Magento 1.9 – How to Get Quantity of Each Product in Cart cartmagento-1.9qty After added products to cart, we can get all qty in cart. But I want to get qty of each product, how to do? Thanks. This is my cart I added product. I want to get qty of each product, example: product 1( item 1 and 2) qty = 4 Best Answer You can get product quantity like this : $quote = Mage::helper('checkout/cart')->getCart()->getQuote(); $product = []; foreach ($quote->getAllItems() as $item) { $product[]= array ( 'id' => $item->getSku(), 'quantity' => $item->getQty() ); } $product_json = json_encode($product); For get qty of specific product : $quote = Mage::getSingleton('checkout/session')->getQuote(); $product = Mage::getModel('catalog/product')->load($product_id); $_item = $quote->getItemByProduct($product); $qty = $_item->getQty(); Related SolutionsMagento – How to get cart item id using product id in magento2 $productid = 600; $quote = $this->checkoutHelper->getQuote(); foreach ($quote->getAllVisibleItems() as $_item) { $cartproductid = $_item->getProductId(); if($productid==$cartproductid) { your_item_id = $_item->getId(); } } Magento 2 Cart – How to Get Quantity of Added Product You can directly get the total qty of quote without using foreach by using this method $quote->getItemsQty(); If you want to check in order object then you can get it by, $order->getTotalQtyOrdered() Where $quote is Magento\Quote\Model\Quote object and $order is Magento\Sales\Model\Order object. Related Topic
Best Answer
You can get product quantity like this :
For get qty of specific product :