Prestashop: [Template inheritance] Prices-drop and best-sales

Created on 11 Mar 2020  路  6Comments  路  Source: PrestaShop/PrestaShop

I noticed, some problems in template inheritance : some typos and missing params, that causes template inheritance not working as it should be.

The core checks locations in order, for specific entities :
https://github.com/PrestaShop/PrestaShop/blob/7633be8294d90148d2bdfe3fd1c2d403e72ec91b/classes/Smarty/TemplateFinder.php#L37-L41

Unfortunately there is some typos here :

- private $productListSearchEntities = array('search', 'price-drop', 'best-sale');
+ private $productListSearchEntities = array('search', 'prices-drop', 'best-sales');

And as the param 'entity' => 'prices-drop' is not passed
from src/controllers/front/listing/PricesDropController.php
to classes/smarty/TemplateFinder.php::getTemplateHierarchy()

it causes Prestashop to find only the exact-file : catalog/listing/prices-drop and not one of the following :

  1. catalog/listing/prices-drop
  2. catalog/listing/product-list

If the 1st file don't exists, the "fallback template" (2) never loaded and a [PrestaShopException] No template found for catalog/listing/prices-drop is triggered.

I can make a PR if needed.


Prestashop 1.7.6.1 / PHP 7

1.7.5.2 1.7.6.1 1.7.6.4 Bug CO Fixed PR available

All 6 comments

HI @glafarge,

Thanks for your report.
Could you please add steps to reproduce the issue in a new comment.
Maybe a reference: https://devdocs.prestashop.com/1.7/themes/reference/template-inheritance/

Thanks!

Hi.

Steps :

  1. Create a file catalog/listing/prices-drop.tpl
  2. Go to prices-drop page on your shop : displays the template correctly.
  3. Delete the file catalog/listing/prices-drop.tpl
  4. You will see that the fallback catalog/listing/product-list.tpl is not loaded as expected in template inheritance (an error is triggered).

See the causes on my first comment.

@glafarge, thanks for your feedback.

  1. Create a file catalog/listing/prices-drop.tpl

This file exists by default
https://github.com/PrestaShop/PrestaShop/blob/develop/themes/classic/templates/catalog/listing/prices-drop.tpl

  1. Delete the file catalog/listing/prices-drop.tpl

Now, I have this exception
image

Thanks to check & feedback.

@glafarge, is it the issue reproduced in your case?

Thanks!

@khouloudbelguith Yes this is the issue. I will make a PR. It'll be clearer i think.

@glafarge, thanks for your feedback and for the fix.
I have the same issue with PS1.7.5.2 and PS1.7.6.4.
I will add to the debug roadmap.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings