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
  1. July 16th, 2011
    Trackback from : Magento « PHP Web Developer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: