magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Price Bug after upgrade 2.1.0 to 2.1.4 #8667

Closed aasim110 closed 7 years ago

aasim110 commented 7 years ago

Upsell and Recently Viewed products showing same price as per product price. Please check attached screenshot of Upsell products and Recently Viewed products

Upsell - http://awesomescreenshot.com/0fc691y87d Recently viewed - http://awesomescreenshot.com/0f4691yab3

jzahedieh commented 7 years ago

@aasim110 we had this issue too, it's because a template change in our theme:

It was the way the requireJS was being initialized which was causing the issue.

You can see the change Magento made 5 months ago here: https://github.com/magento/magento2/blame/2.1/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml#L42-L47

We had to change the template to reflect that change and it worked as expected.

I'm still having issues with admin pricing showing as 0 though.

thdoan commented 7 years ago

We are also seeing this bug in v2.1.5. The strange thing is, the attribute contains the correct price, e.g.:

<div class="price-box price-final_price bottom-align" data-role="priceBox" data-product-id="13513">
  <span class="price-container price-final_price tax weee">
    <span id="product-price-13513-widget-viewed-grid" data-price-amount="109.99" data-price-type="finalPrice" class="price-wrapper ">
      <span class="price">$199.99</span>
    </span>
  </span>
</div>

The correct price is $109.99 just like in the data-price-amount attribute, but the printed price $199.99 is incorrect as it's taking the price of the main product.

thdoan commented 7 years ago

While making the fix to the template, I noticed you can also remove <?php $_helper = $this->helper('Magento\Catalog\Helper\Output'); ?> since $_helper is not used at all.

aasim110 commented 7 years ago

Issue fixed after following chnage

/vendor/magento/module-configurable-product/Pricing/Price/ConfigurablePriceResolver.php line : 58 Replace following function with original

public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)
    {
        $price = null;

        foreach ($this->lowestPriceOptionsProvider->getProducts($product) as $subProduct) 
        {
            $productPrice = $this->priceResolver->resolvePrice($subProduct);
            $price = $price ? min($price, $productPrice) : $productPrice;
        }

        /* fix >>> */
        $price = $price ?: $product->getData('price');
        /* <<< fix */

        return $price === null ? null : (float)$price;
    }