Archive for February, 2011

How to display Random Product in magento


<?php	

	$collection = Mage::getResourceModel('catalog/product_collection');
        Mage::getModel('catalog/layer')->prepareProductCollection($collection);
        $collection->getSelect()->order('rand()');
        $collection->addStoreFilter();
        $this->setProductCollection($collection);
        return parent::_beforeToHtml();

        //below code to written in template file

        if (($_products = $this->getProductCollection())):
        	echo $_product->getSku();
        endif;

?>


for more info visit mage-people

Advertisements