In this article, we review another small plugin created, which exposes the variation properties in the Variants entity view within the Merchandising Manager.
The Habitat catalog data has been created in such a way in which the variation properties are exposed via adding the variation property value to the variant display name, e.g. Habitat Dwell Bagless Upright Vacuum (Red). While this approach works to an extent, it will get more ugly as the variation properties grow, e.g. My Test Jeans (Blue, 32, slim).
The custom plugin will traverse over the variation’s components to find the the properties that match the names provided in the VariationPropertiesPolicy and render them to the Variants entity view.
In the example above, I have specified the following property names, Color, Size, Style, and Length, which works well when all properties have been specified (see below).
A couple of things to note about the platform implementation:
- Variation Properties apply to all Sellable Items globally. If a product contains a value against a property that is specified in the Variation Properties Policy it will render as a variant selection in the Storefront.
- There is no validation to ensure that variation properties are mandatory for variants. This is because not all products will utilise these variation properties. I didn’t think it was necessary to add more overhead to remove columns that contained no values.
- You’ll notice above that the first 2 variants of my Test Pants have matching variation properties. This is again due to having no validation in place, which I believe will break the storefront. So whether you have implemented a catalog import or are entering product data manually be careful not to double up.
Source Code: Ajsuth.Feature.Catalog.VariantProperties.Engine
In this article, we will review the process of configuring product variations properties so that the Product Variants SXA component will render them as dropdown selection controls. This controls allows the user to select the variant property combinations, where each combination represents individual product variants of a product family.
Configure the Variation Properties
In the Commerce Engine solution:
- Define all variation property names in the VariationPropertyPolicy of the environment configuration files.
- In this sample, we will add the Style property to the VariationPropertyPolicy.
Note: The property names are the names of properties that exist on child components of the ItemVariationComponent. The fully qualified namespace for the property is not required as the SXA Storefront logic will use a property name match against the field names produced by the Catalog Generated templates.
"$type": "Sitecore.Commerce.Plugin.Catalog.VariationPropertyPolicy, Sitecore.Commerce.Plugin.Catalog",
"$type": "System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib",
- Publish the solution and Bootstrap the Commerce Engine.
- Verify the variation property in the Storefront.
Note: In the sample below I updated the sellable item’s Style property with the value “Modern” for demo purposes.
Add Variant Specification Label
If you create add new properties that does not have corresponding label configured the variation property label will display as “[YourProperty]“.
To resolve this, go to the Sitecore Content Editor:
- Add user friendly label value to /sitecore/Commerce/Commerce Control Panel/Storefront Settings/Commerce Terms/Variant Specification Labels.
- Publish the Sitecore Item and Reindex.
In this article, we introduce a small custom plugin for Sitecore Commerce Business Tools that enables the reordering of images for sellable items and variants.
In its current release (XC 9.0.3), the only way to reorder images is to remove existing images and re-adding them in the desired order. It’s not the best user experience and can take a considerable length of time to relocate the original images.
The custom catalog plugin adds 2 new actions to the Images actions – Move Image Up and Move Image Down.
The functionality is still a little clunky. The confirmation dialog shows each time an image is moved, the selected image will always reset to the first image after each action, and while the move buttons are not disabled for its outer limits, the code logic prevents out of boundary exceptions from being thrown. Overall, it is definitely an upgraded approach to reordering images.
Publishing the sellable item through workflow is still required in order to have the changes show in the storefront.
Source Code: Extended Sitecore Commerce Catalog project repository