Skip to main content

Smart Collection

Creating Smart Collections allows you to generate dynamic collections that depend on conditions applied to fields (base and metafields) of each product.

  • It is possible to define multiple conditions, linked together via AND or OR.
  • It is possible to set the condition relation type (default: EQUAL)
  • For TAGs the EQUAL condition is handled by Shopify as a CONTAINS
  • The primary key to identify a smart collection can be title or handle, based on the value configured in the specific header (see below)
  • It is possible to associate an image with the collection (Note in update, if not provided and present on Shopify, the existing one will be maintained)
  • It is possible to associate custom metafields with the collection, provided they have been defined as custom data on Shopify.
  • It is possible to define multilingual translations for the title, description, handle fields and for metafields, to support multiple languages in collection display
  • It is possible to publish on Shopify Online Store only, or on all sales channels provided for the shop.

Available keys for rules (key)

These keys represent the base Shopify fields usable in Smart Collection rules.

KeyDescription
metafieldsee example below (here)
tagTags associated with the product
titleProduct title
typeProduct type
compareAtPriceCompare at price (used to indicate discounts)
inventoryQuantity available in warehouse
priceProduct sale price
variant_titleVariant title
weightProduct weight
vendorProduct supplier/brand

Available operators (operator)

These operators determine the type of comparison applied between the key value and that indicated in the rule.

OperatorDescription
EQUALSExactly equal value
NOT_EQUALSDifferent value
GREATER_THANGreater than (only for numeric values)
LESS_THANLess than (only for numeric values)
CONTAINSThe value contains the indicated string
NOT_CONTAINSThe value does not contain the indicated string
STARTS_WITHThe value starts with the indicated string
ENDS_WITHThe value ends with the indicated string
IS_SETThe field is set
IS_NOT_SETThe field is not set

Conditions with Metafields

It is possible to use metafields as subjects of smart collections. These must already be configured on Shopify in the custom data section. To use them:

  • Set the key field with the metafield name
  • Specify conditionTarget to indicate where the metafield is defined (on the product or on the variant)

ConditionTarget (only for metafield)

These targets are used to indicate where the metafield is located:

Target (conditionTarget)Description
PRODUCTThe metafield is associated with the product
PRODUCTVARIANTThe metafield is associated with the variant

Example

{
"rules": [
{
"conditionTarget": "PRODUCT",
"operator": "GREATER_THAN",
"key": "logistic_weight", // Metafield key
"value": "10"
},
{
"conditionTarget": "PRODUCTVARIANT",
"key": "subtitle", // Metafield key
"value": "subtitle value"
}
]
}

Translation Management

Smart Collections support the definition of multilingual translations for the main fields and for metafields. Translations are defined within a translations object, which contains the supported languages and the relative translated strings.

Translatable fields

  • title: collection title
  • description: collection description
  • handle: unique textual identifier used for the URL
  • metafields: specific translations for each metafield key

Example

{
"translations": {
"title": {
"it": "Smart Collection TAG Iphone 12",
"fr": "Collection intelligente TAG Iphone 12"
},
"description": {
"it": "Questa smart collection permette di raggruppare tutti i prodotti che hanno come tag Iphone12",
"fr": "Cette collection intelligente vous permet de regrouper tous les produits qui ont le tag Iphone12"
},
"handle": {
"it": "collezione-iphone-12",
"fr": "collection-iphone-12"
},
"metafields": {
"test": {
"it": "Metafield tradotto",
"fr": "Métachamp traduit"
},
"test_2": {
"it": "Metafield tradotto",
"fr": "Métachamp traduit"
}
}
}
}

Collection publication

In its standard behavior, a Smart Collection is published only on Shopify's Online Store. If the shop provides multiple sales channels, it is possible to publish the collection on all sales channels. This happens through the boolean field isPublishedOnAllChannels, which if set to the value true allows publishing the collection on all channels, while if set to the value false, or if not set, publishes only on Shopify's Online Store.

Example

{
"title": "Smart Collection TAG Iphone 12",
"description": "This smart collection allows you to group all the products that have the Iphone12 tag",
"handle": "smart-collection-iphone-12",
"rules": [
{
"conditionTarget": "PRODUCT",
"operator": "GREATER_THAN",
"key": "logistic_weight",
"value": "10"
},
{
"conditionTarget": "PRODUCTVARIANT",
"key": "subtitle",
"value": "subtitle value"
}
],
"isPublishedOnAllChannels": true // publish the collection on all sales channels
}

Examples

1. Base case: single condition with translations

In this example a smart collection is created that groups all products with the Iphone12 tag and includes translations.

{
"title": "Smart Collection TAG Iphone 12",
"description": "This smart collection allows you to group all the products that have the Iphone12 tag",
"handle": "smart-collection-iphone-12",
"rules": [
{
"key": "tag",
"value": "Iphone12"
}
],
"media": {
"alternativeText": "iphone12",
"url": "https://urldellimmagine.jpg"
},
"metafields": {
"test": "Translated metafield",
"test_2": ""
},
"translations": {
"title": {
"it": "Smart Collection TAG Iphone 12",
"fr": "Collection intelligente TAG Iphone 12"
},
"description": {
"it": "Questa smart collection permette di raggruppare tutti i prodotti che hanno come tag Iphone12",
"fr": "Cette collection intelligente vous permet de regrouper tous les produits qui ont le tag Iphone12"
},
"handle": {
"it": "collezione-iphone-12",
"fr": "collection-iphone-12"
},
"metafields": {
"test": {
"it": "Metafield tradotto",
"fr": "Métachamp traduit"
},
"test_2": {
"it": "Metafield tradotto",
"fr": "Métachamp traduit"
}
}
}
}

2. Multiple conditions in AND

In this case the conditions must all be verified (AND logic).

{
"isConditionOr": false, // Conditions in AND
"title": "Smart Collection TAG Iphone Pesanti",
"description": "Questa smart collection permette di raggruppare tutti i prodotti che hanno come tag Iphone12 e hanno un peso maggiore a 10 kg",
"handle": "collection-iphone-12-pesanti",
"rules": [
{
"key": "tag",
"value": "Iphone12"
},
{
"operator": "GREATER_THAN",
"key": "weight",
"value": "10"
}

]
}

3. Multiple conditions in OR

In this example the conditions are linked with OR logic: products are included that have at least one of the conditions true.

{
"isConditionOr": true, // Conditions in OR
"title": "Smart Collection TAG Iphone Pesanti",
"description": "Questa smart collection permette di raggruppare tutti i prodotti che hanno come tag Iphone12 e hanno un peso maggiore a 10 kg",
"handle": "collection-iphone-12-pesanti",
"rules": [
{
"key": "tag",
"value": "Iphone12"
},
{
"operator": "GREATER_THAN",
"key": "weight",
"value": "10"
}

]
}

Smart collections flow configurations

In addition to the base data flow configurations it is necessary to add the following settings in Settings Override:

FieldValueNote
Base Urlhttps://adapt.flowlyze.comadapter URL
Resource Path/api/adp/shopify/egress/sync-smart-collection-to-shopifyadapter path for smart collections
Headers :: x-api-key**********API key for endpoint interaction verification
Headers :: x-shopify-graphql-urlhttps://SHOPIFYURL.myshopify.com/Shopify shop URL to connect to
Headers :: x-shopify-access-tokenshpat_CODICEALFANUMERICOsecret of the custom app created for integration
Headers :: x-collection-identifiertitle/handleIndicates which field to use as a unique key to identify the smart collection during creation or update operations (default: title)