I’m developing a headless solution using Magento as a product catalogue and i’m facing a small challenge (i’m pretty sure that is not challenging at all, for people that have experience with Magento framework, that is not my case). I’m using the 2.3.3 version of Magento btw.
I have to add a custom filter to the existent GraphQL products query (store_id, that represents the website id in Magento) and i’m a bit lost on how to implement that.
Basically i will have multiple stores created (e.g Portugal, United Kingdom) in Magento and i want to retrieve for example only the products that belongs to the Portugal Store (that is given by this new store_id filter). Can anyone help me?
I have seen this solution somewhere: http://www.mujahidh.com/how-to-filter-product-collection-with-default-graphql-products-query/
But it doesn’t work at all for me, the products query is returning an Internal error and after some debugging i have found this error: Warning: Invalid argument supplied for foreach() in magento2\lib\internal\Magento\Framework\GraphQl\Query\Resolver\Argument\AstConverter.php
Any ideas on how to overcome that? What am i missing?
Thanks in advance.