Skip to main content

Links between Attribute Module and Other Modules

This document showcases the module links defined between the Attribute Module and other Commerce Modules.

Summary

The Attribute Module has the following links to other modules:
First Data ModelSecond Data ModelTypeDescription
ProductAttributeValueStored - many-to-manyAssociates products with their attribute values
ProductCategoryAttributeStored - many-to-manyAssociates product categories with their applicable attributes

Product Module

Mercur defines a link between the Product Module’s Product data model and the Attribute Module’s AttributeValue data model. This allows products to have multiple attribute values assigned to them (e.g., Material: “Cotton”, Color: “Blue”).

Retrieve with Query

To retrieve the attribute values of a product with Query, pass attribute_value_link.attribute_value.* in fields:
  • query.graph
  • useQueryGraphStep
const { data: products } = await query.graph({
  entity: "product",
  fields: [
    "*",
    "attribute_value_link.attribute_value.*",
    "attribute_value_link.attribute_value.attribute.*",
  ],
})

// products[0].attribute_value_link[0].attribute_value
// products[0].attribute_value_link[0].attribute_value.attribute
To manage the attribute values of a product, use Link:

Product Module - Categories

Mercur defines a link between the Product Module’s ProductCategory data model and the Attribute Module’s Attribute data model. This allows product categories to define which attributes are applicable for products in that category (e.g., “Electronics” category might have “Battery Life” and “Screen Size” attributes).

Retrieve with Query

To retrieve the attributes of a product category with Query, pass attribute_link.attribute.* in fields:
  • query.graph
  • useQueryGraphStep
const { data: categories } = await query.graph({
  entity: "product_category",
  fields: [
    "*",
    "attribute_link.attribute.*",
  ],
})

// categories[0].attribute_link[0].attribute
To manage the attributes of a product category, use Link: