In an Observer I want to get the product id and customer id from order object...how can I get in Magento 2.
I am not able to get it from order object
Here got answer
$order = $observer->getEvent()->getOrder();
$items =$order->getAllVisibleItems();
//product ids
$productIds = array();
foreach($items as $item) {
$productIds[]= $item->getProductId();
}
//custoemr id
$customerId = $order->getCustomerId();