【发布时间】:2021-02-04 02:33:36
【问题描述】:
在应用所有目录规则后,我需要更改所有页面中的产品价格,用于目录(产品列表)、购物车等的所有操作。我在 frontend/di.xml 上为 Magento\Catalog\Pricing\Price\FinalPrice 创建了一个插件
<?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>
然后我就有了方法
public function afterGetMinimalPrice(
\Magento\Catalog\Pricing\Price\FinalPrice $subject,
$result
) {
//Custom code here
return $result;
}
我只能为产品页面获取 $result 上的值,但我无法更改该值。最重要的是,我需要在其他地方更改它,例如类别页面等等...更改正常价格很容易,就像这种方法https://webkul.com/blog/set-custom-product-price-when-displaying-on-front-end-in-magento-2/#comment-44779 ...但是当应用了目录规则时,情况就不同了。有人可以指出我正确的方向吗?亲切的问候和感谢任何形式的帮助。
【问题讨论】:
标签: magento magento-2.0