![](https://sfcclearning.com/infocenter/DWAPI/scriptapi/html/api/images/inherit.gif.pagespeed.ce.4vPrGmNumQ.gif)
- ProductAttributeModel(): When the no-arg constructor is
used the model represents:
- the attribute groups of the system object type 'Product' (i.e. the global product attribute groups) and their bound attributes
- Category.getProductAttributeModel(): When the
attribute model for a Category is retrieved, the model represents:
- the global product attribute groups
- product attribute groups of the calling category
- product attribute groups of any parent categories of the calling category
- Product.getAttributeModel(): When the attribute
model for a Product is retrieved, the model represents:
- the global product attribute groups
- product attribute groups of the product's classification category
- product attribute groups of any parent categories of the product's classification category
- On the product detail page, call Product.getAttributeModel() to get the attribute model for the product.
- Call getVisibleAttributeGroups() to get the groups that are appropriate for this product and all other products assigned to the same classification category.
- Iterate the groups, and display each as a "group" in the UI.
- Call getVisibleAttributeDefinitions(ObjectAttributeGroup) for each group. Iterate and display the attribute names using ObjectAttributeDefinition.getDisplayName().
- For each attribute, get the product's display value(s) for that
attribute, using
getDisplayValue()
. This might require custom display logic based on the type of attribute (strings, dates, multi-value attributes, etc).
The collection of returned groups is sorted first by scope and secondly by explicit sort order. Global groups always appear before category-specific groups in the list. Groups of parent categories always appear before groups belonging to subcategories. At each scope, groups have an explicit sort order which can be managed within the Business Manager.
When there are multiple attribute groups with the same ID, the following rules apply:
- If this model represents the global product attribute group only (e.g. the no-arg constructor was used), duplicates cannot occur since only one group can be defined with a given ID at that scope.
- If this model is associated with specific categories (e.g. it is constructed from a product with a classification category), then a category product attribute group might have the same ID as a global product attribute group. In this case, the category group overrides the global one.
- If a category and one of its ancestor categories both define a product attribute group with the same ID, the sub-category group overrides the parent group.
The returned attribute definitions are sorted according to the explicit sort order defined for the attributes in the group. This is managed by merchant in the Business Manager.
The returned attribute definitions are sorted according to the explicit sort order defined for the attributes in the group. This is managed by merchant in the Business Manager.
The collection of returned groups is sorted first by scope and secondly by explicit sort order. Global groups always appear before category-specific groups in the list. Groups of parent categories always appear before groups belonging to subcategories. At each scope, groups have an explicit sort order which can be managed within the Business Manager.
When there are multiple attribute groups with the same ID, the following rules apply:
- If this model represents the global product attribute group only (e.g. the no-arg constructor was used), duplicates cannot occur since only one group can be defined with a given ID at that scope.
- If this model is associated with specific categories (e.g. it is constructed from a product with a classification category), then a category product attribute group might have the same ID as a global product attribute group. In this case, the category group overrides the global one.
- If a category and one of its ancestor categories both define a product attribute group with the same ID, the sub-category group overrides the parent group.
The returned attribute definitions are sorted according to the explicit sort order defined for the attributes in the group. This is managed by merchant in the Business Manager.
Note: this method may only be used where the attribute model was created for a specific product; otherwise it will always return null.
If the attribute is localized, the value for the current session locale is returned.
In case of an Image attribute this method returns a MediaFile instance. In previous versions this method returned a String with the image path. In case of an HTML attribute this method returns a MarkupText instance. In previous versions this method returned a String with the HTML source.
An attribute definition is considered visible if is marked as visible. If the product attribute model is created for a specific product, the product must also define a value for the attribute definition; else the attribute definition is considered as invisible.
The returned attribute definitions are sorted according to the explicit sort order defined for the attributes in the group. This is managed by merchant in the Business Manager.