0

How can I get additional data for each order item, based on order id? I need to get additional data for each order when order is made. I already implemented the observer, it works fine. I hooked observer to the sales_order_place_after event, it seems that at this moment, the additional data is not yet saved into the database, so maybe it is not available to this event? When is additionalData for an order item created, and where can I catch it, while the order is being made, ie. what is the soonest (earliest) moment I can catch this data and how?

1

You can use this code to get orders items in observer: Magento 2

$orderId = '';
$order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId);
$orderItems = $order->getAllItems();
    foreach( $orderItems as $item ):
         $productId = $item->getProductId();
        /* Here we can get additional data */
    endforeach;
} 

Magento 1.8: You can get order data by:

 $orderdata = Mage::getModel('sales/order')->load($orderId);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.