Magento Document
Cart Information:
Get all items information in cart
// $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems(); $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
foreach($items as $item) {
echo 'ID: '.$item->getProductId().'
';
echo 'Name: '.$item->getName().'
';
echo 'Sku: '.$item->getSku().'
';
echo 'Quantity: '.$item->getQty().'
';
echo 'Price: '.$item->getPrice().'
';
echo "
";
}
Get total items and total quantity in cart
$totalItems = Mage::getModel('checkout/cart')->getQuote()->getItemsCount(); $totalQuantity = Mage::getModel('checkout/cart')->getQuote()->getItemsQty(); Get subtotal and grand total price of cart
$subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal(); $grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();
Filter products by Price programmatically.
$html='
- ';
$html .= $this->priceHtmlnav($maincategoryId);
$html .='
echo $html;
/price block html it took price filter and display in menu/
public function priceHtmlnav($maincategoryId) {
$html='';
$layer = Mage::getModel('catalog/layer');
$category = Mage::getModel('catalog/category')->load($maincategoryId);
if ($category->getId()) {
$origCategory = $layer->getCurrentCategory(); $layer->setCurrentCategory($category); } $attributes = $layer->getFilterableAttributes('price');
foreach ($attributes as $attribute) { if ($attribute->getAttributeCode() == 'price') { $filterBlockName = 'catalog/layer_filter_price'; $result = $this->getLayout()->createBlock($filterBlockName)->setLayer($layer)->setAttributeModel($attribute)->init(); foreach($result->getItems() as $option) { $t=str_replace('', "", $option->getLabel()); $t=str_replace('', "", $t); $html .='
} } }
return $html; }