Magento is a rather complex control system Online store and not all when you work with it smoothly. One of the frequent problems to stop working catalog price rules not working discounts for different product groups. About how to help the cause, will be shown in this article.

Help the Magento system manually

The easiest way to correct the situation is to go to Marketing, Pricing rules for catalog, and click Apply rules.

The method is simple and suitable if the rules are flies not very often. If it happens once a month or at least once a week – you can tolerate it until you clarified the reason for the failure. Still, the administrator at least once a week and goes to the control panel, so press the button and wait a few moments until the rules are applied – no problem.

A crutch for the lazy

This situation is bad because of the failure of price regulation – quite a lot. In search of a problem, you can spend a lot of time. But managers will sound the alarm, the store users will be unhappy, the bosses too. Therefore, we offer a kind of crutch, namely the automation button is pressed to Apply the rules.

Navigate to the root documents directory of the webserver. If there is no shell directory, create it. In the directory shell, create a file apply_rules.php with the following content:

<?php
echo "Apply rules\n";
require_once './app/Mage.php';
$app = Mage:app('admin');
$rule = new Mage_CatalogRule_Model_Rule;
$rule->applyAll();
echo "Done\n";
?>

This script can be created anywhere on the webserver but then you need to edit the path to the Magento script Mage.php. No need to be a PHP programmer to guess that makes the scenario gets the model rules of the directory and calls a method applyAll() to enforce all rules.

After the PHP script established, you need to automate the process of starting it. Create a file apply with the following content:

#!/bin/bash
cd /path/htdocs/shell
/usr/bin/php apply_rules.php

Here you need to change the path to the directory shell, which is our scenario apply_rules. Next, you need to make the file executable apply:

chmod +x apply

All you can test:

./apply

If after this script is run, the rules have been applied, you did the right thing. Next, you need to ensure the continued run of this script, run the command

crontab-e

Add to the schedule the following:

00 8 * * * sh /path/apply

Save the changes and then exit the editor. This line will run the script at 8 am every day. If the rules disappear more often than once in a day, you can run this script more often – at least every hour.

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *