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

Method chaining broken by refactor in Module_Catalog Product Collection #24964

Closed
abdulmueid opened this issue Oct 10, 2019 · 13 comments
Closed
Assignees
Labels
Component: Catalog Fixed in 2.3.x The issue has been fixed in 2.3 release line good first issue Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed 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 Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@abdulmueid
Copy link

The commit a77fd52 refactors the method addAttributeToFilter in file app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php by adding two new methods addIsSaleableAttributeToFilter and addTierPriceAttributeToFilter.

However, there are missing return statements in the if statement which break method chaining. https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php#L1591-L1597

Preconditions (*)

  1. Magento Version 2.3.3

Steps to reproduce (*)

  1. Create an instance of \Magento\Catalog\Model\ResourceModel\Product\Collection
  2. Call the method addAttributeToFilter with attribute is_saleable
  3. Chain the method addAttributeToFilter with any other attribute to chain the function

Expected result (*)

  1. Method chaining works as expected

Actual result (*)

  1. addAttributeToFilter returns null when adding is_saleable to filter, therefore breaking method chaining
@m2-assistant
Copy link

m2-assistant bot commented Oct 10, 2019

Hi @abdulmueid. 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 give me 2.3-develop instance - upcoming 2.3.x release

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

@abdulmueid do you confirm that you were 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 Oct 10, 2019
@sdzhepa sdzhepa added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Oct 10, 2019
@electroidru
Copy link

I think that's critical. After update to 2.3.3 exception with porto theme PHP Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Catalog\Model\ResourceModel\Product\Collection::addIsSaleableAttributeToFilter()

@abdulmueid
Copy link
Author

@electroidru that error is a related but separate problem. The new method signatures type check condition parameter for nullable array whereas the calling method addAttributeToFilter does not type check the condition at all.

This breaks a number of popular themes (Porto, Market) and modules which filter products. We can open another issue for this behavior. I'm still debugging and checking for all the misbehaviours.

@mahesh-rajawat mahesh-rajawat self-assigned this Oct 11, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 11, 2019

Hi @maheshWebkul721. 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!


@mahesh-rajawat
Copy link
Member

@shikhamis11 Please look in to this, and confirm this issue. This issue is reproducible.

@shikhamis11 shikhamis11 self-assigned this Oct 11, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 11, 2019

Hi @shikhamis11. 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. Add label Issue: Confirmed once verification is complete.

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

@shikhamis11
Copy link
Member

Hello @abdulmueid
thank you for reporting this issue

The commit a77fd52 refactors the method addAttributeToFilter in file app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php by adding two new methods addIsSaleableAttributeToFilter and addTierPriceAttributeToFilter.
However, there are missing return statements in the if statement which break method chaining.

yes you are right Please make Pull request with it's solution
you can check guide for contribution
https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html

@shikhamis11 shikhamis11 added good first issue 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 Oct 11, 2019
@ghost ghost removed the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Oct 11, 2019
@magento-engcom-team
Copy link
Contributor

@shikhamis11 Thank you for verifying the issue.

Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:

  • Add "Component: " label(s) to this ticket based on verification result. If uncertain, you may follow the best guess

Once all required information is added, please add label "Issue: Confirmed" again.
Thanks!

@ghost ghost unassigned shikhamis11 Oct 11, 2019
@magento-engcom-team magento-engcom-team removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Oct 11, 2019
@shikhamis11 shikhamis11 added Component: Catalog Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it labels Oct 11, 2019
@ghost ghost removed the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Oct 11, 2019
@magento-engcom-team
Copy link
Contributor

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

Issue Available: @shikhamis11, 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 the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Oct 11, 2019
@shikhamis11 shikhamis11 self-assigned this Oct 11, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 11, 2019

Hi @shikhamis11. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

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

  • 2. 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!

  • 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


@mahesh-rajawat
Copy link
Member

@shikhamis11 Thanks for verifying this issue. @magento i am working on it.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Oct 15, 2019
@magento-engcom-team
Copy link
Contributor

Hi @abdulmueid, @shikhamis11, @maheshWebkul721.

Thank you for your report and collaboration!

The issue was fixed by Magento team.

The fix will be available with the upcoming 2.3.4 release.

@hzubyrss
Copy link

hzubyrss commented Jan 20, 2020

You should contact your theme developer and ask them for the updated patch for Magento 2.3.3 if you using Porto theme follow this link: https://magento2expert.com/error-after-indexing-after-upgrade-to-magento-2-3-3-porto-theme/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Fixed in 2.3.x The issue has been fixed in 2.3 release line good first issue Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed 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 Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

7 participants