-: To view random product in your home page :-
>> First you have add this code to your CMS home page content..
{{block type="catalog/product_list_random" name="product_random" template="catalog/product/rand_prod.phtml"}}
>> create 'rand_prod.phtml' in this directory ...
\app\design\frontend\default\imat\template\catalog\product
>> Mage::getSingleton('catalog/layer')->setData("product_collection",NULL);
$this->_productCollection = null;
$_productCollection=$this->getLoadedProductCollection();
$_productCollection=$this->getLoadedProductCollection();
$_collectionSize = $_productCollection->count() ;
$_items = $_productCollection->getItems();
// shuffle($_items);
foreach ($_items as $_product)
{
echo $_product->getName();
echo Mage::getModel('catalog/product')->load($_product->getId())->getDescription();
/* 2nd echo will print product description after getting load */
}
>> Or you can do it By one line
$productCollection->getSelect()->order(new Zend_Db_Expr('RAND()'));
>> http://www.magentocommerce.com/boards/viewthread/51297/
follow this url I wish you will get help.... It's very simple
******** Good Luck ************
>> First you have add this code to your CMS home page content..
{{block type="catalog/product_list_random" name="product_random" template="catalog/product/rand_prod.phtml"}}
>> create 'rand_prod.phtml' in this directory ...
\app\design\frontend\default\imat\template\catalog\product
>> Mage::getSingleton('catalog/layer')->setData("product_collection",NULL);
$this->_productCollection = null;
$_productCollection=$this->getLoadedProductCollection();
$_productCollection=$this->getLoadedProductCollection();
$_collectionSize = $_productCollection->count() ;
$_items = $_productCollection->getItems();
// shuffle($_items);
foreach ($_items as $_product)
{
echo $_product->getName();
echo Mage::getModel('catalog/product')->load($_product->getId())->getDescription();
/* 2nd echo will print product description after getting load */
}
>> Or you can do it By one line
$productCollection->getSelect()->order(new Zend_Db_Expr('RAND()'));
>> http://www.magentocommerce.com/boards/viewthread/51297/
follow this url I wish you will get help.... It's very simple
******** Good Luck ************
No comments:
Post a Comment