Skip to content

[PAP] Product filter with "category_id: {in: [...]}" does not work as expected #30349

Closed
@magento-engcom-team

Description

@magento-engcom-team

Steps to reproduce:

  • Create 2 categories with 1 product each
  • run query to fetch products in those categories
{
  products(filter: {category_id: {in: <"<cat1>", "<cat2>">}}) {
    items {
      sku
      name
    }
    total_count
  }
}

Expected:
total_count should be 2, and items should contain 2 products

Actual:
total_count is 2, but items only contains 1 products

Some investigation:
Changes to \Magento\CatalogGraphQl\Model\Resolver\Products\SearchCriteria\CollectionProcessor\FilterProcessor\CategoryFilter::apply() cause the product collection to be filtered by only the last category id in the array used for "in".
see $collection->addCategoryFilter($category); on line 64

Tests failed to catch this because they check total_count but not actual count of items
need to fix test: \Magento\GraphQl\Catalog\ProductSearchTest::testFilteringForProductsFromMultipleCategories()

Metadata

Metadata

Labels

Component: CatalogGraphQlIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPAPPartners acceleration programPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReported on 2.4.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S1Affects critical data or functionality and forces users to employ a workaround.

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions