Repo items refresh

Use this cronjob to automatically update the items in your ASA 2 Repo (see Repo). Long page loading times caused by outdated embedded products will be a thing of the past.

Asa2_Module_Repo_Cron_Refresh

The script to use can be found in ASA 2‘s subdirectory scripts.

Execute it like this:

cd /path-to-your-wp-installation/wp-content/plugins/amazon-simple-affiliate/scripts

bash script.sh Asa2_Module_Repo_Cron_Refresh

There are several Options you can use to fit the cronjob to your requirements.

bash script.sh Asa2_Module_Repo_Cron_Refresh -lt=3600 --limit=50 -cat=31 tag=sale --verbose --log --logpath=/home/me/tmp/asa2

Setup

Let’s assume you have 250 products in your Repo and you want to refresh them once a day. If you configure the cronjob to run once every hour, it should refresh 11 products in every run: 250 products / 24 hours = 10.41 products per hour.

To make sure all 250 products will be handled within 24 hours, set option lifetime to “86400” (seconds) which means a product will only get refreshed once per day.

Replace [wp_path] with the local server path of your WordPress installation.

This cron job will run at minute zero, every hour:

0 * * * * /[wp_path]/wp-content/plugins/amazon-simple-affiliate/scripts/script.sh Asa2_Module_Repo_Cron_Refresh --lifetime=86400 --limit=11

To learn more about cronjobs, see Introduction.

Options

help

Prints a help text showing all available options and how to use them.

bash script.sh Asa2_Module_Repo_Cron_Refresh --help

country_code

Filters the result of repo items to be updated by country code. Mulitple country codes must be separated by comma.

// update 10 items from the US and German store:
bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=10 --country_code=DE,US

// update all items from the Canadian store
bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=-1 --country_code=CA

limit

Limits the amount of repo items to be updated. Default is 10.

bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=50

Use -1 for no limit.

bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=-1

lifetime

Use the lifetime option to only include items with a last refresh time older than the defined lifetime in seconds. Default is 86400 (one day).

For example, if you want to use the cronjob to only update repo items older than two hours, use a lifetime of 7200.

bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=50 --lifetime=7200

cat

Use the cat option to filter the results by category ID. You can define multiple categories as comma separated list.

For example, only update repo items from category 31 and 40.

bash script.sh Asa2_Module_Repo_Cron_Refresh cat=31,40

tag

Use the tag option to filter the results by tag slug. You can define multiple tags as comma separated list.

For example, only update repo items with tag slug “green” and “sale”.

bash script.sh Asa2_Module_Repo_Cron_Refresh tag=green,sale

You can combine the cat and tag options. For example, only update repo items from category 31 and 40 with tag slug “green” and “sale”:

bash script.sh Asa2_Module_Repo_Cron_Refresh cat=31,40 tag=green,sale

log

Activates the cronjob log. This will write the cronjob results to a file defined with logpath.

logpath

If you want to use the log feature, you must define a directory path. It must be writable. ASA 2 will create a log file asa2reporefresh.log there. Using a log rotate function new files will be created when the old reaches 20MB.

bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=50 --lifetime=7200 --log --logpath=/home/me/tmp/asa2

verbose

Use the verbose option to get more information about the updated repo items.

bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=50 --lifetime=7200 --verbose