Magento 2 – How to Override Catalog Price Rules

catalog-price-rulesmagento2

I'm trying to create a module which i'm hoping will extend the Catalog Price Rules feature to allow me to create pricing groups based on Cost plus a percentage (e.g. All products in a category are cost + 30% for specific customer group).

Firstly, how can I ensure that Magento uses this price even if it is higher than the base price??

Secondly, Which files do i need to override?
So far, i've located:

  • vendor/magento/module-catalog-rule/Helper/Data.php – this contains the rule logic

  • vendor/magento/module-catalog-rule/Model/Rule.php – this contains the validation rules

  • vendor/magento/module-catalog-rule/Model/Rule/Action/Product.php – i think this contains the options for the rule logic

  • vendor/magento/module-catalog-rule/Model/Rule/Action/SimpleActionOptionsProvider.php – this also contains the options for the rule logic

  • vendor/magento/module-catalog-rule/Observer/ProcessAdminFinalPriceObserver.php & ProcessFrontFinalPriceObserver.php

Are there any others?

The last thing is that i will obviously need to parse the product cost into these functions, what would be the best way to do that?

Any and all help is greatly appreciated! 🙂

Best Answer

All good, i figured it all out.

  • vendor/magento/module-catalog-rule/Helper/Data.php
  • vendor/magento/module-catalog-rule/Model/Rule.php
  • vendor/magento/module-catalog-rule/Model/Rule/Action/Product.php
  • vendor/magento/module-catalog-rule/Model/Rule/Action/SimpleActionOptionsProvider.php
  • vendor/magento/module-catalog-rule/Observer/ProcessAdminFinalPriceObserver.php
  • vendor/magento/module-catalog-rule/Observer/ProcessFrontFinalPriceObserver.php
  • vendor/magento/module-catalog/Model/Product/Type/Price.php
  • vendor/magento/module-catalog-rule/Model/Indexer/IndexBuilder.php

were the files i needed in case anyone is interested

Related Topic