internal static void EnsureValueConversion(this ProductAttributeDisplay display, IContentType contentType, DetachedValuesConversionType conversionType = DetachedValuesConversionType.Db) { if (display.ValueConversion == conversionType) { return; } display.ValueConversion = conversionType; display.DetachedDataValues = DetachedValuesConverter.Current.Convert(contentType, display.DetachedDataValues, conversionType); }
/// <summary> /// Ensures the attribute data values. /// </summary> /// <param name="attribute"> /// The attribute. /// </param> /// <remarks> /// This is required as some options are shared and the attribute data values are not serialized into the /// Examine index for these attributes. /// </remarks> /// <returns> /// The detached contents. /// </returns> internal static void EnsureAttributeDetachedDataValues(this ProductAttributeDisplay attribute) { if (attribute.DetachedDataValues != null && attribute.DetachedDataValues.Any()) { return; } var pa = MerchelloContext.Current.Services.ProductOptionService.GetProductAttributeByKey(attribute.Key); attribute.DetachedDataValues = pa.DetachedDataValues.AsEnumerable(); }
/// <summary> /// Initializes a new instance of the <see cref="ProductAttributeContent"/> class. /// </summary> /// <param name="contentType"> /// The content type. /// </param> /// <param name="display"> /// The display. /// </param> /// <param name="parent"> /// The parent content - generally set to the <see cref="IProductContent"/> containing the option /// </param> /// <param name="isPreviewing"> /// The is previewing. /// </param> public ProductAttributeContent( PublishedContentType contentType, ProductAttributeDisplay display, IPublishedContent parent = null, bool isPreviewing = false) { Mandate.ParameterNotNull(display, "display"); _contentType = contentType; _display = display; _parent = parent; _isForPreview = isPreviewing; this.Initialize(); }
/// <summary> /// Gets the content for an attribute if available. /// </summary> /// <param name="variant"> /// The variant. /// </param> /// <param name="attribute"> /// The attribute. /// </param> /// <returns> /// The <see cref="IProductAttributeContent"/>. /// </returns> public static IProductAttributeContent GetContentForAttribute(this IProductVariantContent variant, ProductAttributeDisplay attribute) { return(variant.GetContentForAttribute(attribute.Key)); }
/// <summary> /// Returns a value indicating whether or not an attribute has property content. /// </summary> /// <param name="variant"> /// The variant. /// </param> /// <param name="attribute"> /// The attribute. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool AttributeHasContent(this IProductVariantContent variant, ProductAttributeDisplay attribute) { return(variant.AttributeHasContent(attribute.Key)); }