related_items

This component fetches related items of a specific source item, such as a Product that has had Related Products assign to it.

{% component type: "related_items", source: "Products", itemId: "<Item ID>" %}

Parameters and Options

Parameter Values Required Description
type related_items

This is the name of the entity that needs to be used for the component retrieving function.

source <Module name/ID> The entity/alias name or ID that the data is to be sourced from.
itemId <Item ID> The module item ID (specific Product) the data is to be sourced from
layout <Your Layout name>
Path to file that will contain the Liquid layout content to be parsed.

If an empty string, nothing will be rendered.
If paramater is not included, the default virtual layout will be rendered (see below).

sortBy id
parentid
name
weighting
url
urlslug
releasedate
expirydate
LastUpdatedDate
Author
ItemCategories
ItemTags
<CustomPropertyName>
...and any other top level properties available for the module

The name of the property to sort by. If empty or not present, alpha/numeric sorting will be used.

Remove spaces from custom property names here.

sortOrder ASC (default)
DESC

ASC sorts the items in ascending order while DESC sorts in descending order (based on alpha/numeric or date sorting).
If empty or not present, alpha/numeric sorting will be used.
limit 10 (default)
<number>

The maximum number of items returned. If displayPagination is enabled this determines the maximum number of items per page.
object item
collection (default)

Determines the method for Liquid rendering.
item returns each item iteratively, one after another, for output (generally, output to a container element with no need for looping through the data).
collection returns all items as one collection for output (your container element and looping logic would be handled in the Components Layout).
collectionVariable <yourLiquidVariableName>
Assigns the data to a Liquid collection enabling further access to the data on the Page or Template using Liquid.

Your collectionVariable value must only contain English letters, numbers or underscores. Spaces or special characters are not supported.

Liquid Output

The below example has 2 related items and is the default structure you will get from this Component.

