Try your search with a different keyword or use * as a wildcard.
using Nop.Core.Domain.Catalog;
namespace Nop.Services.Catalog;
///
/// Extensions
///
public static class ProductAttributeExtensions
{
///
/// A value indicating whether this product attribute should have values
///
/// Product attribute mapping
/// Result
public static bool ShouldHaveValues(this ProductAttributeMapping productAttributeMapping)
{
if (productAttributeMapping == null)
return false;
if (productAttributeMapping.AttributeControlType == AttributeControlType.TextBox ||
productAttributeMapping.AttributeControlType == AttributeControlType.MultilineTextbox ||
productAttributeMapping.AttributeControlType == AttributeControlType.Datepicker ||
productAttributeMapping.AttributeControlType == AttributeControlType.FileUpload)
return false;
//other attribute control types support values
return true;
}
///
/// A value indicating whether this product attribute can be used as condition for some other attribute
///
/// Product attribute mapping
/// Result
public static bool CanBeUsedAsCondition(this ProductAttributeMapping productAttributeMapping)
{
if (productAttributeMapping == null)
return false;
if (productAttributeMapping.AttributeControlType == AttributeControlType.ReadonlyCheckboxes ||
productAttributeMapping.AttributeControlType == AttributeControlType.TextBox ||
productAttributeMapping.AttributeControlType == AttributeControlType.MultilineTextbox ||
productAttributeMapping.AttributeControlType == AttributeControlType.Datepicker ||
productAttributeMapping.AttributeControlType == AttributeControlType.FileUpload)
return false;
//other attribute control types support it
return true;
}
///
/// A value indicating whether this product attribute should can have some validation rules
///
/// Product attribute mapping
/// Result
public static bool ValidationRulesAllowed(this ProductAttributeMapping productAttributeMapping)
{
if (productAttributeMapping == null)
return false;
if (productAttributeMapping.AttributeControlType == AttributeControlType.TextBox ||
productAttributeMapping.AttributeControlType == AttributeControlType.MultilineTextbox ||
productAttributeMapping.AttributeControlType == AttributeControlType.FileUpload)
return true;
//other attribute control types does not have validation
return false;
}
///
/// A value indicating whether this product attribute is non-combinable
///
/// Product attribute mapping
/// Result
public static bool IsNonCombinable(this ProductAttributeMapping productAttributeMapping)
{
//When you have a product with several attributes it may well be that some are combinable,
//whose combination may form a new SKU with its own inventory,
//and some non-combinable are more used to add accessories
if (productAttributeMapping == null)
return false;
//we can add a new property to "ProductAttributeMapping" entity indicating whether it's combinable/non-combinable
//but we assume that attributes
//which cannot have values (any value can be entered by a customer)
//are non-combinable
var result = !ShouldHaveValues(productAttributeMapping);
return result;
}
}