Hello everyone,
I have an automation programmed to add over 10,000 products to Shopify on a daily basis.
I need to restrict the market for each newly added product to only one region, for example, Canada only. Please see the attached screenshot below for clarity.
However, I am unable to find the mutation needed to accomplish this. I can update the Sales Channels of a product using the Product ID, but I cannot do the same for the Markets. Please note that I am talking about updating the Markets (to, let’s say, only Canada) for a specific Product ID, and not about adding, removing, or editing the Markets field.
This must be done through the API because it is impractical to update all the new products manually on a daily basis. Can anyone here help me out with this? Thank you.
Hey @hassanashas ,
This can be done via the api using the publishablePublish mutation.
In your mutation, you can specify the product id and the id of the market publication you want it published on.
Here’s an example of what the mutation could look like:
mutation PublishablePublish {> publishablePublish(> id: “gid://shopify/Product/8011698569238”> input: { publicationId: “gid://shopify/Publication/124654878742” }> ) {> publishable {> … on Product {> id> }> }> }> }
If you’re not sure of the publication ID of your Canada market, you can query publications to identify this. Here’s an example query you can try. I’ve included the markets handle to make it easier to identify the specific market.
query Publications {> publications(first: 10, catalogType: MARKET) {> nodes {> catalog {> … on MarketCatalog {> publication {> id> name> }> markets(first: 10) {> nodes {> handle> }> }> }> }> }> }> }
Hope that helps,