Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Random New Products
 
BarkTop
Jr. Member
 
Total Posts:  1
Joined:  2008-09-09
 

Hi, I have used the new products static block on my homepage. It shows the same 5 products every time anyone visits this page. Does anyone know what code I would change to make the products show up randomly instead of always the same 5 products? Thanks for your help!

 
Magento Community Magento Community
Magento Community
Magento Community
 
reboot
Member
 
Total Posts:  39
Joined:  2008-12-21
 

anyone?  this would be much appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Eric Cavalcanti
Guru
 
Avatar
Total Posts:  710
Joined:  2008-09-28
San Antonio
 

I need that too, anyone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
JeanDaPaul
Jr. Member
 
Total Posts:  29
Joined:  2009-02-20
 

This will show u random new products.

Change \\app\\code\\core\\mage\\catalog\\block\\product\\new.phtml with the following code.

const DEFAULT_PRODUCTS_COUNT 3// change this in to your product count

set cache_lifetime on 0 if u wanna see other products everytime when u refresh

\'cache_lifetime\'    => 86400// set this on 0

Add $collection->getSelect()->order(\’rand()\’); under $collection->setVisibility(Mage::getSingleton(\’catalog/product_visibility\’)->getVisibleInCatalogIds()); on line 81 see below.

$collection->setVisibility(Mage::getSingleton(\'catalog/product_visibility\')->getVisibleInCatalogIds());
$collection->getSelect()->order(\'rand()\');
 
Magento Community Magento Community
Magento Community
Magento Community
 
dvanzan
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2010-06-29
 

you can set variable _productsCount="your product count” in CMS like this

{{block type="catalog/product_new" name="home.catalog.product.new" template="catalog/product/new.phtml" column_count="2" _productsCount="6"}}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top