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 Products List widget - prices are loaded from wrong source #21581

Open
snowcore opened this issue Mar 5, 2019 · 3 comments
Open

Catalog Products List widget - prices are loaded from wrong source #21581

snowcore opened this issue Mar 5, 2019 · 3 comments
Labels
Area: Catalog Component: Catalog Component: CatalogWidget Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.

Comments

@snowcore
Copy link

snowcore commented Mar 5, 2019

Preconditions (*)

  1. Magento 2.2.7 (2.3) - both Open Source and Commerce editions
  2. Flat catalog enabled

Steps to reproduce (*)

Create widget "Catalog Products List", add some random products to it.

Expected result (*)

Product prices are loaded from price index table catalog_product_index_price

Actual result (*)

In the resulting product collection prices are taken from flat table instead of price index table (or from EAV if flat catalog is disabled).

Technical details

This affects Magento\CatalogWidget\Block\Product\ProductsList block and some others.
The problem is in \Magento\Catalog\Block\Product\AbstractProduct::_addProductAttributesAndPrices() method.
addAttributeToSelect() method is called later than addFinalPrice() and it overrides price column

protected function _addProductAttributesAndPrices(
        \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
    ) {
        return $collection
            ->addMinimalPrice()
            ->addFinalPrice()
            ->addTaxPercents()
            ->addAttributeToSelect($this->_catalogConfig->getProductAttributes())
            ->addUrlRewrite();
    }

\Magento\Catalog\Model\ResourceModel\Product\Collection::_productLimitationPrice() already handles price override, but it is not called in the right order.

// Preventing overriding price loaded from EAV because we want to use the one from index
$this->removeAttributeToSelect('price');

Other notes

  1. There is no need to call both addMinimalPrice() and addFinalPrice(), as they call the same method addPriceData()
  2. Potentially, the same problem is in \Magento\AdvancedCheckout\Helper\Data::getFailedItems()
  3. Ideally, there should be no dependency on methods call order (or we can combine addAttributeToSelect() with addFinalPrice() in some new method).

P.S.: will submit PR a bit later.

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Mar 5, 2019

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

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

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

@snowcore do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Mar 5, 2019
@snowcore snowcore self-assigned this Mar 5, 2019
snowcore added a commit to snowcore/magento2 that referenced this issue May 7, 2019
@ghost ghost unassigned snowcore May 22, 2019
@engcom-Delta engcom-Delta self-assigned this Jul 26, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jul 26, 2019

Hi @engcom-Delta. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Delta engcom-Delta added Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jul 26, 2019
@ghost ghost unassigned engcom-Delta Jul 26, 2019
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jul 26, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Delta
Thank you for verifying the issue. Based on the provided information internal tickets MC-18667 were created

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

@magento-engcom-team magento-engcom-team added this to Ready for Dev in Community Backlog Mar 24, 2020
@sidolov sidolov added this to Ready for Grooming in Low Priority Backlog Sep 3, 2020
@sidolov sidolov added this to Ready for Development in Low Priority Backlog Sep 24, 2020
@ghost ghost removed this from Ready for Dev in Community Backlog Oct 20, 2020
@ghost ghost removed this from Ready for Development in Low Priority Backlog Oct 20, 2020
@ghost ghost removed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Oct 20, 2020
@magento-engcom-team magento-engcom-team added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Nov 30, 2020
@m2-community-project m2-community-project bot added this to Ready for Development in High Priority Backlog Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Catalog Component: Catalog Component: CatalogWidget Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
High Priority Backlog
  
Ready for Development
Development

No branches or pull requests

5 participants