15

I am facing a very strange issue after the installation of Magento 2.0.4. I have create a product with the price $12 and change the locale from Magento configuration in backend.

Below is the screenshot for the listing page.

enter image description here

Also find the below screenshot for the detail page.

enter image description here

You might have noticed the difference between two screenshot. Yes, Product detail page shows $0.00 price while listing page has retain with the price what i have added.

Product details page automatically updates correct price to $0,00 After one or two seconds ( Javascript Updates).

Find the below code for it

$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({data: price}));

I have debug further in the code and find another javascript code that passes parameter to Magento 2 pricebox widget.

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

Now i have checked the getJsonConfig() method,

  $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
        ];

I did lot of debugging through the code and come to the conclusion that they are using ICUDATA for locale support.

I am stuck with this all thing, It seems it is PriceFormat issue.

Please make sure this issue arise only for certain Locale options like Persion (Iran).

4
  • Apply reindeix, clean cache, deploy static conent. Commented Apr 12, 2016 at 9:17
  • Thanks @SHPatel, Its not a reindex or cache issue. i did everything possible. Commented Apr 12, 2016 at 9:26
  • This is a bug and has been reported previously to magento team. Check this for more details - github.com/magento/magento2/issues/4077 Commented Apr 12, 2016 at 9:37
  • Thanks @ReenaParekh , That bug reported by me. But i want solution to this issue because magento people will take time to update it in their next release or so. Commented Apr 12, 2016 at 10:39

3 Answers 3

1

this issue has been resolved , kindly update your Magento2 to latest Stable version

if you have installed from GIT & Composer follow these steps :

  • Than you must stach your changes
  • GIT PULL Latest Stable Branch i.e. 2.1
  • Composer Update
  • Upgrade Magento ( bin/magento setup:upgrade)

else if you have installed using zip folder download than download latest from magento website and override all files using new zip than you need to clear cache and run

bin/magento setup:upgrade
0
0

Upgrade the magento by following commands.

bin/magento setup:upgrade

bin/magento setup:db-schema:upgrade

php -d memory_limit=-1 bin/magento setup:di:compile

php -d memory_limit=-1 bin/magento setup:static-content:deploy

0

Please try to update below code :

Path - lib/internal/Magento/Framework/Locale/Format.php

class Format implements \Magento\Framework\Locale\FormatInterface
{
    const DEFAULT_NUMBER_SET = 'latn';
    /**
     * @var \Magento\Framework\App\ScopeResolverInterface
     */
@@ -104,12 +105,18 @@ public function getPriceFormat($localeCode = null, $currencyCode = null)
            $currency = $this->_scopeResolver->getScope()->getCurrentCurrency();
        }
        $localeData = (new DataBundle())->get($localeCode);
        /* $format = $localeData['NumberElements']['latn']['patterns']['currencyFormat']
            ?: explode(';', $localeData['NumberPatterns'][1])[0];
        $decimalSymbol = $localeData['NumberElements']['latn']['symbols']['decimal']
            ?: $localeData['NumberElements'][0];
        $groupSymbol = $localeData['NumberElements']['latn']['symbols']['group']
            ?: $localeData['NumberElements'][1]; */
 //start updated code
        $defaultSet = $localeData['NumberElements']['default'] ?: self::DEFAULT_NUMBER_SET;
        $format = $localeData['NumberElements'][$defaultSet]['patterns']['currencyFormat']
            ?: ($localeData['NumberElements'][self::DEFAULT_NUMBER_SET]['patterns']['currencyFormat']
                ?: explode(';', $localeData['NumberPatterns'][1])[0]);
        $decimalSymbol = $localeData['NumberElements'][$defaultSet]['symbols']['decimal']
            ?: ($localeData['NumberElements'][self::DEFAULT_NUMBER_SET]['symbols']['decimal']
                ?: $localeData['NumberElements'][0]);
        $groupSymbol = $localeData['NumberElements'][$defaultSet]['symbols']['group']
            ?: ($localeData['NumberElements'][self::DEFAULT_NUMBER_SET]['symbols']['group']
                ?: $localeData['NumberElements'][1]);

  // end updated code

        $pos = strpos($format, ';');
        if ($pos !== false) {

hope its work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.