安装Magento 2.0.4之后,我面临一个非常奇怪的问题。我创建了一个价格为12美元的产品,并从后端的Magento配置更改了语言环境。
以下是列表页面的屏幕截图。
还可以在详细页面上找到以下屏幕截图。
您可能已经注意到两个屏幕截图之间的区别。是的,产品详细信息页面显示的价格为0.00美元,而列表页面保留了我添加的价格。
一秒钟或两秒钟后,“产品详情”页面会自动将正确价格更新为$ 0(Java更新)。
查找以下代码
$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({data: price}));我在代码中进行了进一步调试,并找到了另一个将参数传递给Magento 2 pricebox小部件的JavaScript代码。
<script>
    require([
        'jquery',
        'Magento_Catalog/js/price-box'
    ], function($){
        var priceBoxes = $('[data-role=priceBox]');
        priceBoxes = priceBoxes.filter(function(index, elem){
            return !$(elem).find('.price-from').length;
        });
        priceBoxes.priceBox({'priceConfig': <?php /* @escapeNotVerified */ echo $block->getJsonConfig() ?>});
    });
</script>
现在我已经检查了getJsonConfig()方法,
  $product = $this->getProduct();
        if (!$this->hasOptions()) {
            $config = [
                'productId' => $product->getId(),
                'priceFormat' => $this->_localeFormat->getPriceFormat()
                ];
            return $this->_jsonEncoder->encode($config);
        }
        $tierPrices = [];
        $tierPricesList = $product->getPriceInfo()->getPrice('tier_price')->getTierPriceList();
        foreach ($tierPricesList as $tierPrice) {
            $tierPrices[] = $this->priceCurrency->convert($tierPrice['price']->getValue());
        }
        $config = [
            'productId' => $product->getId(),
            'priceFormat' => $this->_localeFormat->getPriceFormat(),
            'prices' => [
                'oldPrice' => [
                    'amount' => $this->priceCurrency->convert(
                        $product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue()
                    ),
                    'adjustments' => []
                ],
                'basePrice' => [
                    'amount' => $this->priceCurrency->convert(
                        $product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount()
                    ),
                    'adjustments' => []
                ],
                'finalPrice' => [
                    'amount' => $this->priceCurrency->convert(
                        $product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue()
                    ),
                    'adjustments' => []
                ]
            ],
            'idSuffix' => '_clone',
            'tierPrices' => $tierPrices
        ];
我通过代码进行了很多调试,得出的结论是,他们正在使用ICUDATA进行语言环境支持。
我被这一切困扰,似乎是PriceFormat问题。
请确保仅对于某些语言环境选项(例如Persion(伊朗))会出现此问题。

