Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catalog price rule applied configurable products not show oldPrice in product list #7624

Closed
rbostan opened this issue Nov 30, 2016 · 20 comments

Comments

Projects
None yet
@rbostan
Copy link

commented Nov 30, 2016

Preconditions

  1. Magento 2.1.2
  2. PHP 7.0.11

Steps to reproduce

  1. Create a price rule and apply it (for ex. 15% discount)

Expected result

  1. Listing working fine with simple products

screenshot at nov 30 15-26-47

2. Same as simples, show both final and old price for configurable products

Actual result

  1. Old price not shown for configurable products

screenshot at nov 30 15-29-44

@olysenko

This comment has been minimized.

Copy link
Contributor

commented Dec 2, 2016

Hi, I cannot reproduce this issue. Please add more details to your description of the steps you followed when identifying this issue.

@rbostan

This comment has been minimized.

Copy link
Author

commented Dec 9, 2016

@olysenko It just classical usage of catalog price rules.

  • Create a rule based on attribute set
  • Apply it.

rule_attribute_set

Actually rule is working on all type of products.
For simples, discounted prices shown on all areas (listing, search, view etc..)
But configurables, just shown on product view page.

It may be about with price renderer in $block->getProductPrice(). Because in listing, for configurables, magento gets lowest child's price.

I'm investigating this.

@rbostan

This comment has been minimized.

Copy link
Author

commented Dec 9, 2016

In addition it may be related with #6080
Our configurables prices are 0. Catalog price calculating by totals of selected attributes (child prices).

@rbostan

This comment has been minimized.

Copy link
Author

commented Dec 11, 2016

Additional Info:

After some investigation, i think find a clue
Clean install 2.1.2 with sample-data via composer.

  • Create a catalog rule which looks like our original one and apply it. (Attribute set based)

scr1

- It is working well with same price children 👍

scr2

scr3

  • But if change price of any child

scr4

  • It shows lowest price as expected but regular price gone same as our situation

scr5

  • But in product view discount shown. So catalog rule applied all children, not only parent (as expected).

scr6

I hope it will help to solve this.

@olysenko olysenko self-assigned this Dec 12, 2016

@olysenko

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2016

Hi, after your las comment update I was able to reproduce issue on clear Magento installation with sample data. Your price index is invalid after price was changed. In case your have setting for indexers UPDATE BY SCHEDULE in menu System->Tools->Index Management. You have to setup cron with indexers reindex job. Or use UPDATE ON SAVE mode for indexers. In this case it will reindex price on product save. Please tell me if my comment was helpful for you.

@olysenko olysenko removed their assignment Dec 13, 2016

@rbostan

This comment has been minimized.

Copy link
Author

commented Dec 13, 2016

Hi @olysenko,
All indexes are update by schedule and crond working fine. Also check database while running reindex. I have verified the calculation is correct and products got discounted price.

This issue just about showing oldPrice in frontend. Not about rule applying or other.
Product special price did not set for minimal price (lowest price of child products) so final_price.html don't know how about showing price ($block->hasSpecialPrice() in final_price.phtml returns false).

I did some trick to override it (Magento_Catalog/templates/product/price/final_price.phtml) :
line around 20

if($block->getSaleableItem()->getTypeId()==\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE)
{
/** ex: \Magento\Catalog\Pricing\Price\ConfiguredPrice /
/
* @var \Magento\Framework\Pricing\Price\PriceInterface $priceModel */
$priceModel = $block->getPriceType('configured_price');
}

and line around 32
if($finalPriceModel->getAmount()->getValue()<$priceModel->getAmount()->getValue())
$block->getSaleableItem()->setSpecialPrice($finalPriceModel->getAmount()->getValue());
if ($block->hasSpecialPrice()): ?>

@olysenko

This comment has been minimized.

Copy link
Contributor

commented Dec 19, 2016

Hi @rbostan, so we need to synchronize our steps. My steps with no bug you can find below:

  1. Clean install 2.1.2 with sample-data
  2. Set all Indexes mode to UPDATE BY SCHEDULE in menu System->Tools->Index Management
  3. Add task to crontab to execute every 1 minute
          • /usr/bin/php {magento2ce}/bin/magento indexer:reindex
  1. Create a catalog rule which looks like our original one and apply it. (Attribute set Top). Discount 20% from original price
  2. Go to front-end. Open category Women->Tops->Bras & Tanks
    All configurable products have two prices actual minimal price and regular price.
    For example, product "Breathe-Easy Tank" two prices available: $27.20 and Regular Price $34.00
  3. Change for any simple product "Breathe-Easy Tank" price to 20$
  4. Refresh category Women->Tops->Bras & Tanks
    One price is shown $20.00 for product "Breathe-Easy Tank"
  5. Wait 1 minute until indexes will be updated by cron
  6. Refresh category Women->Tops->Bras & Tanks
    Two prices are shown $16.00 and Regular Price $20.00 for product "Breathe-Easy Tank"
    What is your result after these steps? Do you have another sequence of steps?
@veloraven

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2017

According to contributor guide, tickets without response for two weeks should be closed.
If this issue still reproducible please feel free to create the new one: format new issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result and specify Magento version.

@veloraven veloraven closed this Jan 3, 2017

@onepack

This comment has been minimized.

Copy link

commented Apr 19, 2017

I have the exact same issue on a project that has migrated data from a magento 1 store.
The products are assigned later to the configurable product not on the go while creating the configurable product.
When I apply a special price on a simple product or apply a catalog price rule the old price just never shows just the new discounted price and so it is not clear for a customer that this is a special/ discounted price.
This happens in the grids and on a product detail page.
Only when I click a color option in the detail page the display of the price box gets updated with the text "regular: xx,xx" under the new "special price".

@onepack

This comment has been minimized.

