-
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
Tier Price Storage Interface Delete Bug doesn't delete all Tier Prices #37949
Comments
Hi @MarcProvi. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @engcom-Bravo. Thank you for working on this issue.
|
@magento give me 2.4-develop instance |
Hi @okolesnyk. Thank you for your request. I'm working on Magento instance for you. |
Hi @okolesnyk, here is your Magento Instance: https://a1f49fe434ce563ccd915703c1656256.instances-prod.magento-community.engineering |
Hi @engcom-November. Thank you for working on this issue.
|
Hello @MarcProvi, Thank you for the report and collaboration! Can you please elaborate the 4th step in Preconditions, and what exactly you mean by the affected website. Thank you. |
With the 4th Step of preconditions I mean that two tier prices exist with the same information but with different websites, as the image of steps to reproduce shows. So for example in the tier prices will be:
Tier Price 2:
The only data difference between the two tier prices is the website they are assigned to, the other data is exactly the same. The problem is that the delete tier price storage function checks all the fields despite the website ID before deleting the tier price, so if two tier prices match all the other fields but with different website, the tier price storage function will retrieve only the first result of the tier prices and not both IDs when trying to delete both tier prices. An example of use would be that you want to delete all tier prices of a specified product. When retrieving all tier prices of the product and using the tier price storage interface to delete all tier prices, all tier prices should be deleted, but in reality only the first tier price is deleted and the other not. |
Hello @MarcProvi, Thank you for the quick response! We followed your inputs and the issue seems to be reproducible on 2.4-develop. Here we have created same tier prices for two different website. After using the price storage interface to delete the tier prices we got below result. Please find the custom module used to reproduce the issue. Thank you. |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-9738 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-November. Thank you for verifying the issue. |
❌ You don't have permission to export this issue. |
Preconditions and environment
Steps to reproduce
Tier Prices should look like this:
Expected result
All Tier prices are deleted.
Actual result
Only the first tier price that match the conditions is deleted, because it doesn't take into account the website of the tier price.
Additional information
The problem is found in \Magento\Catalog\Model\Product\Price\TierPriceStorage.php where the function delete doesn't retrieve correctly the affected IDs to delete. The function retrievePriceId (Line 267) is the culprit of the bug with the current code:
` /**
* Look through provided price in list of existing prices and retrieve it's Id.
*
* @param array $price
* @param array $existingPrices
* @return int|null
*/
private function retrievePriceId(array $price, array $existingPrices): ?int
{
$linkField = $this->tierPricePersistence->getEntityLinkField();
But the correct way of retrieving the price Id should be:
` /**
* Look through provided price in list of existing prices and retrieve it's Id.
*
* @param array $price
* @param array $existingPrices
* @return int|null
*/
private function retrievePriceId(array $price, array $existingPrices): ?int
{
$linkField = $this->tierPricePersistence->getEntityLinkField();
With this fix the retrieve price ID takes into account the website the tier price is created and makes a unique identifier of the tier price with all the previous information.
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: