I have created an event called sales_order_place_after.

$order = $observer->getEvent()->getOrder();
 foreach($order->getAllVisibleItems() as $item){
     $ProdustIds[]= $item->getProductId();
 $Price[]= $item->getPrice();
  $QuoteIds[]= $item->getQuoteItemId();
  $ItemIds[]= $item->getItemId();

Here i am getting price, product id, quote id. But Unable to get Item id , Item id is returning null .

Is there any way to get Item Id ?

  • try this $ItemIds[]= $item->getId();
    – Vino
    Commented Jul 28, 2017 at 12:58
  • For what Purpose you need ItemId ? Commented Jul 28, 2017 at 13:21
  • I need to store item id on custom table, i want to find taxes on that item id. Commented Jul 28, 2017 at 16:41

2 Answers 2


Primary id should get like below

$ItemIds[]= $item->getId(); 


$ItemIds[]= $item->getData('item_id'); 

Hope it will help you.


Try This :

$order = $observer->getEvent()->getOrder();
$orderItems = $order->getAllVisibleItems();

foreach ($orderItems as $key => $item){
        echo $item->getProductId();

Product itself Item Id.

  • I need Item id.. Commented Jul 28, 2017 at 14:40
  • Product id and item id is different. One product id having multiple item ids. Its assign when we placing a order. Commented Jul 28, 2017 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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