PhoenixKitEcommerce.Shopify.AdminClient (PhoenixKitEcommerce v0.5.0)

Copy Markdown View Source

Thin REST client for the Shopify Admin API's products.json endpoint.

Resolves the shop domain and access token from the PhoenixKit.Integrations connection identified by integration_uuid — never from application env (see PhoenixKitEcommerce.Shopify.Provider for why). Authenticates with the X-Shopify-Access-Token header, NOT Authorization: Bearer — that is what the REST Admin API expects for a Custom App's static token.

Summary

Functions

Fetches the product ids of collection_id, in the order Shopify returns them — Shopify applies the collection's own sort order to this endpoint, so no client-side sorting happens here; CollectionSync reads this order directly as item.position within the category. Paginated like fetch_products/2.

Fetches every collection from the connected store — custom_collections and smart_collections concatenated, each paginated like fetch_products/2. Each returned collection carries "kind" ("custom" or "smart", which endpoint it came from) and "position" — a running index across BOTH lists, in API order (custom first, then smart) — this is the order CollectionSync writes as category.position.

Fetches every product from the Shopify store connected via integration_uuid, following Link: rel="next" pagination.

Functions

fetch_collection_product_ids(collection_id, opts \\ [])

@spec fetch_collection_product_ids(String.t() | integer(), keyword()) ::
  {:ok, [term()]} | {:error, term()}

Fetches the product ids of collection_id, in the order Shopify returns them — Shopify applies the collection's own sort order to this endpoint, so no client-side sorting happens here; CollectionSync reads this order directly as item.position within the category. Paginated like fetch_products/2.

Options

Same as fetch_collections/1.

fetch_collections(opts \\ [])

@spec fetch_collections(keyword()) :: {:ok, [map()]} | {:error, term()}

Fetches every collection from the connected store — custom_collections and smart_collections concatenated, each paginated like fetch_products/2. Each returned collection carries "kind" ("custom" or "smart", which endpoint it came from) and "position" — a running index across BOTH lists, in API order (custom first, then smart) — this is the order CollectionSync writes as category.position.

Options

fetch_products(integration_uuid, opts \\ [])

@spec fetch_products(String.t(), keyword()) :: {:ok, [map()]} | {:error, term()}

Fetches every product from the Shopify store connected via integration_uuid, following Link: rel="next" pagination.

Options

  • :req_options — keyword list merged into Req.new/1 (e.g. plug: to stub the transport in tests).