'published_scope' => 'global' in REST API, but Product not available to Storefront API.

Solved
VAutoGroup
Tourist
7 1 1

Hi, I am building a custom storefront to integrate into our website. We also us the the standard Storefront.

When i publish items via the REST they aren't available to the to the Storefront API unless i generate a new token or manual add it to the items to the sales channel.

I tried setting

'published_scope' => 'global'

in the Push Service i built but it had no effect on the outcome. 

I also don't actually see any other way to manage the products sales channels via the API.

How does one publish Products to ALL available sales channels?

Accepted Solution (1)

Accepted Solutions
VAutoGroup
Tourist
7 1 1

This is an accepted solution.

Alright. I solved it!

https://shopify.dev/api/admin-rest/2021-10/resources/productlisting#[put]/admin/api/2021-10/product_...

This is the endpoint required to publish product to private app sales channels.

Note: The Access Token is your Storefront API's Access Key

View solution in original post

Replies 5 (5)
devharlo
Tourist
4 0 1

From what I have read, you will only see products that have been assigned as available specifically within the sales channel you are working on and the token is forever associated with only that sales channel

VAutoGroup
Tourist
7 1 1

Yes that is correct - But there needs to be a way to do that through the Admin API but there is nothing I can find in the documentation about assigning items to sales channels other than The default web store and the Shopify POS system which is the `published_scope`

VAutoGroup
Tourist
7 1 1

This is an accepted solution.

Alright. I solved it!

https://shopify.dev/api/admin-rest/2021-10/resources/productlisting#[put]/admin/api/2021-10/product_...

This is the endpoint required to publish product to private app sales channels.

Note: The Access Token is your Storefront API's Access Key

View solution in original post

devharlo
Tourist
4 0 1

Good work, how did you find that out?  So you can assign existing products to a specific app, or do you have to create a duplicate product and assign it?

VAutoGroup
Tourist
7 1 1

You do this after creating the Products using the Product ID so you would be able to write a script to add all existing items added to the App's Product Listing. 


This is what I ended up doing in my update & add script (PHP8/Laravel):

//$result->object() = response from POST /admin/api/2021-10/products.json OR PUT /admin/api/2021-10/products/{PRODUCT-ID}.json

$this->request->put('/admin/api/2021-10/product_listings/'.$result->object()->product->id, [  
"product_listing" => [ "product_id" => $result->object()->product->id   ]
])->header('X-Shopify-Access-Token', env('SHOPIFY_SHOP_TOKEN')) ;