Showing posts with label Magento. Show all posts
Showing posts with label Magento. Show all posts

Friday, December 6, 2013

Magento | Get Product Minimum Sale Qty on Category View / Product List Page

Here is the following code snippet required to be added into your file where you want to display the Minimum Sale Quantity of the Product -

<?php $loadProduct = Mage::getModel('catalog/product')->load( $_product->getId() ); ?>
<?php echo $this->getMinimalQty($loadProduct); ?>

Paste and Enjoy!

Thursday, September 27, 2012

Bestselling Products in Magento

To add a block into Home Page you need to  login into the Magento : CMS > Manage Pages > Home. Then add the following to the Content area:

{{block type=”catalog/product” show_total=”12″ template=”catalog/product/bestseller.phtml”}}

Now put the following code into catalog/product/bestseller.phtml -

   $visibility = array(
        Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
        Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
  );

  $_productCollection = Mage::getResourceModel('reports/product_collection')
                      ->addAttributeToSelect('*')
                      ->addOrderedQty()
                      ->addAttributeToFilter('visibility', $visibility)
                      ->setOrder('ordered_qty', 'desc');
   $totalPerPage = ($this->show_total) ? $this->show_total : 6 ;
   $counter = 1;
Here you have the Best selling Product Collection. Now feel free to manage your Bestseller page with your own Style.

Friday, August 17, 2012

Magento - Get all Cart Product's Categories

Here is the following Code to Get all Product Categories related with Cart :
Use Checkout Session :
$session = Mage::getSingleton('checkout/session');
foreach($session->getQuote()->getAllItems() as $item):
     $_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
     $cartProductCatId = $_product->getCategoryIds();
endforeach;

Thursday, February 9, 2012

Magento - Display total weight of Products in Cart

Here is some code snippet need to put -

$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
$weight = 0;
foreach($items as $item) {
    $weight += ($item->getWeight() * $item->getQty()) ;
}
echo $weight;