Ratings Refresh Cronjob

Introduction

Purpose

This cronjob processes the “Advanced Ratings Mode” queue. Therefore it only works in combination with activated Advanced ratings mode.

ASA2 ratings cronjob

Basics

To learn more about cronjobs in general, check out the Introduction chapter.

Setup

To learn more about setting up and using ASA2’s cronjobs, see the dedicated Cronjob Setup chapter.

Usage

Name

The internal name of this cornjob is Asa2_Cron_Ratings.

Therefore, use it with the Server-side execution like this:

bash script.sh Asa2_Cron_Ratings --quantity=5

And with WP Cron API and ASA2’s Cron Wrapper like this:

$cronWrapper = new \Asa2\Cron\Wrapper('Asa2_Cron_Ratings');
$cronWrapper->setOptions([
    'quantity' => 5,
]);
$cronWrapper->execute();

REST API Endpoint

The REST API endpoint name of this cronjob is ratings.

Example:

https://example.com/wp-json/asa2/v1/ratings/?token=[your-token]&quantity=5

Check Cron REST API for more details about running ASA2’s cronjobs via URL.

Recommendations

It is recommended to execute the ratings refresh cronjob every three minutes. If there are no problems and you have a lot of products, you can increase the frequency to every minute.

Options

pause

Can be used to define a pause in seconds between each processed rating. Can be set globally for all executions with the option Cronjob pause.

ASA2 ratings cronjob with pause option
// to set a pause of 2 seconds:
bash script.sh Asa2_Cron_Ratings --pause=2

php

With the php option, you can tell the ASA2 cronjob what PHP executable it should use to execute the command. With some webhosters the standard command “php” executes an outdated version and there is a special command for each version, e.g. “php74”, “php81” or “/opt/php81/bin/php”.

Please check which PHP version is required for the use of ASA2 here: https://bit.ly/asa2-php-version

bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=10 --php=php74
bash script.sh Asa2_Module_Repo_Cron_Refresh --limit=10 --php=/opt/php81/bin/php

proxy_id

With option proxy_id you can define the proxy you want to use. You can get the ID from the proxy list. Make sure that the “ID” column is enabled (see Screen Options).

If this option is not used, ASA2 automatically determines a proxy.

ASA2 proxy ID
// to process item 915 from the ratings queue
bash script.sh Asa2_Cron_Ratings --proxy_id=10

quantity

The quantity option can be used to set the quantity of products to be processed. Can be set globally for all executions with the option Cronjob items per run.

ASA2 ratings cronjob with quantity option
// to process 5 products in a cronjob run:
bash script.sh Asa2_Cron_Ratings --quantity=5

queue_id

With option queue_id you can selectively grab a product from the rating queue.

ASA2 ratings queue
// to process item 915 from the ratings queue
bash script.sh Asa2_Cron_Ratings --queue_id=915

verbose

Use the verbose option to get more information on the console.

bash script.sh Asa2_Cron_Ratings --verbose