Home >How to Display Latest Products in Magento 1

How to Display Latest Products in Magento 1

As you know, there are a huge number of products belonging to various categories on a Magento store. Hence, store owners normally can only show some items such as the latest products for customers to attract their attention. So how to display these products on Magento? In this article, we will give you guys a very detailed tutorial for showing the latest products on Magento stores.

We can place the latest products anywhere on Magento websites, but the most simple way is to create a CMS page and put these items on this page.

Firstly, you go to CMS -> Pages -> Add New Page.

How to Display Latest Products in Magento 1

In the content section of the CMS page, we will fill in this string :

{{block type = “catalog / product_list” template = “catalog / product / latest.phtml”}}

How to Display Latest Products in Magento 1

For the new Magento version, you need to add the catalog/product_list to the System section. You have to select Permissions -> Blocks -> Add New Block to use this block.

How to Display Latest Products in Magento 1

Now, you go to app/code/design/frontend/vendor_name/theme_name/template/catalog/product/ and create a file as latest.phtml. This file needs to include the following code:

<?php

$productCollection = Mage::getModel('catalog/product')->getCollection()

->addAttributeToSelect('*')

->addAttributeToSort('created_at', 'desc')

->addAttributeToFilter('status', 1) 

->setPageSize(10); 

foreach ($productCollection as $product):            

<template> 

endforeach;

?>

In which:

->addAttributeToSort(‘created_at’, ‘desc’): this string means sorting order of products by the creation date (start from the latest date).

->addAttributeToFilter(‘status’, 1): this string means filtering products which have status as Enable.

->setPageSize(10): this string means getting 10 products to be displayed.

*Note: In the <template> line of the above code, you need to add the template of the latest products which you want to display (or you can use the template of category from the  catalog/product/list.phtml file).

For more details, you can take a look at the example in this file: latest.phtml

Then you save configuration and go to the frontend to see the final result. All of the latest products are displayed on the frontend as the following image:

How to Display latest products in Magento 1

Hope this article on “How to display latest products in Magento 1” is helpful. Feel free to take a tour around and explore dozens of Magento tutorials.

< Previous Post
Next Post >
+ posts