1

I need to change price of products using plugin. I used following method for it.

<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_price" type="Namespace\Module\Plugin\Price" />
    </type>
</config>

Created following plugin class:

namespace Namespace\Module\Plugin;

    class Price
    {
        public function afterGetPrice(\Magento\Catalog\Model\Product $subject, $result){


            return $result;
        }
    }

This is working perfectly for simple product but this is not working with configurable product. I need to carry all type of products.

2
  • Did you get an answer to this offline? as I am in the same situation
    – Goose84
    Commented Aug 2, 2018 at 7:22
  • Thank you, Nope, I did't get answer but I checked that product is having parent configurable product or not. If yes then I wrote code to change the price of that particular product. Commented Aug 2, 2018 at 7:59

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.