Load Optimization of AdminSpecificPriceRule Controller in Prestashop

November 3, 2015 / Posted in Prestashop by Alex Simonchik
blog-admin specific price rules
Download PDF

Catalog Price Rules is a widely used Prestashop tool for mass creation of discounts. But if you have a lot of features and feature_values associated with them, one day this function can get unavailable for you. Let’s check why exactly you won’t be able to use it.

1Load Optimization

The reason is hidden in the AdminSpecificPriceRuleControllerCore::renderForm method, and more particularly here:

The thing is while loading the form, Prestashop tries to load all features and their values because Catalog Price Rules allows using Features as one of the conditions for a discount.

2Load Optimization

We solved this problem using asynchronous load of Feature Values.

To do so made a few corrections:

1.

2. The FeatureValue::getFeatureValueWithLang() class is a new method that gets values for a particular Feature.

class FeatureValue extends FeatureValueCore

3.  The SpecificPriceRule::getConditions() class

4. Override of a theme file

/administration/themes/default/template/controllers/specific_price_rule/helpers/form/form.tpl

5. New action in AdminSpecificPriceRuleController::ajaxProcessGetFeatureValues() controller that is used in /administration/themes/default/template/controllers/specific_price_rule/helpers/form/form.tpl

Download all changed files here.



2 comments

  1. Hello,

    Is it possible to fix the link, download is not working. Also i am having issues to understand exactly where you need to modify, could you please look maybe you havent specified clearly what file and where to add/modify.

    Thank you

Post a new comment