|
|
|
@ -47,31 +47,42 @@ namespace EasyAbp.EShop.Products |
|
|
|
var product = new Product(ProductsTestData.Product1Id, null, ProductsTestData.Store1Id, "Default", |
|
|
|
productDetail1.Id, "Cake", "Cake", InventoryStrategy.NoNeed, true, false, false, null, null, 0); |
|
|
|
|
|
|
|
var attribute = new ProductAttribute(ProductsTestData.Product1Attribute1Id, "Size", null); |
|
|
|
var attribute1 = new ProductAttribute(ProductsTestData.Product1Attribute1Id, "Size", null, 2); |
|
|
|
var attribute2 = new ProductAttribute(ProductsTestData.Product1Attribute2Id, "Color", null, 1); |
|
|
|
|
|
|
|
attribute.ProductAttributeOptions.AddRange(new[] |
|
|
|
attribute1.ProductAttributeOptions.AddRange(new[] |
|
|
|
{ |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option1Id, "S", null), |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option2Id, "M", null), |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option3Id, "L", null), |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option4Id, "XL", null) |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option4Id, "XL", null, 1), |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option2Id, "M", null, 3), |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option1Id, "S", null, 4), |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option3Id, "L", null, 2), |
|
|
|
}); |
|
|
|
|
|
|
|
product.ProductAttributes.Add(attribute); |
|
|
|
|
|
|
|
attribute2.ProductAttributeOptions.AddRange(new[] |
|
|
|
{ |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute2Option2Id, "Green", null, 1), |
|
|
|
new ProductAttributeOption(ProductsTestData.Product1Attribute2Option1Id, "Red", null, 2), |
|
|
|
}); |
|
|
|
|
|
|
|
product.ProductAttributes.Add(attribute2); |
|
|
|
product.ProductAttributes.Add(attribute1); |
|
|
|
|
|
|
|
await _productManager.CreateAsync(product); |
|
|
|
|
|
|
|
var productSku1 = new ProductSku(ProductsTestData.Product1Sku1Id, |
|
|
|
await _attributeOptionIdsSerializer.SerializeAsync(new[] |
|
|
|
{ ProductsTestData.Product1Attribute1Option1Id }), null, "CNY", null, 1m, 1, 10, null, null, null); |
|
|
|
|
|
|
|
{ ProductsTestData.Product1Attribute1Option1Id, ProductsTestData.Product1Attribute2Option1Id }), |
|
|
|
null, "CNY", null, 1m, 1, 10, null, null, null); |
|
|
|
|
|
|
|
var productSku2 = new ProductSku(ProductsTestData.Product1Sku2Id, |
|
|
|
await _attributeOptionIdsSerializer.SerializeAsync(new[] |
|
|
|
{ ProductsTestData.Product1Attribute1Option2Id }), null, "CNY", null, 2m, 1, 10, null, null, null); |
|
|
|
|
|
|
|
{ ProductsTestData.Product1Attribute1Option2Id, ProductsTestData.Product1Attribute2Option1Id }), |
|
|
|
null, "CNY", null, 2m, 1, 10, null, null, null); |
|
|
|
|
|
|
|
var productSku3 = new ProductSku(ProductsTestData.Product1Sku3Id, |
|
|
|
await _attributeOptionIdsSerializer.SerializeAsync(new[] |
|
|
|
{ ProductsTestData.Product1Attribute1Option3Id }), null, "CNY", null, 3m, 1, 10, null, null, null); |
|
|
|
{ ProductsTestData.Product1Attribute1Option3Id, ProductsTestData.Product1Attribute2Option2Id }), |
|
|
|
null, "CNY", null, 3m, 1, 10, null, null, null); |
|
|
|
|
|
|
|
await _productManager.CreateSkuAsync(product, productSku1); |
|
|
|
await _productManager.CreateSkuAsync(product, productSku2); |
|
|
|
|