Skip to content

Commit dd159ef

Browse files
30349: Product filter with category_id does not work as expected - fixed query returns missing items
1 parent 1c1e70e commit dd159ef

File tree

1 file changed

+6
-0
lines changed
  • app/code/Magento/CatalogGraphQl/Model/Resolver/Products/SearchCriteria/CollectionProcessor/FilterProcessor

1 file changed

+6
-0
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/SearchCriteria/CollectionProcessor/FilterProcessor/CategoryFilter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public function __construct(
5151
*/
5252
public function apply(Filter $filter, AbstractDb $collection)
5353
{
54+
$conditionType = $filter->getConditionType();
55+
if ($conditionType !== 'eq') {
56+
return true;
57+
}
58+
5459
$categoryIds = $filter->getValue();
5560
if (!is_array($categoryIds)) {
5661
$categoryIds = [$categoryIds];
@@ -61,6 +66,7 @@ public function apply(Filter $filter, AbstractDb $collection)
6166
$category = $this->categoryFactory->create();
6267
$this->categoryResourceModel->load($category, $categoryId);
6368
$categoryProducts[$categoryId] = $category->getProductCollection()->getAllIds();
69+
$collection->addCategoryFilter($category);
6470
}
6571

6672
$categoryProductIds = array_unique(array_merge(...$categoryProducts));

0 commit comments

Comments
 (0)