This is the documentation for LemonStand V1, which has been discontinued. You can learn more and upgrade your store here.

LemonStand Version 1 Has Been Discontinued

This documentation is for LemonStand Version 1. LemonStand is now offered as a cloud-based eCommerce platform.
You can try the new LemonStand and learn about upgrading here.

How to Automatically Apply Price Rules to Products

How to apply price rules automatically, using a cronjob

You can configure a cronjob for applying the price rules automatically, for example on daily basis. LemonStand has a special URL, which, once accessed, forces price rules to apply. This URL is
/ls_shop_apply_catalog_rules

The full URL depends on your server name and can look like this:
http://yourserver.com/ls_shop_apply_catalog_rules

To invoke this URL by a cronjob you can use the CURL command:
curl http://yourserver.com/ls_shop_apply_catalog_rules

If you use CPanel it is very simple to add a cronjob using the graphic interface. The following image displays a cronjob configuration in the CPanel Standard Cron Manager:

If you configure cronjobs manually, a cronjob entry in the crontab file can look as follows:
0 * * * * curl http://yourserver.com/ls_shop_apply_catalog_rules

This cronjob will apply the price rules each midnight.

Granting IP access for invoking the cron commands

By default the access to the script for applying the price rules is denied for any IP. You can allow access to the script from specific IP addresses.

First, you need to detect which IP address has the server you invoke the URL from. To do it, you need to access the URL from the server where you are configuring the cron job, using a browser or a command line. Open the http://yourserver.com/ls_shop_apply_catalog_rules (use a correct server URL) script in a browser, or from a command line using the CURL application, and look to the error message:
Error. Cron access from the IP address 127.0.0.1 is denied.

To grant access to the script from specific IP address (in this case 127.0.0.1), please open the /config/config.php file in a text editor and find the following configuration parameter:

$CONFIG['CRON_ALLOWED_IPS'] = array();

Add the IP address to the list of allowed addresses:

$CONFIG['CRON_ALLOWED_IPS'] = array('127.0.0.1');

Save the document and try to invoke the script again, using a browser or a command line. If you configured the permissions correctly, you will see a confirmation message:
Price rules have been successfully applied to 139 product(s).


Previous: Managing catalog level price rules
Return to Managing catalog level price rules