A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Using a product identifier like the product id or handle, I am trying to use the GraphQL API to get a product’s price for all market. I am able to get information like the product’s name in various markets using the product->translations(). Is there any similar strategy for getting a product’s price from each market?
I was able to get the pricesList for a market with this GraphQL API query:
{ markets(first: 10) { edges { node { priceList { prices(first:10) { edges { node { price { amount currencyCode } variant { id product { handle } } } } } } } } } }
From the priceList I can get the prices for all products in a market. However, in order to get the market price for a specific product, I would need to query the entire market’s priceList which seems very inefficient. Is there a simpler way of doing this?
Solved! Go to the solution
This is an accepted solution.
I was able to figure out a way to accomplish my goal. I wanted to get market specific product data for each market that a product was in.
I first got the markets data with a GraphQL API call like this:
{
markets(first: 10, after: $cursor) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
name
webPresence {
rootUrls {
url
locale
}
}
}
}
}
}
Since I now have the URL for each market, I was able to get the product data by using this Product Ajax API.
So your final API call would be something like this: `{market_webPresence_url}/products/{handle}.js`.
This is an accepted solution.
I was able to figure out a way to accomplish my goal. I wanted to get market specific product data for each market that a product was in.
I first got the markets data with a GraphQL API call like this:
{
markets(first: 10, after: $cursor) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
name
webPresence {
rootUrls {
url
locale
}
}
}
}
}
}
Since I now have the URL for each market, I was able to get the product data by using this Product Ajax API.
So your final API call would be something like this: `{market_webPresence_url}/products/{handle}.js`.
Hi
I have implemented each markets pricelist using grapghql admin api in php.