Skip to main content

Transform To Shopify Structure Usage

Configuration

transformToShopifyStructure Function

The transformToShopifyStructure function converts the ServerProduct[] array into a structure compatible with Shopify’s requirements. This is useful for transforming Fast Simon product data (including promotiles, when configured) into a format that can be used directly within Shopify’s ecosystem.

Parameter

  • ServerProduct[] The function expects an array of ServerProduct objects.

    Note: In some cases, items in this array may represent a Promotile instead of a traditional product.

Return Object

The function returns a list of objects in a format compatible with Shopify's product structure, enabling smooth integration into Shopify themes or apps.

note

While transformToShopifyStructure primarily returns objects of type Product, if a promotile is configured in the Fast Simon dashboard, the function may also return objects of type Promotile. Make sure to handle both types accordingly in your implementation.


Usage Example

const collection = await fastSimon.getSmartCollection({
props: {
categoryURL: '/collections/' + handle,
page,
narrow,
facetsRequired: true,
productsPerPage: 20,
categoryID: undefined,
sortBy,
},
});

if (!collection) {
throw new Response(`Collection ${handle} not found`, {
status: 404,
});
}

const transformed = transformToShopifyStructure(collection.items);

Explanation

1. Fetching the Smart Collection:

The getSmartCollection function fetches a collection from Fast Simon based on the provided parameters like categoryURL, page, and sortBy.

2. Collection Validation:

A check is performed to ensure that the collection exists. If not, an error is thrown with a 404 status.

3. Transforming Data:

The transformToShopifyStructure function is called with the collection items. This transforms the raw data — which may include both standard products and promotiles — into the Shopify product structure, making it ready for integration into Shopify.