Contextual product feeds
Contextual product feeds allow sales channels to sync merchant catalogs to their platforms. You can configure distinct feeds for the different language and country pairs that a merchant supports.
What you'll learn
Anchor link to section titled "What you'll learn"In this tutorial, you'll learn how to do the following tasks:
- Identify a merchant's supported markets
- Create product feeds for specific country/language contexts
- Subscribe to product feed webhooks
- Initiate a full product sync
Requirements
Anchor link to section titled "Requirements"- Your app has the
read_product_listings
access scope. Learn more about requesting access scopes when your app is installed using authorization code grant.
Step 1: Identify the merchant's supported markets
Anchor link to section titled "Step 1: Identify the merchant's supported markets"Query the merchant's markets to obtain localization details, including each country's supported languages and currencies.
The following example shows how to retrieve language, currency and country details from a shop's markets. Inline fragments are used to simply the GraphQL query.
Subscribe to market updates
Anchor link to section titled "Subscribe to market updates"Market configurations might change after onboarding, to which your app may need to respond. Stay updated on any market changes by using the webhookSubscriptionCreate
mutation to subscribe to the MARKETS_CREATE
, MARKETS_DELETE
and MARKETS_UPDATE
webhook topics. Events will be triggered whenever key changes occur, such as when:
- A new market is created.
- An existing market is updated.
- An existing market is deleted.
Step 2: Create product feeds
Anchor link to section titled "Step 2: Create product feeds"Use the productFeedCreate
mutation to create a ProductFeed
for each country/language pair that both the channel and the merchant support.
Save the productFeed
's id
value. You'll use it it initiate and identify webhook payloads in a subsequent step when you synchronize products.
The following example shows how to create a product feed for the US-EN
context.
(Optional): Use the primary context only
Anchor link to section titled "(Optional): Use the primary context only"If your app only requires access to the merchant's default localization, then use the productFeedCreate
mutation without its input
argument. This creates a feed in the merchant's primary context, similar to how the ProductListings
reference on the REST Admin API behaves.
Step 3: Subscribe to product feed webhooks
Anchor link to section titled "Step 3: Subscribe to product feed webhooks"Subscribe to product feed webhooks to receive initial full sync payloads and async events whenever products are updated.
Subscribe to full sync events
Anchor link to section titled "Subscribe to full sync events"Full sync events are triggered when a product feed full sync is initiated. Full sync events contain individual product payloads and allow you to sync a merchant's entire catalog during channel setup.
Use the webhookSubscriptionCreate
mutation to subscribe to the PRODUCT_FEEDS_FULL_SYNC
webhook topic.
Individual product listing payloads are sent when a full sync is initiated.
(Optional): Subscribe to full sync completion events
Anchor link to section titled "(Optional): Subscribe to full sync completion events"You can subscribe to the PRODUCT_FEEDS_FULL_SYNC_FINISH
webhook topic to be notified whenever a full sync finishes. This is a useful signal for scenarios where the merchant hasn't published any products to the channel.
Subscribe to incremental sync events
Anchor link to section titled "Subscribe to incremental sync events"Incremental sync events are triggered whenever changes occur relative to app's feeds, such as when:
- Product fields are updated.
- Product variant fields are added, updated, or deleted.
- Product translations are updated.
- Product market price is updated.
- Products are published to the app.
- Products are unpublished from app.
Use the webhookSubscriptionCreate
mutation to subscribe to the PRODUCT_FEEDS_INCREMENTAL_SYNC
webhook topic.
Subscribe to product feed updates
Anchor link to section titled "Subscribe to product feed updates"Product feeds might change as the merchant modifies their market settings. For example, if a merchant un-publishes a language, then any dependant feeds will become inactive. Subscribe to the PRODUCT_FEEDS_UPDATE
webhook topic to stay updated on feed statuses
.
Step 4: Initiate a full sync
Anchor link to section titled "Step 4: Initiate a full sync"After all relevant feeds are created and your app has subscribed to the necessary webhook topics, you can initiate full syncs for each feed using the productFullSync
. The id
returned can be used to attribute the webhooks and identify the sync completion event.
Your app should trigger a full sync once during initialization to fetch the store's entire catalog. You can trigger additional full syncs on a regular schedule for reconciliation.
When a full sync is initiated, individual PRODUCT_FEEDS_FULL_SYNC
webhook payloads are fired for each of the merchant's published products. The webhook payloads contain localized data according the feed's context. A confirmation event is sent to the PRODUCT_FEEDS_FULL_SYNC_FINISH
subscription once the full sync has completed. The payload's fullSyncId
is the feed's identifier.
An initial full sync should be triggered during app onboarding, and regular reconciliation syncs should be scheduled after. The optional beforeUpdatedAt
and updatedAtSince
parameters allow you to specify a time range for the sync.
(Optional):Full Sync by download
Anchor link to section titled "(Optional):Full Sync by download"An alternative solution is to download a single JSONL
file containing all products that would normally be sent through individual PRODUCT_FEEDS_FULL_SYNC
payloads. This can be useful in scenarios where the amount of webhook traffic is difficult to manage. When full sync by download is enabled, the PRODUCT_FEEDS_FULL_SYNC_FINISH
webhook payload contains a JSONL
file URL. This functionality is similar to bulk operations.
- For other channel product sync solutions, refer to the unidirectional product synchronization guide.