在 Magento 2 目录价格规则后更改产品价格

时间:2021-02-04 02:33:36

标签: magento magento-2.0

我需要更改所有页面中的产品价格,对于所有操作...在目录(产品列表)、购物车等...应用所有目录规则后。我在 frontend/di.xml 上为 Magento\Catalog\Pricing\Price\FinalPrice 创建了一个插件

n

然后我有方法

<?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>

我只能获取产品页面的 $result 值,但我无法更改该值。最重要的是,我需要在每个其他地方更改它,例如类别页面等等...更改正常价格很容易,就像这种方法https://webkul.com/blog/set-custom-product-price-when-displaying-on-front-end-in-magento-2/#comment-44779 ...但是当应用了目录规则时,事情就不同了。有人可以指出我正确的方向吗?衷心的问候并感谢您提供的任何帮助。

1 个答案:

答案 0 :(得分:0)

朋友...我发现如果我在插件上使用 afterGetValue() 而不是 afterGetMinimalPrice() 方法,实际值更改,在产品页面和类别页面...但当我将产品添加到购物车时不起作用。任何想法都会受到高度赞赏。

谢谢