Bas
Bas

Reputation: 13

Magento adding new products by date "automatically" to homepage

Im searching for an option to add new arrivals to my homepage of my shop automatically so not by set date option that magento offers now.

I want to display the 5 or 6 newest products that I added to my shop no matter what catagory they are in . So just every new product that I add must be displayed there. Ive already created a block for it and such but cant find solution to call this information.

Any advice on how to create this?

Thanks in advance if you need something more specific please ask

Upvotes: 0

Views: 997

Answers (1)

Steve Robbins
Steve Robbins

Reputation: 13812

You can get a collection of the 5 most recently added with

<?php

$productCollection = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToSelect(
        Mage::getSingleton('catalog/config')->getProductAttributes()
    )
    ->setOrder('created_at', Zend_Db_Select::SQL_DESC)
    ->setPageSize(5);

You could create a custom block with a method getProductCollection() that returns the above, and use the catalog/product/new.phtml template.

Upvotes: 1

Related Questions