Copy link

commented Apr 19, 2017

This is on a magento 2.1.6 install on a development environment and a production environment with PHP 7.

@onepack

This comment has been minimized.

Copy link

commented Apr 19, 2017

@veloraven this is weird.
I noticed it in more clear reproducible bug-cases. Some moderators seem eager to close them when the 2-week-deadline is reached.
It is understandable that tickets cannot be open all the time but when there is a clear bug it seems to me that solving this to make magento better has more importance than this guideline.
I'm now having the exact same issue and have to create a whole new case while this case could already be solved or at least updated by me and maybe others.

@joebordo

This comment has been minimized.

Copy link

commented May 28, 2017

@rbostan can you provide the final price file content? I don't know what to replace or override. thanks in advance!

@joebordo

This comment has been minimized.

Copy link

commented May 28, 2017

Hi, Line 22 in the the file: vendor\magento\module-configurable-product\view\base\templates\product\price\final_price.phtml

I replaced This: <?php if (!$block->isProductList() && $block->hasSpecialPrice()): ?>
With this: <?php if ($block->hasSpecialPrice()): ?>

From onepack, if you want the old price to show in product page (when the swatches are not selected)
Remove the css styling of the "old-price" line 32 (remove everything and leave the old-price class and now it will show on the product page.

hope it helps. someone

@gediminaskv

This comment has been minimized.

Copy link

commented Jun 29, 2017

@joebordo overwrite provided by @rbostan doesn't work on 2.1.7.

I overwrote like this:

<?php
/** @var \Magento\Catalog\Pricing\Render\FinalPriceBox $block */

$productId = $block->getSaleableItem()->getId();

if ($block->getSaleableItem()->getTypeId()==\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {

/** ex: \Magento\Catalog\Pricing\Price\ConfiguredPrice /

/* @var \Magento\Framework\Pricing\Price\PriceInterface $priceModel */

$priceModel = $block->getPriceType('configured_price');

} else {

/** ex: \Magento\Catalog\Pricing\Price\RegularPrice */
/** @var \Magento\Framework\Pricing\Price\PriceInterface $priceModel */
$priceModel = $block->getPriceType('regular_price');
}


/** ex: \Magento\Catalog\Pricing\Price\FinalPrice */
/** @var \Magento\Framework\Pricing\Price\PriceInterface $finalPriceModel */
$finalPriceModel = $block->getPriceType('final_price');
$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
$schema = ($block->getZone() == 'item_view') ? true : false;
?>
<?php 
if ($finalPriceModel->getAmount()->getValue() < $priceModel->getAmount()->getValue())
	
$block->getSaleableItem()->setSpecialPrice($finalPriceModel->getAmount()->getValue());

if ($block->hasSpecialPrice()): ?>
..............
..............
.............
@drpit

This comment has been minimized.

Copy link

commented Jul 17, 2017

@gediminaskv It worked form me on 2.1.7
@joebordo I want to copy this file and put it in my custom theme. What path should I use?

@saulfm08

This comment has been minimized.

Copy link

commented Aug 21, 2017

@joebordo Thanks it works for me!

Someone know how can I change "was" for "old price" ?

@studioworx-meniconi

This comment has been minimized.

Copy link

commented Mar 16, 2018

Sorry to reopen and drag this but im having the same issue on a magento 2.2 with migration data. ive tried the method mentioned by @joebordo but doesnt seem to work as no old price is showing.

Any advice would be much appreciated.

@juandosil

This comment has been minimized.

Copy link

commented Jul 19, 2018

I have also tried the method mentioned by @joebordo with Magento 2.2.4 but doesnt seem to work as no old price is showing.

Any advice would be much appreciated.

@brampta

This comment has been minimized.

Copy link

commented Nov 15, 2018

Hi, Line 22 in the the file: vendor\magento\module-configurable-product\view\base\templates\product\price\final_price.phtml

I replaced This: <?php if (!$block->isProductList() && $block->hasSpecialPrice()): ?>
With this: <?php if ($block->hasSpecialPrice()): ?>

From onepack, if you want the old price to show in product page (when the swatches are not selected)
Remove the css styling of the "old-price" line 32 (remove everything and leave the old-price class and now it will show on the product page.

hope it helps. someone

I found that this solution works for me on 2.2.6, now old prices are showing for configurable products in the catalog, hower this causes a new bug, on product pages the old price is initially shown for a second or 2 and then disappears in a flash :(. When selecting an option it goes back to displaying but that was always like that. Seems like there is some Ajax rewriting the price after the fact on the product page.

======edit:
found a fix for the bug created by the joebordo fix: #8670

@deanpeterson

This comment has been minimized.

Copy link

commented Nov 29, 2018

Hi, Line 22 in the the file: vendor\magento\module-configurable-product\view\base\templates\product\price\final_price.phtml
I replaced This: <?php if (!$block->isProductList() && $block->hasSpecialPrice()): ?>
With this: <?php if ($block->hasSpecialPrice()): ?>
From onepack, if you want the old price to show in product page (when the swatches are not selected)
Remove the css styling of the "old-price" line 32 (remove everything and leave the old-price class and now it will show on the product page.
hope it helps. someone

I found that this solution works for me on 2.2.6, now old prices are showing for configurable products in the catalog, hower this causes a new bug, on product pages the old price is initially shown for a second or 2 and then disappears in a flash :(. When selecting an option it goes back to displaying but that was always like that. Seems like there is some Ajax rewriting the price after the fact on the product page.

======edit:
found a fix for the bug created by the joebordo fix: #8670

@brampta What fix did you find for the bug created by the joebordo fix? I'm on 2.2.3 and I get the old price to flash for a second and then it is replaced with the sale price. So the sale price is displayed and the Original Price, also displays the sale price.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.