Home
Wiki
Home
Wiki
  1. 2. Components
  • Back to home
  • 1. Themes
  • Vs Code
    • Getting Started
  • Kitchenware
    • Layout
      • New Layout
      • Legacy Layout
    • Components
      • Announcement
      • Banner Carousel
      • Banner With Products Carousel
      • Blog Category List
      • Blog List
      • Brand List
      • Brands Carousel
      • Breadcrumb
      • Call To Action
      • Cart
      • Categories List
      • Change Password
      • Checkout
      • Cookie Manager
      • Filter list
      • Footer
      • Forgot Password
      • Form
      • Hero Carousel
      • Icon Block
      • Invitation
      • Last Visited Products
      • Layout
      • Login
      • Map
      • Nav Bar
      • Offer
      • Product Attachments
      • Product Attributes
      • Product Documentation
      • Product Expected
      • Product Modal
      • Products Block
      • Products Carousel
      • Product Single
      • Profile
      • Quote
      • Register
      • Related Products
      • Search
      • Stores
      • Subscribe Newsletter
      • Text with Image
      • Top Bar
      • Video
    • Reusables
      • Getting Started
    • Assets
      • Getting Started
    • SDK
      • Products
        • _findProductsByCategory
        • _findProductsByIds
        • _findProductsByTitle
        • _findProductsByFilter
        • _findProductsByCriteria
        • _findProductsAndCalculate
        • _findProductsThenCalculate
        • _getProductAttributeSet
        • _setLastVisited
      • Categories
        • _findCategoryTreeById
        • _findCategoriesByIds
        • _findCategoryByAlias
        • _findCategoryTreeByAlias
        • _getCategoryContent
      • Collections
        • _getCollectionContent
        • _findCollectionsByIds
        • _findCollectionsByIdsThenCalculate
      • Brands
        • _getBrandContent
        • _findBrandsByIds
      • Cart
        • _addToCartMulti
        • _addToCart
        • _setCart
        • _clearCart
        • _setCartListener
        • _removeFromCart
        • _calculateCart
      • Checkout
        • _startCheckout
        • _updateCheckout
        • _completeCheckout
      • Shopping Lists
        • _getShoppingLists
        • _updateShoppingList
        • _createShoppingList
        • _deleteShoppingList
        • _getShoppingListByAlias
      • Navigation
        • _getFooterMenu
        • _getHeaderMenu
      • Users
        • _getUserById
      • Utils
        • _calculateCurrency
        • _getCurrencySymbol
        • _getCulture
        • _subscribeToNewsletter
        • _findUnitsByIds
  • Noir
    • 0. Introduction
    • 1. Structure
      • Overview
      • LayoutA.liquid
      • ComponentsList.liquid
      • Metas.liquid
      • CssVariables.liquid
      • Json.liquid
      • GoogleTagManager.liquid
      • StagingButton.liquid
    • 2. Components
      • Overview
      • Announcement
      • BannerCarousel
      • BlogCategoryList
      • BlogList
      • BrandList
      • Breadcrumb
      • Cart
      • CategoriesList
      • ChangePassword
      • Checkout
      • CookieManager
      • FilterList
      • Footer
      • ForgotPassword
      • Form
      • IconBlock
      • Invitation
      • LastVisitedProducts
      • Login
      • Map
      • NavBar
      • ProductAttachments
      • ProductAttributes
      • ProductComparison
      • ProductDocumentation
      • ProductMixList
      • ProductsBlock
      • ProductsCarousel
      • ProductSingle
      • Profile
      • Register
      • RelatedProducts
      • SingleBlog
      • Stores
      • TextWithImage
      • ThankYouPage
      • TopBar
      • Wishlist
    • 3. Reusables
      • Overview
      • Addresses
      • BillingRetail
      • AddressForm
      • AnnouncementModal
      • BackToTop
      • Company
      • General
      • Login
      • LoginModal
      • Orders
      • Payment
      • ProductAttachments
      • ProductAttributes
      • ProductComparisonButton
      • ProductComparisonFloatingButton
      • ProductGridItem
      • ProductListItem
      • ShoppingListsButton
      • ProductModal
      • ProfileInfo
      • PromptModal
      • Register
      • Shipping
      • ShoppingLists
      • ShoppingListsNavbar
      • Toast
      • Users
      • VariantContent
      • WishlistButton
      • Services
    • 4. Assets
      • Fonts
      • Images
      • Templates
      • Javascript
        • Overview
        • theme.js
      • Css / Scss
        • Overview
        • ThemeClasses
    • 5. SDK
      • Overview
      • LiquidGlobals
      • ServicesSDK
  1. 2. Components

