0

I want to update the product price using plugin and I tried the afterGetPrice() plugin its working fine in normal case but showing wrong price calculation when catalog price rule applied, I want to apply catalog price rule before the plugin execution. I tired the below code :

di.xml :

 <?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Model\Product">
        <plugin name="change_product" type="Vendor\Module\Plugin\Product" sortOrder="1" disabled="false"/>
    </type>
</config>

Product.php

public function afterGetPrice($product, $proceed) : float
    {
        return $proceed+111.55;
    }

I want to apply catalog price rule before the plugin execution.

15
  • in frontend or backend?
    – Mohit Rane
    Commented Jul 25, 2019 at 12:21
  • Can you talk us through the outcome you are trying to achieve? Commented Jul 25, 2019 at 12:22
  • I just want to update the price on frontend via some condition
    – MagentoDev
    Commented Jul 25, 2019 at 12:23
  • post your di.xml and module.xml, also mention the file for this code afterGetPrice() you have mentioned.
    – Mohit Rane
    Commented Jul 25, 2019 at 12:27
  • @MohitRane question edited
    – MagentoDev
    Commented Jul 25, 2019 at 12:30

1 Answer 1

0

You should use afterGetFinalPrice instead of afterGetPrice, that way all calculations of prices will be done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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