New Products In Prestashop

New Products In Prestashop

New Products page in Prestashop helps introduce and promote fresh offerings. How does it work from inside? Find out more about the controller, the main Product:: getNewPrоduсts method that returns the list of goods, considered by the system as new, new-products.tpl template and many more.

1

There is a special controller which is responsible for generating a new products page: controllers/front/NewProductsController.php.  This controller implements only 2 methods: initContent and setMedia and it is inherited from the FrontController class. Let’s take a look at each of them:

The method Product:: getNewPrоduсts takes a special place in this controller. The method returns the list of goods, considered by the system as new.  Let’s take a closer look at the method, which returns the collection of new products.

To finish with this controller we need to see what is inside the template new-products.tpl:

The content of the template shows that this is just a compilation of other templates, which we saw on the catalog page. Such an approach makes the markup of the page much easier: you just need to properly markup the category template.  This template, as well as the controller, is very similar to the Bestseller template and controller.

The constant PS_NB_DAYS_NEW_PRODUCT is responsible for the number of days which a product is considered as new. It can be configured in the back office under Preferences – > Products.

2



11 comments

  1. Hello, could the new-products page also be shown directly on the homepage as index? I tried to modify homefeatured module to show new products which was working but the new-products.tpl code is not working in homefeatured.tpl. The page is missing the sort function on the top (pagination and “sort by”).

  2. Hi,

    I would like to filter as new products products which are in stock.

    How could I do that: I guess I could update a SQL statement in the NewProductsController.php page, however I have no clue what and where!

    Could you help me with that (I am using 1.5.6 !)

    Many thanks!
    Xavier

  3. Xavier,

    You can use the function Product::getNewPrоduсts() to modify SQL for receiving new products. This is exactly the place which is responsible for generating the query for receiving new products.

  4. Hi Alex,

    your post is very interesting.
    Is it possible to create a different page with the new products, one for each category?
    For example, i have a store with the category: Man Woman Kids ; i would to have one different page with the new products one for man , one for woman, one for kids.

    Let me know, how i can do it.

    Many Thanks
    Angela

  5. Angela,

    It is possible to implement this, however, this would require developing of a new module, that is why unfortunately I can not provide so much code in a single comment. Anyway, this looks like a good idea for a new article or even module) In case you need to implement this asap, you may contact Valerie at store@belvg.com for help.

  6. How to change the controller if i want filter the product by feature alex, example i add feature publish_date in all product, and i want show only prduct with publish_date between 2010-10-01 until 2015-01-01

    Thanks alex

  7. Mark Cuy,

    You need to modify the query in the function, that returns a collection of new products.

  8. Hi, Alex. What would be the syntax to check only if a product is considered as new?

    I’m trying the following:

    (Product::getNewProducts($IdProduct) > 0) ? 1 : 0;

    But it’s not working >.<

  9. I wonder it is possible to show number of new products added? I have 2000 new products. It will be nice to show customer this information

Post a new comment

top