Cannot use processFilter on product Collection
Preconditions and environment
- 2.4.6-p11
- Magento 2 EE
Steps to reproduce
- Create a product collection using a productCollectionFactory
- Create Multiple Filters Using filterBuilder on different product attributes
- Create a filter group using a filterGroupBuilder and the previously created filters.
- Create a Search Criteria using SearchCriteriaBuilder with the previously created group of filters.
- Use the FilterProcessor Class and the process function to filter this collection using the search Criteria
- It will fail
{
$filters = [];
$data = "black"
$filters[] = $this->filterBuilder
->setField('description')
->setValue($data)
->setConditionType('eq')
->create();
$filters[] = $this->filterBuilder
->setField('color')
->setValue($data)
->setConditionType('eq')
->create();
$filters[] = $this->filterBuilder
->setField('country_of_manufacture')
->setValue($data)
->setConditionType('eq')
->create();
// Create a filter group with OR logic
$filterGroup = $this->filterGroupBuilder
->setFilters($filters)
->create();
// Build search criteria
$searchCriteria = $this->searchCriteriaBuilder
->setFilterGroups([$filterGroup])
->create();
$this->collection = $this->productCollectionFactory->create();
$this->collection->addAttributeToSelect('*');
// Apply the search criteria to the collection
$this->filterProcessor->process($searchCriteria, $this->collection);
$this->collection->load();
return $this->collection->getFirstItem();
}
Expected result
Get the products from the collection with the correct filters.
Actual result
Cannot access offset of type string on string at /var/www/src/vendor/magento/module-eav/Model/Entity/Collection/AbstractCollection.php:373
It seems that in the addAttributeToFilter function from module eav the condition parameter from the function is never used and actually replaced by the attribute array passed in the function.
Additional information
No response
Release note
No response
Triage and priority
- [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Hi @jaydainn. 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.
- For more details, review the Magento Contributor Assistant documentation.
- Add a comment to assign the issue:
@magento I am working on this - To learn more about issue processing workflow, refer to the Code Contributions.
Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :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, join the Community Contributions Triage session to discuss the appropriate ticket.
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:
- [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXXlabel to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.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: Confirmedonce verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @engcom-Hotel. 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:
- [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXXlabel to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.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: Confirmedonce verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @jaydainn,
Thanks for the report and collaboration!
We are able to reproduce this issue in the latest development branch i.e. 2.4-develop. In order to reproduce this issue we have created a custom module, the exact same error we are getting.
Hence confirming the issue.
Thanks
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-15018 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.