Question

I try to make a simple request using graphql and to get a response from my magento. I have a parent category named Products(id:"3"). In this one, there are 3 subcategories A(id:"5"),B(id:"6"),C(id:"7") for example. Each subcategory has a single product assigned. I use the products query and filter products by category_id like:

{
 products(filter: {category_id: {eq:"5"}}){
  items{
    name
  }
 }
}

This query returns an empty items array, and does the same for all subcategory ids (B with id:"6" and C with id:"7"). Based on the example i provided above it should return the product of category A, am i missing something? Although using the same query with eq:"3" returns all the products. Is there something special with subcategories and this query returns only parent category?

Was it helpful?

Solution

Your query is fine. I have copied it locally and I have results.

So, I would look at your Magento system trying to remove the graphql from the equation.

For instance, go to your Magento backend, fetch the url-key for the category 5. Then hit in your browser the category url.

I suspect you won't have products either. Then, to resolve this, you may look at reindexing your system

php bin/magento inde:reind may help if that was the case.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top