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.52k stars 9.31k forks source link

Unable to remove all Tier Prices for Product using APIs #29319

Open lbajsarowicz opened 4 years ago

lbajsarowicz commented 4 years ago

Preconditions (*)

  1. Recommended way of interacting with Magento is through the @api Interfaces (eg. ProductRepositoryInterface, ScopedProductTierPriceManagementInterface.

Steps to reproduce (*)

  1. Install Magento Sample Data
  2. Add different (from 1 to 5 per product) Tier Prices
  3. Run code provided below
    /** @var ScopedProductTierPriceManagementInterface */
    private $tierPriceManagement;

...

        $searchCriteria = $this->searchCriteriaBuilder->create();
        $productList = $this->productRepository->getList($searchCriteria);

        $output->writeln(
            __('Starting removal for %count products', ['count' => $productList->getTotalCount()])
        );

        /** @var ProductInterface $product */
        foreach ($productList->getItems() as $product) {
            $this->state->emulateAreaCode(Area::AREA_ADMINHTML, function () use ($product) {
                $tierPrices = $product->getTierPrices();

                if (!$tierPrices) {
                    return;
                }

                foreach ($tierPrices as $tierPrice) {
                    $this->tierPriceManagement->remove($product->getSku(), $tierPrice);
                }
            });

Expected result (*)

  1. All the Tier Price entries should be removed from catalog_product_tier_price

Actual result (*)

  1. Exception is thrown: image
  2. My code returns 1 element (tier price): image
  3. While Magento in his \Magento\Catalog\Model\Product\PriceModifier::removeTierPrice has no items in getData('tier_price') :clap:

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 4 years ago

Hi @lbajsarowicz. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

lbajsarowicz commented 4 years ago

After 8,5 hours of execution for ↑ command, from 30.000 of sample entries in catalog_product_entity_tier_price, only 20.000 were removed.

10.000 (!) is still in the database and... Magento considers these as not a Tier Prices.

lbajsarowicz commented 4 years ago

Single tier_price entry: image

During delete causes 5 database calls: image

Which isn't the sexiest thing to see in the logs : )

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Thank you for your contributions.

lbajsarowicz commented 3 years ago

The issue is still there.

m2-assistant[bot] commented 3 years 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:

magento-engcom-team commented 3 years ago

:white_check_mark: Confirmed by @engcom-Bravo Thank you for verifying the issue. Based on the provided information internal tickets MC-40311 were created

Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

ProkopovVitaliy commented 3 years ago

@magento I am working on this