{
  "Pagination": {
  "CurrentPage": 1,
  "ItemsPerPage": 10,
  "NumberOfPages": 1,
  "TotalItemsCount": 2
},
  "Items": [
  {
    "Id": 2536,
    "Url": "/catalogs/demo-product-2",
    "ParentId": 2489,
    "LastUpdatedDate": "2020-05-20T09:35:14",
    "Name": "DEMO product 2",
    "UrlSlug": "demo-product-2",
    "Enabled": true,
    "ReleaseDate": "2020-05-06T00:00:00",
    "ExpiryDate": "2099-12-11T13:00:00",
    "Weighting": 0,
    "Description": "<p>Sample product for the ecommerce store.</p>",
    "ItemTags": null,
    "Author_Name": null,
    "Author_Url": null,
    "Author": "",
    "SEOTitle": "",
    "MetaTitle": "",
    "MetaDescription": "",
    "ShowPageForSearchEngine": false,
    "CanonicalLink": "",
    "EnableAMP": false,
    "AMPContent": "",
    "CodeEditor": false,
    "ExternalId": 0,
    "SocialMetaTags": "",
    "OpenGraphProperties": "",
    "DisableForSiteSearch": false,
    "SeoPriority": "0.5",
    "CreatedByMemberId": 0,
    "ItemCategories": null,
    "ItemCategoryIdList": null,
    "SKUCode": "DEMO2",
    "SiteSearchKeywords": "",
    "SmallImage": "/images/template-detail-crafter-mobile@2x.png",
    "LargeImage": "/images/template-detail-crafter-desktop@2x.jpg",
    "OnSale": false,
    "IsGiftVoucher": false,
    "ProductWeight": 0,
    "ProductWidth": 0,
    "ProductHeight": 0,
    "ProductDepth": 0,
    "EnableDropShipping": false,
    "Supplier": "0",
    "UnitType": "",
    "MinimumUnits": 0,
    "MaximumUnits": 0,
    "RecurringType": "",
    "IsShippable": true,
    "IsDownloadable": false,
    "DownloadableFileLink": "",
    "NumberOfPossibleDownloads": 0,
    "taxRate": 0.0,
    "Price": 0.0,
    "IsHide": false,
    "InStock": 0,
    "IsDisable": false,
    "priceWithTax": 0.0,
    "ProductDataJSON": {
      "itemId": 2536,
      "attributes": {},
      "variations": null,
      "options": {},
      "inStockTotal": null,
      "recommendedPrice": null,
      "prices": {
        "0": 0.0
      },
      "taxInPercent": 0.0,
      "taxRate": 0.0,
      "enablePreOrder": true,
      "maximumUnits": 0,
      "minimumUnits": 0,
      "QuantityThreshold": [
        {
          "Quantity": 0,
          "Price": 0.0
        }
      ]
    },
    "RecommendedPrice": 0.0,
    "EnableInventoryControl": false,
    "VolumeDiscount": [
      {
        "Quantity": 0,
        "Price": 0.0
      }
    ],
    "PriceHtml": "<span data-cms_product_data_price=\"2536\">0.00</span>",
    "InStockHtml": "<span data-cms_product_data_in_stock=\"2536\">0</span>",
    "priceWithTaxHtml": "<span data-cms_product_data_price_with_tax=\"2536\">0.00</span>",
    "RecommendedPriceHtml": "<span data-cms_product_data_recommended_price=\"2536\">0.00</span>",
    "InventoryProductVariations": [
      {
        "SKUCode": "DEMO2",
        "InStock": 0,
        "PreOrder": 0
      }
    ],
    "ProductDataJsonHTML": "<script>initEcommerceProductPriceVariations(2536,{\"itemId\":2536,\"attributes\":{},\"variations\":null,\"options\":{},\"inStockTotal\":null,\"recommendedPrice\":null,\"prices\":{\"0\":0.0},\"taxInPercent\":0.0,\"taxRate\":0.0,\"enablePreOrder\":true,\"maximumUnits\":0,\"minimumUnits\":0,\"QuantityThreshold\":[{\"Quantity\":0,\"Price\":0.0}]});</script>"
  },
  {
    "Id": 2563,
    "Url": "/catalogs/demo-product-3",
    "ParentId": 2489,
    "LastUpdatedDate": "2020-05-20T09:35:16",
    "Name": "DEMO Product 3",
    "UrlSlug": "demo-product-3",
    "Enabled": true,
    "ReleaseDate": "2020-05-20T00:00:00",
    "ExpiryDate": "2099-12-11T13:00:00",
    "Weighting": 0,
    "Description": "",
    "ItemTags": null,
    "Author_Name": null,
    "Author_Url": null,
    "Author": "",
    "SEOTitle": "",
    "MetaTitle": "",
    "MetaDescription": "",
    "ShowPageForSearchEngine": false,
    "CanonicalLink": "",
    "EnableAMP": false,
    "AMPContent": "",
    "CodeEditor": false,
    "ExternalId": 0,
    "SocialMetaTags": "",
    "OpenGraphProperties": "",
    "DisableForSiteSearch": false,
    "SeoPriority": "0.5",
    "CreatedByMemberId": 0,
    "ItemCategories": null,
    "ItemCategoryIdList": null,
    "SKUCode": "7067ce22-6b5d-4bdb-80e6-b878ca0b31f2",
    "SiteSearchKeywords": "",
    "SmallImage": null,
    "LargeImage": null,
    "OnSale": false,
    "IsGiftVoucher": false,
    "ProductWeight": 0,
    "ProductWidth": 0,
    "ProductHeight": 0,
    "ProductDepth": 0,
    "EnableDropShipping": false,
    "Supplier": "0",
    "UnitType": "",
    "MinimumUnits": 0,
    "MaximumUnits": 0,
    "RecurringType": "",
    "IsShippable": true,
    "IsDownloadable": false,
    "DownloadableFileLink": "",
    "NumberOfPossibleDownloads": 0,
    "taxRate": 0.0,
    "Price": 0.0,
    "IsHide": false,
    "InStock": 0,
    "IsDisable": false,
    "priceWithTax": 0.0,
    "ProductDataJSON": {
      "itemId": 2563,
      "attributes": {},
      "variations": null,
      "options": {},
      "inStockTotal": null,
      "recommendedPrice": null,
      "prices": {
        "0": 0.0
      },
      "taxInPercent": 0.0,
      "taxRate": 0.0,
      "enablePreOrder": true,
      "maximumUnits": 0,
      "minimumUnits": 0,
      "QuantityThreshold": [
        {
          "Quantity": 0,
          "Price": 0.0
        }
      ]
    },
    "RecommendedPrice": 0.0,
    "EnableInventoryControl": false,
    "VolumeDiscount": [
      {
        "Quantity": 0,
        "Price": 0.0
      }
    ],
    "PriceHtml": "<span data-cms_product_data_price=\"2563\">0.00</span>",
    "InStockHtml": "<span data-cms_product_data_in_stock=\"2563\">0</span>",
    "priceWithTaxHtml": "<span data-cms_product_data_price_with_tax=\"2563\">0.00</span>",
    "RecommendedPriceHtml": "<span data-cms_product_data_recommended_price=\"2563\">0.00</span>",
    "InventoryProductVariations": [
      {
        "SKUCode": "7067ce22-6b5d-4bdb-80e6-b878ca0b31f2",
        "InStock": 0,
        "PreOrder": 0
      }
    ],
    "ProductDataJsonHTML": "<script>initEcommerceProductPriceVariations(2563,{\"itemId\":2563,\"attributes\":{},\"variations\":null,\"options\":{},\"inStockTotal\":null,\"recommendedPrice\":null,\"prices\":{\"0\":0.0},\"taxInPercent\":0.0,\"taxRate\":0.0,\"enablePreOrder\":true,\"maximumUnits\":0,\"minimumUnits\":0,\"QuantityThreshold\":[{\"Quantity\":0,\"Price\":0.0}]});</script>"
  }
],
  "Params": {},
  "Parent": {
  "Count": 48,
  "Items": [
    {
      "Key": "Id",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "Url",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ParentId",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "LastUpdatedDate",
      "Value": {
        "Type": 7
      }
    },
    {
      "Key": "Name",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "UrlSlug",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "Enabled",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "ReleaseDate",
      "Value": {
        "Type": 7
      }
    },
    {
      "Key": "ExpiryDate",
      "Value": {
        "Type": 7
      }
    },
    {
      "Key": "Weighting",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "Description",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ItemTags",
      "Value": {
        "Type": 1
      }
    },
    {
      "Key": "Author_Name",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "Author_Url",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "Author",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "SEOTitle",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "MetaTitle",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "MetaDescription",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ShowPageForSearchEngine",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "CanonicalLink",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "EnableAMP",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "AMPContent",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "CodeEditor",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "ExternalId",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "SocialMetaTags",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "OpenGraphProperties",
      "Value": {
        "Type": 3
      }
    },
    {
      "Key": "DisableForSiteSearch",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "SeoPriority",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "CreatedByMemberId",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "ItemCategories",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "ItemCategoryIdList",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "SKUCode",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "SiteSearchKeywords",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "Active",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "IgnoreUpdates",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "UpdateNotes",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ExternalResources",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "AdditionalRelatedArticle_Name",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "AdditionalRelatedArticle_Url",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "AdditionalRelatedArticle",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "AdditionalRelatedArticle2_Name",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "AdditionalRelatedArticle2_Url",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "AdditionalRelatedArticle2",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "Authors",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ParentName",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ParentUrl",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "TemplateName",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "IsHome",
      "Value": {
        "Type": 2
      }
    }
  ]
}
}

