We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

Product price is a dynamic thing. It keeps changing time-by-time.

That’s why we came up today to talk about “product & pricing” subject.

If you want to change product pricing with plugin, then this article is for you.

Well, to do the same you have to add below code in di.xml

<config>
  <type name="MagentoCatalogModelProduct">
    <plugin name="change_product" type=" MagemonkeysPricechangePluginProduct " sortOrder="2" disabled="true"/>
  </type>
</config>

After doing same, go to MagemonkeysPricechangePlugin to add new class Product.php.
There you need to add code which we going to write below. Below code will work when the original method getPrice() complete. You can always put your logic into it.

<?php
 
namespace MagemonkeysPricechangePlugin;
 
class Product
{
    public function afterGetPrice(MagentoCatalogModelProduct $subject, $result)
    {
        return $result + 100;
    }
}
?>

Last but not the least, do flush cache before you check.

 

field_5bfb909c5ccae

    Recent Articles
    Get a Free Quote

      Full Name

      Email Address

      Mobile Number

      Message

      Let’s initiate a discussion!!

      With Only Agency that provides a 24/7 emergency support.

        Full Name

        Email Address

        Mobile Number

        Message