Fall catalog rules in Magento: how to fix the problem

2 min


Magento

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.


Like it? Share with your friends!

What's Your Reaction?

cute cute
300
cute
lol lol
120
lol
love love
90
love
scary scary
300
scary
hate hate
150
hate
geeky geeky
180
geeky
omg omg
30
omg
CmsDaddy

Hello Guys, Here we write about ultimate guides about content management system (CMS) and other software such as WordPress, Joomla, Drupal, Oxwall, Skadate, Prestashop, Magento, CSS, HTML, Linux, CentOS, Ubuntu, Windows, macOS, Android, iOS, iPadOS, etc...

0 Comments

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

Choose A Format
Story
Formatted Text with Embeds and Visuals
Poll
Voting to make decisions or determine opinions
List
The Classic Internet Listicles
Personality quiz
Series of questions that intends to reveal something about the personality
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Ranked List
Upvote or downvote to decide the best list item
Open List
Submit your own item and vote up for the best submission
Countdown
The Classic Internet Countdowns
Video
Youtube and Vimeo Embeds