I’m trying to get products by tags. The query is:
let query = {
query: "tag:'backpack_large' OR tag:'backpack' OR tag:'glass'"
}
client.products.fetchQuery(query).then((products) => {
console.log(products)
})
Everything is ok, the product data is coming in. But the product variants don’t have the necessary quantityAvailable field.
I read that quantityAvailable is disabled by default in the query to optimize query time.
I also read about Expanding the SDK. There’s an example of adding a field, but to query all the unfiltered products.
// Build a custom products query using the unoptimized version of the SDK
const productsQuery = client.graphQLClient.query((root) => {
root.addConnection('products', {args: {first: 10}}, (product) => {
product.add('title');
product.add('tags');// Add fields to be returned
});
});
// Call the send method with the custom products query
client.graphQLClient.send(productsQuery).then(({model, data}) => {
// Do something with the products
console.log(model);
});
I don’t quite understand how to do this in my case, to query not all products, but by key tags.
Thanks in advance)