Hello!
I have one simple product with url_key: test-product-1
https://i.stack.imgur.com/wRM7N.png
Also I have one group product. That group product include a simple product with url_key: test-product-1
https://i.stack.imgur.com/iBHky.png
I have this Graphql query
{ products(filter: { url_key: { eq: "test-product-1" } }) { items { name sku url_key stock_status price_range { minimum_price { regular_price { value currency } } } } total_count page_info { page_size } } }
I expect to get information about a product with url_key : test-product-1
But I get next result
{
"data": {
"products": {
"total_count": 2,
"items": [
{
"name": "Test group product",
"sku": "tgp1",
"url_key": "test-group-product",
"price_range": {
"minimum_price": {
"regular_price": {
"value": 99,
"currency": "USD"
}
}
}
},
{
"name": "Test simple product 1",
"sku": "tsp1",
"url_key": "test-simple-product-1",
"price_range": {
"minimum_price": {
"regular_price": {
"value": 99,
"currency": "USD"
}
}
}
}
],
"page_info": {
"page_size": 4,
"current_page": 1
}
}
How can I get only one product in my Graphql result ? I need to get information only for product Test simple product 1
Could someone explain why I get two products?
Thank you!
MyBalanceNow wrote:Hello!
I have one simple product with url_key: test-product-1
https://i.stack.imgur.com/wRM7N.png
Also I have one group product. That group product include a simple product with url_key: test-product-1
https://i.stack.imgur.com/iBHky.png
I have this Graphql query
{ products(filter: { url_key: { eq: "test-product-1" } }) { items { name sku url_key stock_status price_range { minimum_price { regular_price { value currency } } } } total_count page_info { page_size } } }I expect to get information about a product with url_key : test-product-1
But I get next result
{ "data": { "products": { "total_count": 2, "items": [ { "name": "Test group product", "sku": "tgp1", "url_key": "test-group-product", "price_range": { "minimum_price": { "regular_price": { "value": 99, "currency": "USD" } } } }, { "name": "Test simple product 1", "sku": "tsp1", "url_key": "test-simple-product-1", "price_range": { "minimum_price": { "regular_price": { "value": 99, "currency": "USD" } } } } ], "page_info": { "page_size": 4, "current_page": 1 } }
How can I get only one product in my Graphql result ? I need to get information only for product Test simple product 1
Could someone explain why I get two products?
Thank you!
is a method of collections.
addAttributeToFilter You should execute in on a category collection, not on a category instance.