AI OnAI Off
This can be considered a bug. However what is the right way to do it is up to discussion. I'll file a bug so we can discuss and will get back to you.
In the meantime, you can resolve that issue by creating a new editor descriptor for it.
Let's do it as following steps:
[EditorDescriptorRegistration(TargetType = typeof(ContentReference), UIHint = "TopLevelProductVariation")] public class TopLevelProductVariationReferenceEditorDescriptor : ContentReferenceEditorDescriptor<CatalogContentBase> { public TopLevelProductVariationReferenceEditorDescriptor() { ClientEditingClass = "your-dojo-client-resources-folder/widget/TopLevelCatalogContentSelector"; } public override string RepositoryKey { get { return CatalogRepositoryDescriptor.RepositoryKey; } } }
(TopLevelCatalogContentSelector widget defined in above step)
define([ // dojo "dojo/_base/declare", "dojo/aspect", // epi "epi-cms/widget/ContentSelector" ], function ( // dojo declare, aspect, // epi ContentSelector ) { return declare([ContentSelector], { _getDialog: function () { // tags: // protected extensions var dialog = this.inherited(arguments); if (this.dialog && this.contentSelectorDialog) { this.own( aspect.before(this.contentSelectorDialog.tree.model.store, "query", function (query, queryOptions) { query.toplevel = true; }, true), aspect.around(this.contentSelectorDialog.tree, "selectContent", function (originalMethod) { return function (contentReferenceAsString, setFocus, needParentRefresh, onComplete) { if (this.selectedItem.contentLink === contentReferenceAsString) { return; } originalMethod.apply(this, arguments); }; }) ); } return dialog; } }); });
/// <summary> /// Gets or sets the product content reference. /// </summary> /// <value> /// The product content reference. /// </value> [Display( Name = "Product/Course Variant", Description = "The variant to be added to the basket - will use the variant on the page level by default if empty", GroupName = SystemTabNames.Content, Order = 10 )] [UIHint("TopLevelProductVariation")] [AllowedTypes(typeof(SupplierProductVariant), typeof(CourseScheduleVariant))] public virtual ContentReference ProductContentReference { get; set; }
Updated code for TopLevelCatalogContentSelector widget
define([ // dojo "dojo/_base/declare", "dojo/aspect", // epi "epi-cms/widget/ContentSelector" ], function ( // dojo declare, aspect, // epi ContentSelector ) { return declare([ContentSelector], { _getDialog: function () { // tags: // protected extensions var dialog = this.inherited(arguments); if (this.dialog && this.contentSelectorDialog) { this.own( aspect.before(this.contentSelectorDialog.tree.model.store, "query", function (query, queryOptions) { query.toplevel = true; }, true), aspect.around(this.contentSelectorDialog.tree, "selectContent", function (originalMethod) { return function (contentReferenceAsString, setFocus, needParentRefresh, onComplete) { if ((this.selectedItem && this.selectedItem.contentLink) === contentReferenceAsString) { return; } originalMethod.apply(this, arguments); }; }) ); } return dialog; } }); });
We have many blocks that we have created that are designed to allow the picking of a commerce product/variant, these have the standard ContentReference property such as below
However when this picker is shown it seems to show the variant in both the node as well as the product when it should only be shown in the product level and this make it really difficult to use.
We have tried using the Commerce UiHints as shown above EPiServer.Commerce.UIHint.CatalogEntry and EPiServer.Commerce.UIHint.ProductVariation but it always seems to have this issue.
Is there any workaround for this anyone knows?