Publish products
After merchants are onboarded to your sales channel app, you can publish the merchant's products to your sales channel. This process has frontend or backend considerations.
Requirements
Anchor link to section titled "Requirements"- You've built an account page.
Step 1: Retrieve product listings
Anchor link to section titled "Step 1: Retrieve product listings"By default, all available products can be published to your channel. However, Shopify recommends reading the product catalog from the ProductListing resource instead, to give merchants better control over their products.
To retrieve product listings, send the following GET request to the Shopify API:
Request: GET https://{shop}.myshopify.com/admin/api/2022-04/product_listings.json
In response, the API returns the product listings formatted as JSON.
Step 2: Build a product status card
Anchor link to section titled "Step 2: Build a product status card"To display product publishing statuses to merchants, build a product status card on the account page using the Card component.
The product status card includes the number of products published. If any products failed to publish to a sales channel, then the card will list the number of products with errors.
Your product status card might look like the following:
Step 3: Manage product information
Anchor link to section titled "Step 3: Manage product information"In the Shopify admin, on Products, merchants can view and manage products that are published to the sales channel.
If merchants select your sales channel from the More actions drop-down menu, then they can view metafields for the sales channel.
Merchants can use the bulk editor to view and manage multiple products at once.
In some cases, the product catalog won't include all of the product information that you need for your sales channel. In these instances, use metafields to obtain the additional information. Alternately, you can use the Metafield
resource in the REST Admin API.
Your channel can also integrate with scheduled product listings.
Step 4: Manage errors
Anchor link to section titled "Step 4: Manage errors"You might encounter errors when trying to publish the merchant's product catalog to your sales channel. Publishing errors are displayed in the product status card. The product status card can show products that are being synced or products that have sync errors.
Merchants need to be able to view all products with publishing errors directly through the sales channel app using the link on the product status card. Use the Banner component to display a success banner when errors are resolved.
Merchants can use the bulk editor to view and manage publishing errors on multiple products at once.
The Product ResourceFeedback resource or ResourceFeedback object enables you to prompt merchants to resolve product publishing errors. This can be useful in various scenarios, such as when a product isn't valid for you to publish, or when an edit to a previously published product causes an error.
Any missing product attributes that the sales channel requires can be listed on Products using the Resource feedback API. Merchants can view the resource feedback in the product status card.
Product-level resource feedback
Anchor link to section titled "Product-level resource feedback"Product-level resource feedback can be used for a product and its variants.
To create product-level resource feedback, send the following POST request to the Shopify API:
Request: POST https://{shop}.myshopify.com/admin/api/2022-04/products/#{product_id}/resource_feedback.json
After you create resource feedback, you need to check the product for validity whenever you receive a product update. If the error is resolved, then you can dismiss the resource feedback.
Shop-level resource feedback
Anchor link to section titled "Shop-level resource feedback"Shop-level resource feedback can be used for any account-level errors that affect the entire catalog.
To create shop-level resource feedback, send the following POST request to the Shopify API:
Request: POST https://{shop}.myshopify.com/admin/api/2022-04/resource_feedback.json
Step 5: Stay in sync with product changes
Anchor link to section titled "Step 5: Stay in sync with product changes"After products have been successfully published to your sales channel, you need to keep the product catalog up-to-date with any changes in Shopify. For example, if a merchant changes a product title or marks a product as out of stock, then the product catalog should be updated.
To stay in sync with product changes, you can subscribe to the following product_listing
or collection_listing
webhooks:
product_listings/add
product_listings/update
product_listings/remove
collection_listings/add
collection_listings/update
collection_listings/remove
You can configure webhooks using the API by specifying the topic in the request body.
The following is an example of a POST request that uses the product_listings/add
webhook:
The POST request returns the following response:
You can then create an HTTP endpoint on your server to monitor for events. For more information, refer to HTTPS webhook delivery.