Useful Tricks

This section contains some useful programming tricks.
Get associated products

In /app/design/frontend/default/site/template/catalog/product/view/type/ <?php $_helper = $this->helper(‘catalog/output’); ?><?php $_associatedProducts = $this->getAllowProducts() ?><?php //var_dump($_associatedProducts); ?><br /><br /><?php if (count($_associatedProducts)): ?>    <?php foreach…

Cart Data

<?php$cart = Mage::getModel(‘checkout/cart’)->getQuote()->getData();print_r($cart);$cart = Mage::helper(‘checkout/cart’)->getCart()->getItemsCount();print_r($cart);$session = Mage::getSingleton(‘checkout/session’);foreach ($session->getQuote()->getAllItems() as $item) { echo $item->getName(); Zend_Debug::dump($item->debug());}?>

How to delete a quote in Magento

Use the code below to delete a quote: <?php$quoteID = Mage::getSingleton(“checkout/session”) ->getQuote()->getId();if($quoteID){ try { $quote = Mage::getModel(“sales/quote”)->load($quoteID); $quote->setIsActive(false); $quote->delete(); return…

1 9 10 11 42