Skip to main content

How to create automation rule

The automation rule is used for bulk data processing. To trigger the rule, you should use the CLI command. Alternatively, you can schedule the command to run in your crontab.

You can create a new rule by pressing the Add new button at System -> AI Assistant -> Automation rules.

1. Set general information about rule

In the General information section, set the rule name, choose Entity type, and activate the rule.

note

Automation rule can only be created for Products and Categories scopes.

Via additional options, you can select the store view, set how many times the rule can be applied to a single item (product or category), and define whether the extension can overwrite data in a field if it's not empty.

Save your changes.


2. Add prompt and conditions

Select an available prompt from the list and set the field that the automation rule will work with. If you don't have available prompts, first create a new prompt.

Using Conditions, set which group of products or categories the rule will apply to after being triggered.

note

The rule will be applied only to products that are enabled, visible on the frontend, and meet the rule conditions.


3. Enable logs

To monitor the execution of the rule and evaluate the results, you can enable logging in the extension settings. After that, the execution results will be available in the Log section of your rule.


4. Run automation rule

To run the rule, connect to your server via SSH and execute the CLI command.

To schedule the rule to run at a specific time using cron, edit your cronjob and add a line like this:

20 10 * * * php -f bin/magento mirasvit:assistant:apply-rule --id 1

This command will run the automation rule with id=1 at 10:20 AM. If you have multiple automation rules on your site and run them regularly, make sure to use different times for each rule to avoid conflicts.

You can check the result of the execution in the Logs section of your automation rule. If the rule execution was unsuccessful (for example, due to an error), you can rerun it with the --force option:

bin/magento mirasvit:assistant:apply-rule --id 1 --force