Virtual Layout

Based on the above example, if not using any custom layout or collection, the default virtual layout will output as a list of related items:

<ul>
    {% for item in this.items %}
        <li> 
            <a href="{{item.url}}" title="{{item.name}}">{{item.name}}</a>
        </li>
    {% endfor %}
</ul>

Rendering the list:

Accessing the Data

This data is also accessible directly on the Page or Template via a Liquid Collection by adding collectionVariable to the Component.

An example using collectionVariable with value "relatedCollection":

{% component type:"related_items", source: "Products", itemId: "2535", collectionVariable: "relatedCollection" %}

Accessing a specific item within the collection. In this case the first item (zero based index), which in our example would render the value DEMO product 2

{{relatedCollection.items[0]['Name']}}


Related Articles

  • Payment Settings
  • Orders
  • {{ order }} object
    This liquid object will output the order details of a submitted payment. {% capture data...
  • module (Catalogs)
    This module component fetches data relating to eCommerce Catalogs and can be used to render Catalog structures and Products within them.
  • module (Products)
    This module component fetches data relating to eCommerce Products and can be used to render Product information.
  • ecommerce_add_to_cart
    This component renders an anchor element allowing the javascript function to add the item to the shopping cart.
  • ecommerce_buy_now
    This component renders an anchor element allowing the javascript function to add the item to the shopping cart and then proceeding directly to the shopping cart page.
  • ecommerce_item_quantity
    This component renders a form input element allowing a quantity to be set for when the source item is added to the shopping cart.
  • item_attributes
    This component fetches all attributes/options for a specified product. By default, each attribute group is rendered, with its options and any prices, according to their specified form inputs.
  • grouped_items
    This component fetches grouped items of a specific source item, such as a Product that has been Grouped with other Products and allows the ability to navigate between grouped items.
  • currencies
    This component renders a form select element of all currency names, codes and symbols by default, and can also be used to output currency data to a Liquid collection.
  • shopping_cart
    This component fetches data relating to the shopping cart, such as any products added, order totals, tax, shipping, etc.
  • shipping_options
    This component renders a form select element of all shipping options configured on the site, and can also be used to output shipping option data to a Liquid collection.
  • tax_codes
    This component renders a form select element of all tax codes configured on the site, and can also be used to output tax code data to a Liquid collection.
  • payment_form_fields
    This component is used to render payment fields, and payment related validation errors, within a form using the capabilities provided by your configured payment gateway.
  • orders
    This component fetches Orders from the CRM, either owned by the logged-in user or for all customer Orders.
  • Getting Started
    With the recent release of eCommerce features there are some advanced system components that are...
  • Products
    Products are one of the most powerful and flexible modules in Treepl CMS. Create customised product schemas with multiple price points, catalogs, inventory tracked attributes/variables, SEO optimisation and more.
  • Catalogs
    When organising any eCommerce store, Catalogs are crucial to your Products structure and browserbility. Easily create and customise unlimited product catalogs for your online store.
  • countries
    This component renders a form select element of all country names and country codes by default, and can also be used to output country codes/names to a Liquid collection.
  • domain_settings
    This module component retrieves settings associated with the current domain, or optionally from another specified domain configured in the site instance.

External Resources

There are currently no external resources available.

Please let us know if you have any other contributions or know of any helpful resources you'd like to see added here.


Questions?

We are always happy to help with any questions you may have.
Send us a message at support@treepl.co and we will consult you as soon as possible.