-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Fix #7371 #8593
Fix #7371 #8593
Conversation
'catalog_rule_price' is added to products only before load of the Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection and it is used only for detecting the minimal price here - Magento\Catalog\Pricing\Price\BasePrice. Due to it the price has never converted to the site currency.
@rossluk could you please provide clear test cases? what is the issue and how to reproduce it. And how we can test your solution. Thank you |
|
@okorshenko, steps are described in #7371, you know :) @rossluk, fix looks incorrect to me. Check the logic in e3cecaf#diff-ca5d201faa2fc6d81caa299b64589a3bR91 So, if the issue is relevant for |
$this->value = $this->priceCurrency->convertAndRound($this->value); | ||
} | ||
} | ||
if ($this->value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orlangur Sorry, I can't understand what I should see in diff. Problem is 'catalog_rule_price' which is added to join in Magento\CatalogRuleConfigurable\Plugin\ConfigurableProduct\Model\ResourceModel\AddCatalogRulePrice. I didn't see any mention about current currency (if value from db already in current currency we should see something about it) or conversion of the value in this file, and I didn't see any places where 'catalog_rule_price' or 'rule_price' converts to current currency after. Maybe I miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($this->product->hasData(self::PRICE_CODE)) {
$this->value = floatval($this->product->getData(self::PRICE_CODE)) ?: false;
Where this value is stored? I believe currency conversion is missed there.
So, it's better to store totally prepared value than convert it after.
However, if the value stored in product is not store-aware by design, fix looks ok to me. To avoid regression it's better to create proper integration test, with catalog rule and multiple currencies, as change of started to fail unit test does not enforce anything (i.e. somebody doing next changes will just do the same - change hardcoded expectations - as test case is not sticked to any concrete scenario).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($this->product->hasData(self::PRICE_CODE)) {
$this->value = floatval($this->product->getData(self::PRICE_CODE)) ?: false;
This value is stored in the 'catalogrule_product_price' table. As I know all prices in Magento is converted after (from base currency to selected on site) and it's too much work to store prepared value because there is should be added a new dimension by currency per store. Value which is stored in product is website-aware, but currency is another dimension (you can have many currencies for one store view).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see... Thanks, that's exactly what I was asking.
Then
fix looks ok to me
Integration test would be really valuable to not ever break this place again, but it's up to you, of course, whether invest time in it or not.
Minor fixes in docs
'catalog_rule_price' is added to products only before load of the Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection and it is used only for detecting the minimal price here - Magento\Catalog\Pricing\Price\BasePrice. Due to it the price has never converted to the site currency.