'Change the product price after catalog price rules in Magento 2

I need to change the product price in all the pages, for all the operations... on catalog (product listing), cart, etc... after all the catalog rules are applied. I've created a plugin for Magento\Catalog\Pricing\Price\FinalPrice on frontend/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\Pricing\Price\FinalPrice">
        <plugin name="Pefsa_Redondeo_Plugin_Magento_Catalog_Pricing_Price_FinalPrice" type="Pefsa\Redondeo\Plugin\Magento\Catalog\Pricing\Price\FinalPrice" sortOrder="10" disabled="false"/>
    </type>
</config>

And then I have the method

public function afterGetMinimalPrice(
        \Magento\Catalog\Pricing\Price\FinalPrice $subject,
        $result
    ) {
        //Custom code here
        
        return $result;
    }

I'm able to get the value on $result only for product page but I can't change that value. Above all I need to change it every where else like the category pages and so on.

Changing the normal price is easy like this approach https://webkul.com/blog/set-custom-product-price-when-displaying-on-front-end-in-magento-2/#comment-44779 ... but when there are catalog rules applied the thing is different.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source