Skip to content

Method chaining broken by refactor in Module_Catalog Product Collection #24964

@abdulmueid

Description

@abdulmueid

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

Metadata

Metadata

Labels

Component: CatalogFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasegood first issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions