Stefan Schuchlenz
Stefan Schuchlenz

Reputation: 117

Magento latest products without "new" flag

I need to create a block that displays the latest products in the store without making use of the "new from / new to" option (since the customer's ERP system does not understand these attributes and thus they will stay empty and cannot be maintained in the store's admin panel since this would break the connectivity with the ERP system).

Can anyone please provide an example on how to achieve this (preferred method would be to load products ordered by date of creation)?

Upvotes: 1

Views: 172

Answers (1)

SeniorDeveloper
SeniorDeveloper

Reputation: 906

If you are wanting to grab the latest products that were created you can do something like this.

$collection = Mage::getModel('catalog/product')
              ->getCollection()                   
              ->addAttributeToSort('created_at', 'desc'); 

Then you can load each one individually like so:

foreach($collection as $products) {
    $_product = Mage::getModel('catalog/product')->load($products->getEntityId());

    //Lets echo the product name
    echo $_product->getName();
}

Upvotes: 2

Related Questions