本文整理汇总了C#中IProductVariant.AddToCatalogInventory方法的典型用法代码示例。如果您正苦于以下问题:C# IProductVariant.AddToCatalogInventory方法的具体用法?C# IProductVariant.AddToCatalogInventory怎么用?C# IProductVariant.AddToCatalogInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProductVariant
的用法示例。
在下文中一共展示了IProductVariant.AddToCatalogInventory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToCatalog
/// <summary>
/// Adds the variants to the catalog.
/// </summary>
/// <param name="variant">
/// The variant.
/// </param>
private void AddToCatalog(IProductVariant variant)
{
var matching = this.GetOrignalMatchingVariant(variant);
var catalogKeys = matching.CatalogInventories.Select(x => x.CatalogKey).ToArray();
foreach (var key in catalogKeys)
{
if (variant.CatalogInventories.All(x => x.CatalogKey != key))
{
var catalog = _warehouseCatalogs.Value.FirstOrDefault(x => x.Key == key);
if (catalog != null) variant.AddToCatalogInventory(catalog);
}
}
}
示例2: ToProductVariant
internal static IProductVariant ToProductVariant(this ProductVariantDisplay productVariantDisplay, IProductVariant destination)
{
if (productVariantDisplay.Key != Guid.Empty)
{
destination.Key = productVariantDisplay.Key;
}
if( !String.IsNullOrEmpty(productVariantDisplay.Name) )
{
destination.Name = productVariantDisplay.Name;
}
if( !String.IsNullOrEmpty(productVariantDisplay.Sku) )
{
destination.Sku = productVariantDisplay.Sku;
}
destination.Price = productVariantDisplay.Price;
destination.CostOfGoods = productVariantDisplay.CostOfGoods;
destination.SalePrice = productVariantDisplay.SalePrice;
destination.OnSale = productVariantDisplay.OnSale;
destination.Manufacturer = productVariantDisplay.Manufacturer;
destination.ManufacturerModelNumber = productVariantDisplay.ManufacturerModelNumber;
destination.Weight = productVariantDisplay.Weight;
destination.Length = productVariantDisplay.Length;
destination.Width = productVariantDisplay.Width;
destination.Height = productVariantDisplay.Height;
destination.Barcode = productVariantDisplay.Barcode;
destination.Available = productVariantDisplay.Available;
destination.TrackInventory = productVariantDisplay.TrackInventory;
destination.OutOfStockPurchase = productVariantDisplay.OutOfStockPurchase;
destination.Taxable = productVariantDisplay.Taxable;
destination.Shippable = productVariantDisplay.Shippable;
destination.Download = productVariantDisplay.Download;
destination.DownloadMediaId = productVariantDisplay.DownloadMediaId;
destination.ProductKey = productVariantDisplay.ProductKey;
// We need to refactor the CatalogInventories to not be immutable if we are
// going to need to do operations like this. In the UI, the user "unchecks" a catalog that was
// previously checked - so we need to remove it.
var deletedCatalogKeys =
destination.CatalogInventories.Where(
x => !productVariantDisplay.CatalogInventories.Select(ci => ci.CatalogKey).Contains(x.CatalogKey)).Select(x => x.CatalogKey).ToArray();
foreach (var deletedCatalogKey in deletedCatalogKeys)
{
destination.RemoveFromCatalogInventory(deletedCatalogKey);
}
foreach (var catalogInventory in productVariantDisplay.CatalogInventories)
{
var catInv = destination.CatalogInventories.FirstOrDefault(x => x.CatalogKey == catalogInventory.CatalogKey);
if (catInv != null)
{
var destinationCatalogInventory = catInv;
destinationCatalogInventory = catalogInventory.ToCatalogInventory(destinationCatalogInventory);
}
else if (!Guid.Empty.Equals(catalogInventory.CatalogKey) && destination.HasIdentity)
{
//// Add to a new catalog
destination.AddToCatalogInventory(catalogInventory.CatalogKey);
}
}
foreach (var attribute in productVariantDisplay.Attributes)
{
IProductAttribute destinationProductAttribute;
var attr = destination.Attributes.FirstOrDefault(x => x.Key == attribute.Key);
if (attr != null)
{
destinationProductAttribute = attr;
destinationProductAttribute = attribute.ToProductAttribute(destinationProductAttribute);
}
else
{
destinationProductAttribute = new ProductAttribute(attribute.Name, attribute.Sku);
destinationProductAttribute = attribute.ToProductAttribute(destinationProductAttribute);
ProductAttributeCollection variantAttributes = destination.Attributes as ProductAttributeCollection;
variantAttributes.Add(destinationProductAttribute);
}
}
destination.AddOrUpdateDetachedContent(productVariantDisplay);
return destination;
}
示例3: ToProductVariant
internal static IProductVariant ToProductVariant(this ProductVariantDisplay productVariantDisplay, IProductVariant destination)
{
if (productVariantDisplay.Key != Guid.Empty)
{
destination.Key = productVariantDisplay.Key;
}
if( !String.IsNullOrEmpty(productVariantDisplay.Name) )
{
destination.Name = productVariantDisplay.Name;
}
if( !String.IsNullOrEmpty(productVariantDisplay.Sku) )
{
destination.Sku = productVariantDisplay.Sku;
}
destination.Price = productVariantDisplay.Price;
destination.CostOfGoods = productVariantDisplay.CostOfGoods;
destination.SalePrice = productVariantDisplay.SalePrice;
destination.OnSale = productVariantDisplay.OnSale;
destination.Manufacturer = productVariantDisplay.Manufacturer;
destination.ManufacturerModelNumber = productVariantDisplay.ManufacturerModelNumber;
destination.Weight = productVariantDisplay.Weight;
destination.Length = productVariantDisplay.Length;
destination.Width = productVariantDisplay.Width;
destination.Height = productVariantDisplay.Height;
destination.Barcode = productVariantDisplay.Barcode;
destination.Available = productVariantDisplay.Available;
destination.TrackInventory = productVariantDisplay.TrackInventory;
destination.OutOfStockPurchase = productVariantDisplay.OutOfStockPurchase;
destination.Taxable = productVariantDisplay.Taxable;
destination.Shippable = productVariantDisplay.Shippable;
destination.Download = productVariantDisplay.Download;
destination.DownloadMediaId = productVariantDisplay.DownloadMediaId;
destination.ProductKey = productVariantDisplay.ProductKey;
foreach (var catalogInventory in productVariantDisplay.CatalogInventories)
{
var catInv = destination.CatalogInventories.FirstOrDefault(x => x.CatalogKey == catalogInventory.CatalogKey);
if (catInv != null)
{
var destinationCatalogInventory = catInv;
destinationCatalogInventory = catalogInventory.ToCatalogInventory(destinationCatalogInventory);
}
else if (!Guid.Empty.Equals(catalogInventory.CatalogKey) && destination.HasIdentity)
{
//// Add to a new catalog
destination.AddToCatalogInventory(catalogInventory.CatalogKey);
}
}
foreach (var attribute in productVariantDisplay.Attributes)
{
IProductAttribute destinationProductAttribute;
var attr = destination.Attributes.First(x => x.Key == attribute.Key);
if (attr != null)
{
destinationProductAttribute = attr;
destinationProductAttribute = attribute.ToProductAttribute(destinationProductAttribute);
}
else
{
destinationProductAttribute = new ProductAttribute(attribute.Name, attribute.Sku);
destinationProductAttribute = attribute.ToProductAttribute(destinationProductAttribute);
ProductAttributeCollection variantAttributes = destination.Attributes as ProductAttributeCollection;
variantAttributes.Add(destinationProductAttribute);
}
}
return destination;
}