Question

    $cart = Mage::getModel('checkout/cart')->getQuote();
    $cartTotal =$cart->getGrandTotal();
    $cartItems = $cart->getAllItems();
            foreach ($cartItems as $item) 
            {
                $_product = $item->getProduct();
                $id=$_product->getId();
                $qty = $_product->getQty(); //get product Qty
                $image=$_product->getImageUrl();
            }
Était-ce utile?

La solution

Vaibhav, veuillez utiliser getAllVisibleItems plutôt getAllItems

pour obtenir aucune quantité d'article du panier, vous devez utiliser getQty()

$cart = Mage::getModel('checkout/cart')->getQuote();
$cartTotal =$cart->getGrandTotal();
$cartItems = $cart->getAllVisibleItems();
foreach ($cartItems as $item) 
{
    $_product = $item->getProduct();
    $id=$_product->getId();
    $qty =  $item->getQty(); //get item qty

}

Pour obtenir current product qty , vous devez charger product model by sku alors prends inventory à partir d'un objet en stock

$_producObject = Mage::getModel('catalog/product')->loadByAttribute('sku',$item->getSku());
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_producObject);
echo "<pre>"; 
print_r($stock->getData()); 
echo "</pre>";
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top