0

I am working in a module which extends catalogrule feature

In this module, we apply some changes to price calculation process. Right now, it is working when a product is saved in admin. We have achieved that by rewriting some classes in Magento/CatalogRule/Model/Indexer folder Magento2 catalogrule promotions, ability to choose price or special_price?

The pending thing is: module code are not being executed when applying rules in admin. I was thinking to observe catalogrule_apply_all event, but I am not sure if it still exists in Magento 2.3

The only reference for that event I have found is in vendor/magento/module-catalog-rule/Model/Rule/Job.php class

/**
 * Dispatch event "catalogrule_apply_all" and set success or error message depends on result
 *
 * @return \Magento\CatalogRule\Model\Rule\Job
 * @api
 */
public function applyAll()
{
    try {
        $this->ruleProcessor->markIndexerAsInvalid();
        $this->setSuccess(__('Updated rules applied.'));
    } catch (\Magento\Framework\Exception\LocalizedException $e) {
        $this->setError($e->getMessage());
    }
    return $this;
}

But that markIndexerAsInvalid() function doesn't seem to fire any event. It just seem to invalidate related index

Any tips? Which code is fired when applying catalog rules in admin?

1

It seems, at least in 2.3 version, that event catalogrule_apply_all is not being used (nor fired) any more

As index management in Magento2 is reserved to cron it makes sense just flagging the relevant index as invalid, so next cron execution will reindex & do what was done in catalogrule_apply_all event

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.