1

I am overriding the frontend price by using the Magento\Catalog\Model\Product plugin like so:

Sulman/Mymodule/etc/frontend/di.xml

<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="sulman-product-model-frontend" type="Sulman\Mymodule\Plugin\ProductPlugin" sortOrder="1" />
    </type>
</config>

Sulman\Mymodule\Plugin\ProductPlugin.php:

<?php

namespace Sulman\Mymodule\Plugin;

class ProductPlugin
{

    public function afterGetPrice(\Magento\Catalog\Model\Product $subject, $result)
    {
        return '123.45'; // just testing
    }
}
?>

This is working correctly but when FPC is enabled the prices do not update. (e.g. if I load the page, then change the return price to 789.99 then refresh frontend the price stays at 123.45 - If i then clear cache 789.99 then shows).

How can I get around the cache?

Thanks

Magento 2.4.1

4
  • On which page, you are trying
    – Amit Bera
    Commented Jul 28, 2022 at 3:12
  • @AmitBera - This is on Product List page
    – sulman
    Commented Jul 28, 2022 at 8:22
  • @sulman Did you find a solution for this? Commented Aug 26, 2022 at 8:56
  • @JancyAbraham - No. I ended using customer group pricing. It can be achieved using private data but that seemed like a convoluted method to me.
    – sulman
    Commented Aug 30, 2022 at 9:22

0

Your Answer

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

Browse other questions tagged or ask your own question.