Magento: get the last added product id and cart items
This code snippet demonstrates how to get the product id of the last product that was added to the shopping cart, as well as to get all the products currently in the shopping cart.
$productID=Mage::getSingleton('checkout/session')->getLastAddedProductId(true); echo $productID."<br>"; $_product=Mage::getModel('catalog/product')->load($productID); echo $_product->getName()."<br>"; $session= Mage::getSingleton('checkout/session'); foreach($session->getQuote()->getAllItems() as $item) { $productID = $item->getProductId(); $productSku = $item->getSku(); $productName = $item->getName(); $productQty = $item->getQty(); echo $productID."|".$productSku."|".$productName."|".$productQty."<br>"; }
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts