0

We are using magento 1.9. In that

How to get ordered product count not order qty of product. I want to how many product is there in that order?

I am using this but it showing ordered qty only

 <?php 
        $_order = $this->getOrder(); //call the order
        echo $order_qty = floor($_order->getData('total_qty_ordered')); //get qty of all items rounded to full number (without 3.0000 or so)
        //echo $order_qty;
    ?>
4

Try this

    <?php $_order = $this->getOrder() ?>
<?php echo $_order->getTotalItemCount();?>

For eg.

enter image description here

  • No it's not working – Magento 2 Jan 23 '16 at 8:50
  • Can share your code ??? – Abdul Jan 23 '16 at 8:58
  • code means i jus want to display how many product available in sales order page backend – Magento 2 Jan 23 '16 at 9:00
  • ChecK $order = Mage::getModel('sales/order')->load($orderId); echo '<pre>'; print_r($order); – Abdul Jan 23 '16 at 9:04
  • and give response me :) – Abdul Jan 23 '16 at 9:06
1

You have to use $items = $order->getAllVisibleItems() instead of $items = $order->getAllItems().

getAllItems gets the configurable along with its associated simple product.

echo $NumberOfItem = count($items);

so its up to you to use in your way.

  • No it's not working – Magento 2 Jan 23 '16 at 8:51
0

For order Item count use below code.

$items = $order->getAllItems();

$itemcount = count($items);
  • No it's not working – Magento 2 Jan 23 '16 at 8:51
  • may be it help you : $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); then use upper code. – Hitesh Vaghasiya Jan 23 '16 at 10:47

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.