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;
    ?>

3 Answers 3

7

Try this

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

For eg.

enter image description here

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

1
  • No it's not working
    – Magento 2
    Commented Jan 23, 2016 at 8:51
0

For order Item count use below code.

$items = $order->getAllItems();

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

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.