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.48k stars 9.29k forks source link

Tier Price Storage Interface Delete Bug doesn't delete all Tier Prices #37949

Open MarcProvi opened 1 year ago

MarcProvi commented 1 year ago

Preconditions and environment

Steps to reproduce

  1. Go to the admin edit page and edit a product information.
  2. Set product tier prices with identical information but different affected websites.
  3. Delete ALL product tier prices with TierPriceStorageInterface, to do this get all tier prices with the TierPriceStorageInterface and use the retrieved prices to delete them.

Tier Prices should look like this:

image

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: ` /**

But the correct way of retrieving the price Id should be: ` /**

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

m2-assistant[bot] commented 1 year ago

Hi @MarcProvi. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

okolesnyk commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @okolesnyk. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @okolesnyk, here is your Magento Instance: https://a1f49fe434ce563ccd915703c1656256.instances-prod.magento-community.engineering Admin access: https://a1f49fe434ce563ccd915703c1656256.instances-prod.magento-community.engineering/admin_99e9 Login: 51fdcd6c Password: 58ad18c6a855

m2-assistant[bot] commented 11 months ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 11 months ago

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. This will help us to reproduce the issue more effectively. It would be great if you can provide sample code, or screencast for the reference.

Thank you.

MarcProvi commented 11 months ago

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

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.

engcom-November commented 11 months ago

Hello @MarcProvi,

Thank you for the quick response!

We followed your inputs and the issue seems to be reproducible on 2.4-develop. We created a custom module to delete the tier price after opening the specific route. Please take a look at the screenshots:

Here we have created same tier prices for two different website. image

After using the price storage interface to delete the tier prices we got below result. image We can see here that only one tier price has been deleted, hence confirming the issue.

Please find the custom module used to reproduce the issue. TierVendor.zip

Thank you.

github-jira-sync-bot commented 11 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-9738 is successfully created for this GitHub issue.

m2-assistant[bot] commented 11 months ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

github-jira-sync-bot commented 11 months ago

:x: You don't have permission to export this issue.