I want to override magento2 product tier price calculation logic for price type 'Percentage'. I would like to calculate the percentage amount in my own way. Please let me know which file I have to override in order to achieve this.
Thank you
Hello All,
I want to override magento2 product tier price calculation logic for price type 'Percentage'. I would like to calculate the percentage amount in my own way. Please let me know which file I have to override in order to achieve this.
Thank you
Hi @sayanth_k
You will achieve by the plugins.
Create a di.xml on following path:
Vendor/ModuleName/etc/di.xml
<type name="Magento\Catalog\Model\Product">
<plugin name="after_final_price" type="Vendor\ModuleName\Plugin\ChangeTierPrice" sortOrder="999" disabled="false" />
</type>
Create a plugin file:
Path:Vendor\ModuleName\Plugin\ChangeTierPrice.php
<?php namespace Vendor\ModuleName\Plugin; class ChangeTierPrice { public function beforeGetFinalPrice($subject, $qty = null) { $finalTierPrice = []; //You need to create your own array or modify the default tier price here and set in to product object $subject->setData('tier_price', $finalTierPrice); } }
It may help you to resolve your issue.
If issue resolve, please click on 'Kudoes' & Accept as Solution!
I tried your code but the function is not getting called.