Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在观察者中,我想从订单对象中获取产品 ID 和客户 ID……我怎样才能进入 Magento 2?
我无法从订单对象中获取它。
这里得到了答案
$order = $observer->getEvent()->getOrder(); $items =$order->getAllVisibleItems(); //product ids $productIds = array(); foreach($items as $item) { $productIds[]= $item->getProductId(); } //custoemr id $customerId = $order->getCustomerId();