RelatedProducts

Purpose#

The RelatedProducts component renders one or more product carousels for related product relations.
It:
renders only when relations[] is non-empty
optionally renders a main header (settings.header)
for each relation:
optionally renders a relation title
renders a Swiper carousel of relation.selectedProducts[]
sends a GA4 viewItemList when the carousel enters the viewport

Inputs (model contract)#

Model shape (storefront example)#

{
  "relations": [
    {
      "title": "Sample title",
      "selectedProducts": [
        {
          "id": "Product Id",
          "title": "Sample product title",
          "link": "product/sample-product",
          "mediaItems": [
            {
              "id": "Media Item Id",
              "link": "https://example.com/media/sample.jpg",
              "position": 0,
              "alt": "sample.jpg",
              "mediaType": "Image"
            },
            "..."
          ],
          "productVariants": [
            {
              "id": "Variant Id",
              "finalPriceText": "Sample price text",
              "finalPrice": 10
            },
            "..."
          ],
          "dimension1": {
            "attributeId": "Attribute Id",
            "type": "Color",
            "items": [
              {
                "id": "Attribute Item Id",
                "value": "Sample text"
              },
              "..."
            ]
          },
          "dimension2": {
            "attributeId": "Attribute Id",
            "type": "Size",
            "items": [
              {
                "id": "Attribute Item Id",
                "value": "S"
              },
              "..."
            ]
          }
        },
        "..."
      ]
    },
    "..."
  ],
  "name": "RelatedProducts",
  "view": "Default",
  "section": "SectionA",
  "settings": {
    "relatedProductsAssociationType": "Product",
    "id": "Component Id",
    "section": "SectionA",
    "type": "NoirRelatedProducts",
    "name": "RelatedProducts",
    "configuredInContentApi": true,
    "view": "Default",
    "displayName": "",
    "cssClass": "",
    "header": "Sample text",
    "alignment": "Left"
  },
  "translations": {
    "relatedProducts": "Sample text"
  }
}

Required fields#

settings.id

Optional fields#

settings.cssClass
settings.header (main header for the whole section)
settings.alignment (Left, Center, Right)
relations[]
When empty/missing, the component renders nothing.
Per relation:
relation.title
relation.selectedProducts[]
translations.relatedProducts

JavaScript#

Global object#

Components/RelatedProducts/Default.js exposes:
Liquid binds it via Alpine:
<div x-data='relatedproductsdefault.initComponent("{{ relationId }}", {{ products | serialize | escape }}, "{{ relation.Title | default: model.Translations.RelatedProducts }}")'>

initComponent(id, products, headerTitle)#

What it does
Creates and returns the Alpine state object for one relation carousel.

init()#

What it does
1.
Initializes the Swiper instance.
2.
Registers an “in view” hook that sends GA4 viewItemList when 25% of the carousel is visible.
Key behaviors / edge cases
Uses elementInView("#products-carousel-" + id, ...), so carousel ids must match Liquid.

swiperInit(id)#

What it does
Creates a Swiper on #products-carousel-<id>.
Enables pagination in .swiper-pagination-<id>.
Uses breakpoints:
mobile: 1 per view
>= 1024: 4 per view
Key behaviors / edge cases
Enables looping only when slides.length > 4.

Dependencies#

Alpine.js
Swiper
Reusables\\ProductGridItem\\Default
Theme utilities:
elementInView(...)
prepareListProducts(...)
sendGAEvent(...)

Notes#

Even though the Swiper component has pagination, there are no next/prev arrows.
The top-level settings.header is optional; relation titles can be shown per relation.

Extras#

Template behavior (Liquid + Alpine)#

Computes alignmentClass from settings.alignment.
Builds a relationId as <componentId>-<index> so multiple carousels on the same page don’t collide.
Computes colorExists for the relation by scanning products for a Color dimension.
Modified at 2026-04-14 13:18:56
Previous
Register
Next
SingleBlog
Built with