public void Can_save_and_load_productVariantAttribute() { var pva = new ProductVariantAttribute { TextPrompt = "TextPrompt 1", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, Product = GetTestProduct(), ProductAttribute = new ProductAttribute() { Name = "Name 1", Description = "Description 1", } }; var fromDb = SaveAndLoadEntity(pva); fromDb.ShouldNotBeNull(); fromDb.TextPrompt.ShouldEqual("TextPrompt 1"); fromDb.IsRequired.ShouldEqual(true); fromDb.AttributeControlType.ShouldEqual(AttributeControlType.DropdownList); fromDb.DisplayOrder.ShouldEqual(1); fromDb.Product.ShouldNotBeNull(); fromDb.ProductAttribute.ShouldNotBeNull(); fromDb.ProductAttribute.Name.ShouldEqual("Name 1"); }
public void Can_save_and_load_productVariantAttribute() { var pva = new ProductVariantAttribute { TextPrompt = "TextPrompt 1", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, ProductVariant = new ProductVariant() { Name = "Product variant name 1", CreatedOnUtc = new DateTime(2010, 01, 03), UpdatedOnUtc = new DateTime(2010, 01, 04), Product = new Product() { Name = "Name 1", Published = true, Deleted = false, CreatedOnUtc = new DateTime(2010, 01, 01), UpdatedOnUtc = new DateTime(2010, 01, 02), } }, ProductAttribute = new ProductAttribute() { Name = "Name 1", Description = "Description 1", } }; var fromDb = SaveAndLoadEntity(pva); fromDb.ShouldNotBeNull(); fromDb.TextPrompt.ShouldEqual("TextPrompt 1"); fromDb.IsRequired.ShouldEqual(true); fromDb.AttributeControlType.ShouldEqual(AttributeControlType.DropdownList); fromDb.DisplayOrder.ShouldEqual(1); fromDb.ProductVariant.ShouldNotBeNull(); fromDb.ProductVariant.Name.ShouldEqual("Product variant name 1"); fromDb.ProductAttribute.ShouldNotBeNull(); fromDb.ProductAttribute.Name.ShouldEqual("Name 1"); }
public void Can_save_and_load_productVariantAttribute() { var pva = new ProductVariantAttribute { TextPrompt = "TextPrompt 1", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, ValidationMinLength = 2, ValidationMaxLength = 3, ValidationFileAllowedExtensions = "ValidationFileAllowedExtensions 1", ValidationFileMaximumSize = 4, DefaultValue = "DefaultValue 1", Product = GetTestProduct(), ProductAttribute = new ProductAttribute() { Name = "Name 1", Description = "Description 1", } }; var fromDb = SaveAndLoadEntity(pva); fromDb.ShouldNotBeNull(); fromDb.TextPrompt.ShouldEqual("TextPrompt 1"); fromDb.IsRequired.ShouldEqual(true); fromDb.AttributeControlType.ShouldEqual(AttributeControlType.DropdownList); fromDb.DisplayOrder.ShouldEqual(1); fromDb.ValidationMinLength.ShouldEqual(2); fromDb.ValidationMaxLength.ShouldEqual(3); fromDb.ValidationFileAllowedExtensions.ShouldEqual("ValidationFileAllowedExtensions 1"); fromDb.ValidationFileMaximumSize.ShouldEqual(4); fromDb.DefaultValue.ShouldEqual("DefaultValue 1"); fromDb.Product.ShouldNotBeNull(); fromDb.ProductAttribute.ShouldNotBeNull(); fromDb.ProductAttribute.Name.ShouldEqual("Name 1"); }
/// <summary> /// Deletes a product variant attribute mapping /// </summary> /// <param name="productVariantAttribute">Product variant attribute mapping</param> public virtual void DeleteProductVariantAttribute(ProductVariantAttribute productVariantAttribute) { if (productVariantAttribute == null) throw new ArgumentNullException("productVariantAttribute"); _productVariantAttributeRepository.Delete(productVariantAttribute); _cacheManager.RemoveByPattern(PRODUCTATTRIBUTES_PATTERN_KEY); _cacheManager.RemoveByPattern(PRODUCTVARIANTATTRIBUTES_PATTERN_KEY); _cacheManager.RemoveByPattern(PRODUCTVARIANTATTRIBUTEVALUES_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(productVariantAttribute); }
/// <summary> /// Create a copy of product variant with all depended data /// </summary> /// <param name="productVariant">The product variant to copy</param> /// <param name="productId">The product identifier</param> /// <param name="newName">The name of product variant duplicate</param> /// <param name="isPublished">A value indicating whether the product variant duplicate should be published</param> /// <param name="copyImage">A value indicating whether the product variant image should be copied</param> /// <returns>Product variant copy</returns> public virtual ProductVariant CopyProductVariant(ProductVariant productVariant, int productId, string newName, bool isPublished, bool copyImage) { if (productVariant == null) throw new ArgumentNullException("productVariant"); var languages = _languageService.GetAllLanguages(true); // product variant picture int pictureId = 0; if (copyImage) { var picture = _pictureService.GetPictureById(productVariant.PictureId); if (picture != null) { var pictureCopy = _pictureService.InsertPicture( _pictureService.LoadPictureBinary(picture), picture.MimeType, _pictureService.GetPictureSeName(productVariant.Name), true); pictureId = pictureCopy.Id; } } // product variant download & sample download int downloadId = productVariant.DownloadId; int sampleDownloadId = productVariant.SampleDownloadId; if (productVariant.IsDownload) { var download = _downloadService.GetDownloadById(productVariant.DownloadId); if (download != null) { var downloadCopy = new Download() { DownloadGuid = Guid.NewGuid(), UseDownloadUrl = download.UseDownloadUrl, DownloadUrl = download.DownloadUrl, DownloadBinary = download.DownloadBinary, ContentType = download.ContentType, Filename = download.Filename, Extension = download.Extension, IsNew = download.IsNew, }; _downloadService.InsertDownload(downloadCopy); downloadId = downloadCopy.Id; } if (productVariant.HasSampleDownload) { var sampleDownload = _downloadService.GetDownloadById(productVariant.SampleDownloadId); if (sampleDownload != null) { var sampleDownloadCopy = new Download() { DownloadGuid = Guid.NewGuid(), UseDownloadUrl = sampleDownload.UseDownloadUrl, DownloadUrl = sampleDownload.DownloadUrl, DownloadBinary = sampleDownload.DownloadBinary, ContentType = sampleDownload.ContentType, Filename = sampleDownload.Filename, Extension = sampleDownload.Extension, IsNew = sampleDownload.IsNew }; _downloadService.InsertDownload(sampleDownloadCopy); sampleDownloadId = sampleDownloadCopy.Id; } } } // product variant var productVariantCopy = new ProductVariant() { ProductId = productId, Name = newName, Sku = productVariant.Sku, Description = productVariant.Description, AdminComment = productVariant.AdminComment, ManufacturerPartNumber = productVariant.ManufacturerPartNumber, Gtin = productVariant.Gtin, IsGiftCard = productVariant.IsGiftCard, GiftCardType = productVariant.GiftCardType, RequireOtherProducts = productVariant.RequireOtherProducts, RequiredProductVariantIds = productVariant.RequiredProductVariantIds, AutomaticallyAddRequiredProductVariants = productVariant.AutomaticallyAddRequiredProductVariants, IsDownload = productVariant.IsDownload, DownloadId = downloadId, UnlimitedDownloads = productVariant.UnlimitedDownloads, MaxNumberOfDownloads = productVariant.MaxNumberOfDownloads, DownloadExpirationDays = productVariant.DownloadExpirationDays, DownloadActivationType = productVariant.DownloadActivationType, HasSampleDownload = productVariant.HasSampleDownload, SampleDownloadId = sampleDownloadId, HasUserAgreement = productVariant.HasUserAgreement, UserAgreementText = productVariant.UserAgreementText, IsRecurring = productVariant.IsRecurring, RecurringCycleLength = productVariant.RecurringCycleLength, RecurringCyclePeriod = productVariant.RecurringCyclePeriod, RecurringTotalCycles = productVariant.RecurringTotalCycles, IsShipEnabled = productVariant.IsShipEnabled, IsFreeShipping = productVariant.IsFreeShipping, AdditionalShippingCharge = productVariant.AdditionalShippingCharge, IsTaxExempt = productVariant.IsTaxExempt, TaxCategoryId = productVariant.TaxCategoryId, ManageInventoryMethod = productVariant.ManageInventoryMethod, StockQuantity = productVariant.StockQuantity, DisplayStockAvailability = productVariant.DisplayStockAvailability, DisplayStockQuantity = productVariant.DisplayStockQuantity, MinStockQuantity = productVariant.MinStockQuantity, LowStockActivityId = productVariant.LowStockActivityId, NotifyAdminForQuantityBelow = productVariant.NotifyAdminForQuantityBelow, BackorderMode = productVariant.BackorderMode, AllowBackInStockSubscriptions = productVariant.AllowBackInStockSubscriptions, OrderMinimumQuantity = productVariant.OrderMinimumQuantity, OrderMaximumQuantity = productVariant.OrderMaximumQuantity, AllowedQuantities = productVariant.AllowedQuantities, DisableBuyButton = productVariant.DisableBuyButton, DisableWishlistButton = productVariant.DisableWishlistButton, CallForPrice = productVariant.CallForPrice, Price = productVariant.Price, OldPrice = productVariant.OldPrice, ProductCost = productVariant.ProductCost, SpecialPrice = productVariant.SpecialPrice, SpecialPriceStartDateTimeUtc = productVariant.SpecialPriceStartDateTimeUtc, SpecialPriceEndDateTimeUtc = productVariant.SpecialPriceEndDateTimeUtc, CustomerEntersPrice = productVariant.CustomerEntersPrice, MinimumCustomerEnteredPrice = productVariant.MinimumCustomerEnteredPrice, MaximumCustomerEnteredPrice = productVariant.MaximumCustomerEnteredPrice, Weight = productVariant.Weight, Length = productVariant.Length, Width = productVariant.Width, Height = productVariant.Height, PictureId = pictureId, AvailableStartDateTimeUtc = productVariant.AvailableStartDateTimeUtc, AvailableEndDateTimeUtc = productVariant.AvailableEndDateTimeUtc, Published = isPublished, Deleted = productVariant.Deleted, DisplayOrder = productVariant.DisplayOrder, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; _productService.InsertProductVariant(productVariantCopy); //localization foreach (var lang in languages) { var name = productVariant.GetLocalized(x => x.Name, lang.Id, false, false); if (!String.IsNullOrEmpty(name)) _localizedEntityService.SaveLocalizedValue(productVariantCopy, x => x.Name, name, lang.Id); var description = productVariant.GetLocalized(x => x.Description, lang.Id, false, false); if (!String.IsNullOrEmpty(description)) _localizedEntityService.SaveLocalizedValue(productVariantCopy, x => x.Description, description, lang.Id); } // product variant <-> attributes mappings var associatedAttributes = new Dictionary<int, int>(); var associatedAttributeValues = new Dictionary<int, int>(); foreach (var productVariantAttribute in _productAttributeService.GetProductVariantAttributesByProductVariantId(productVariant.Id)) { var productVariantAttributeCopy = new ProductVariantAttribute() { ProductVariantId = productVariantCopy.Id, ProductAttributeId = productVariantAttribute.ProductAttributeId, TextPrompt = productVariantAttribute.TextPrompt, IsRequired = productVariantAttribute.IsRequired, AttributeControlTypeId = productVariantAttribute.AttributeControlTypeId, DisplayOrder = productVariantAttribute.DisplayOrder }; _productAttributeService.InsertProductVariantAttribute(productVariantAttributeCopy); //save associated value (used for combinations copying) associatedAttributes.Add(productVariantAttribute.Id, productVariantAttributeCopy.Id); // product variant attribute values var productVariantAttributeValues = _productAttributeService.GetProductVariantAttributeValues(productVariantAttribute.Id); foreach (var productVariantAttributeValue in productVariantAttributeValues) { var pvavCopy = new ProductVariantAttributeValue() { ProductVariantAttributeId = productVariantAttributeCopy.Id, Name = productVariantAttributeValue.Name, ColorSquaresRgb = productVariantAttributeValue.ColorSquaresRgb, PriceAdjustment = productVariantAttributeValue.PriceAdjustment, WeightAdjustment = productVariantAttributeValue.WeightAdjustment, IsPreSelected = productVariantAttributeValue.IsPreSelected, DisplayOrder = productVariantAttributeValue.DisplayOrder }; _productAttributeService.InsertProductVariantAttributeValue(pvavCopy); //save associated value (used for combinations copying) associatedAttributeValues.Add(productVariantAttributeValue.Id, pvavCopy.Id); //localization foreach (var lang in languages) { var name = productVariantAttributeValue.GetLocalized(x => x.Name, lang.Id, false, false); if (!String.IsNullOrEmpty(name)) _localizedEntityService.SaveLocalizedValue(pvavCopy, x => x.Name, name, lang.Id); } } } foreach (var combination in _productAttributeService.GetAllProductVariantAttributeCombinations(productVariant.Id)) { //generate new AttributesXml according to new value IDs string newAttributesXml = ""; var parsedProductVariantAttributes = _productAttributeParser.ParseProductVariantAttributes(combination.AttributesXml); foreach (var oldPva in parsedProductVariantAttributes) { if (associatedAttributes.ContainsKey(oldPva.Id)) { int newPvaId = associatedAttributes[oldPva.Id]; var newPva = _productAttributeService.GetProductVariantAttributeById(newPvaId); if (newPva != null) { var oldPvaValuesStr = _productAttributeParser.ParseValues(combination.AttributesXml, oldPva.Id); foreach (var oldPvaValueStr in oldPvaValuesStr) { if (newPva.ShouldHaveValues()) { //attribute values int oldPvaValue = int.Parse(oldPvaValueStr); if (associatedAttributeValues.ContainsKey(oldPvaValue)) { int newPvavId = associatedAttributeValues[oldPvaValue]; var newPvav = _productAttributeService.GetProductVariantAttributeValueById(newPvavId); if (newPvav != null) { newAttributesXml = _productAttributeParser.AddProductAttribute(newAttributesXml, newPva, newPvav.Id.ToString()); } } } else { //just a text newAttributesXml = _productAttributeParser.AddProductAttribute(newAttributesXml, newPva, oldPvaValueStr); } } } } } var combinationCopy = new ProductVariantAttributeCombination() { ProductVariantId = productVariantCopy.Id, AttributesXml = newAttributesXml, StockQuantity = combination.StockQuantity, AllowOutOfStockOrders = combination.AllowOutOfStockOrders, Sku = combination.Sku, ManufacturerPartNumber = combination.ManufacturerPartNumber, Gtin = combination.Gtin }; _productAttributeService.InsertProductVariantAttributeCombination(combinationCopy); } // product variant tier prices foreach (var tierPrice in productVariant.TierPrices) { _productService.InsertTierPrice( new TierPrice() { ProductVariantId = productVariantCopy.Id, CustomerRoleId = tierPrice.CustomerRoleId, Quantity = tierPrice.Quantity, Price = tierPrice.Price }); } // product variant <-> discounts mapping foreach (var discount in productVariant.AppliedDiscounts) { productVariantCopy.AppliedDiscounts.Add(discount); _productService.UpdateProductVariant(productVariantCopy); } //update "HasTierPrices" and "HasDiscountsApplied" properties _productService.UpdateHasTierPricesProperty(productVariantCopy); _productService.UpdateHasDiscountsApplied(productVariantCopy); return productVariantCopy; }
/// <summary> /// Creates a copy of product with all depended data /// </summary> /// <param name="productId">The product identifier</param> /// <param name="newName">The name of product duplicate</param> /// <param name="isPublished">A value indicating whether the product duplicate should be published</param> /// <param name="copyImages">A value indicating whether the product images should be copied</param> /// <returns>Product entity</returns> public Product CopyProduct(int productId, string newName, bool isPublished, bool copyImages) { var product = _productService.GetProductById(productId); if (product == null) throw new ArgumentException("No product found with the specified id", "productId"); Product productCopy = null; //uncomment this line to support transactions //using (var scope = new System.Transactions.TransactionScope()) { // product productCopy = new Product() { Name = newName, ShortDescription = product.ShortDescription, FullDescription = product.FullDescription, ProductTemplateId = product.ProductTemplateId, AdminComment = product.AdminComment, ShowOnHomePage = product.ShowOnHomePage, MetaKeywords = product.MetaKeywords, MetaDescription = product.MetaDescription, MetaTitle = product.MetaTitle, SeName = product.SeName, AllowCustomerReviews = product.AllowCustomerReviews, Published = isPublished, Deleted = product.Deleted, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; _productService.InsertProduct(productCopy); var languages = _languageService.GetAllLanguages(true); //localization foreach (var lang in languages) { var name = product.GetLocalized(x => x.Name, lang.Id, false, false); if (!String.IsNullOrEmpty(name)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.Name, name, lang.Id); var shortDescription = product.GetLocalized(x => x.ShortDescription, lang.Id, false, false); if (!String.IsNullOrEmpty(shortDescription)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.ShortDescription, shortDescription, lang.Id); var fullDescription = product.GetLocalized(x => x.FullDescription, lang.Id, false, false); if (!String.IsNullOrEmpty(fullDescription)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.FullDescription, fullDescription, lang.Id); var metaKeywords = product.GetLocalized(x => x.MetaKeywords, lang.Id, false, false); if (!String.IsNullOrEmpty(metaKeywords)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.MetaKeywords, metaKeywords, lang.Id); var metaDescription = product.GetLocalized(x => x.MetaDescription, lang.Id, false, false); if (!String.IsNullOrEmpty(metaDescription)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.MetaDescription, metaDescription, lang.Id); var metaTitle = product.GetLocalized(x => x.MetaTitle, lang.Id, false, false); if (!String.IsNullOrEmpty(metaTitle)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.MetaTitle, metaTitle, lang.Id); var seName = product.GetLocalized(x => x.SeName, lang.Id, false, false); if (!String.IsNullOrEmpty(seName)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.SeName, seName, lang.Id); } //product tags foreach (var productTag in product.ProductTags) { productCopy.ProductTags.Add(productTag); } //ensure product is saved before updating totals _productService.UpdateProduct(product); foreach (var productTag in product.ProductTags) { _productTagService.UpdateProductTagTotals(productTag); } // product pictures if (copyImages) { foreach (var productPicture in product.ProductPictures) { var picture = productPicture.Picture; var pictureCopy = _pictureService.InsertPicture( _pictureService.LoadPictureBinary(picture), picture.MimeType, _pictureService.GetPictureSeName(newName), true); _productService.InsertProductPicture(new ProductPicture() { ProductId = productCopy.Id, PictureId = pictureCopy.Id, DisplayOrder = productPicture.DisplayOrder }); } } // product <-> categories mappings foreach (var productCategory in product.ProductCategories) { var productCategoryCopy = new ProductCategory() { ProductId = productCopy.Id, CategoryId = productCategory.CategoryId, IsFeaturedProduct = productCategory.IsFeaturedProduct, DisplayOrder = productCategory.DisplayOrder }; _categoryService.InsertProductCategory(productCategoryCopy); } // product <-> manufacturers mappings foreach (var productManufacturers in product.ProductManufacturers) { var productManufacturerCopy = new ProductManufacturer() { ProductId = productCopy.Id, ManufacturerId = productManufacturers.ManufacturerId, IsFeaturedProduct = productManufacturers.IsFeaturedProduct, DisplayOrder = productManufacturers.DisplayOrder }; _manufacturerService.InsertProductManufacturer(productManufacturerCopy); } // product <-> releated products mappings foreach (var relatedProduct in _productService.GetRelatedProductsByProductId1(product.Id, true)) { _productService.InsertRelatedProduct( new RelatedProduct() { ProductId1 = productCopy.Id, ProductId2 = relatedProduct.ProductId2, DisplayOrder = relatedProduct.DisplayOrder }); } // product <-> cross sells mappings foreach (var csProduct in _productService.GetCrossSellProductsByProductId1(product.Id, true)) { _productService.InsertCrossSellProduct( new CrossSellProduct() { ProductId1 = productCopy.Id, ProductId2 = csProduct.ProductId2, }); } // product specifications foreach (var productSpecificationAttribute in product.ProductSpecificationAttributes) { var psaCopy = new ProductSpecificationAttribute() { ProductId = productCopy.Id, SpecificationAttributeOptionId = productSpecificationAttribute.SpecificationAttributeOptionId, AllowFiltering = productSpecificationAttribute.AllowFiltering, ShowOnProductPage = productSpecificationAttribute.ShowOnProductPage, DisplayOrder = productSpecificationAttribute.DisplayOrder }; _specificationAttributeService.InsertProductSpecificationAttribute(psaCopy); } // product variants var productVariants = product.ProductVariants; foreach (var productVariant in productVariants) { // product variant picture int pictureId = 0; if (copyImages) { var picture = _pictureService.GetPictureById(productVariant.PictureId); if (picture != null) { var pictureCopy = _pictureService.InsertPicture( _pictureService.LoadPictureBinary(picture), picture.MimeType, _pictureService.GetPictureSeName(productVariant.Name), true); pictureId = pictureCopy.Id; } } // product variant download & sample download int downloadId = productVariant.DownloadId; int sampleDownloadId = productVariant.SampleDownloadId; if (productVariant.IsDownload) { var download = _downloadService.GetDownloadById(productVariant.DownloadId); if (download != null) { var downloadCopy = new Download() { DownloadGuid = Guid.NewGuid(), UseDownloadUrl = download.UseDownloadUrl, DownloadUrl = download.DownloadUrl, DownloadBinary = download.DownloadBinary, ContentType = download.ContentType, Filename = download.Filename, Extension = download.Extension, IsNew = download.IsNew, }; _downloadService.InsertDownload(downloadCopy); downloadId = downloadCopy.Id; } if (productVariant.HasSampleDownload) { var sampleDownload = _downloadService.GetDownloadById(productVariant.SampleDownloadId); if (sampleDownload != null) { var sampleDownloadCopy = new Download() { DownloadGuid = Guid.NewGuid(), UseDownloadUrl = sampleDownload.UseDownloadUrl, DownloadUrl = sampleDownload.DownloadUrl, DownloadBinary = sampleDownload.DownloadBinary, ContentType = sampleDownload.ContentType, Filename = sampleDownload.Filename, Extension = sampleDownload.Extension, IsNew = sampleDownload.IsNew }; _downloadService.InsertDownload(sampleDownloadCopy); sampleDownloadId = sampleDownloadCopy.Id; } } } // product variant var productVariantCopy = new ProductVariant() { ProductId = productCopy.Id, Name = productVariant.Name, Sku = productVariant.Sku, Description = productVariant.Description, AdminComment = productVariant.AdminComment, ManufacturerPartNumber = productVariant.ManufacturerPartNumber, Gtin = productVariant.Gtin, IsGiftCard = productVariant.IsGiftCard, GiftCardType = productVariant.GiftCardType, RequireOtherProducts = productVariant.RequireOtherProducts, RequiredProductVariantIds = productVariant.RequiredProductVariantIds, AutomaticallyAddRequiredProductVariants = productVariant.AutomaticallyAddRequiredProductVariants, IsDownload = productVariant.IsDownload, DownloadId = downloadId, UnlimitedDownloads = productVariant.UnlimitedDownloads, MaxNumberOfDownloads = productVariant.MaxNumberOfDownloads, DownloadExpirationDays = productVariant.DownloadExpirationDays, DownloadActivationType = productVariant.DownloadActivationType, HasSampleDownload = productVariant.HasSampleDownload, SampleDownloadId = sampleDownloadId, HasUserAgreement = productVariant.HasUserAgreement, UserAgreementText = productVariant.UserAgreementText, IsRecurring = productVariant.IsRecurring, RecurringCycleLength = productVariant.RecurringCycleLength, RecurringCyclePeriod = productVariant.RecurringCyclePeriod, RecurringTotalCycles = productVariant.RecurringTotalCycles, IsShipEnabled = productVariant.IsShipEnabled, IsFreeShipping = productVariant.IsFreeShipping, AdditionalShippingCharge = productVariant.AdditionalShippingCharge, IsTaxExempt = productVariant.IsTaxExempt, TaxCategoryId = productVariant.TaxCategoryId, ManageInventoryMethod = productVariant.ManageInventoryMethod, StockQuantity = productVariant.StockQuantity, DisplayStockAvailability = productVariant.DisplayStockAvailability, DisplayStockQuantity = productVariant.DisplayStockQuantity, MinStockQuantity = productVariant.MinStockQuantity, LowStockActivityId = productVariant.LowStockActivityId, NotifyAdminForQuantityBelow = productVariant.NotifyAdminForQuantityBelow, BackorderMode = productVariant.BackorderMode, AllowBackInStockSubscriptions = productVariant.AllowBackInStockSubscriptions, OrderMinimumQuantity = productVariant.OrderMinimumQuantity, OrderMaximumQuantity = productVariant.OrderMaximumQuantity, AllowedQuantities = productVariant.AllowedQuantities, DisableBuyButton = productVariant.DisableBuyButton, DisableWishlistButton = productVariant.DisableWishlistButton, CallForPrice = productVariant.CallForPrice, Price = productVariant.Price, OldPrice = productVariant.OldPrice, ProductCost = productVariant.ProductCost, SpecialPrice = productVariant.SpecialPrice, SpecialPriceStartDateTimeUtc = productVariant.SpecialPriceStartDateTimeUtc, SpecialPriceEndDateTimeUtc = productVariant.SpecialPriceEndDateTimeUtc, CustomerEntersPrice = productVariant.CustomerEntersPrice, MinimumCustomerEnteredPrice = productVariant.MinimumCustomerEnteredPrice, MaximumCustomerEnteredPrice = productVariant.MaximumCustomerEnteredPrice, Weight = productVariant.Weight, Length = productVariant.Length, Width = productVariant.Width, Height = productVariant.Height, PictureId = pictureId, AvailableStartDateTimeUtc = productVariant.AvailableStartDateTimeUtc, AvailableEndDateTimeUtc = productVariant.AvailableEndDateTimeUtc, Published = productVariant.Published, Deleted = productVariant.Deleted, DisplayOrder = productVariant.DisplayOrder, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; _productService.InsertProductVariant(productVariantCopy); //localization foreach (var lang in languages) { var name = productVariant.GetLocalized(x => x.Name, lang.Id, false, false); if (!String.IsNullOrEmpty(name)) _localizedEntityService.SaveLocalizedValue(productVariantCopy, x => x.Name, name, lang.Id); var description = productVariant.GetLocalized(x => x.Description, lang.Id, false, false); if (!String.IsNullOrEmpty(description)) _localizedEntityService.SaveLocalizedValue(productVariantCopy, x => x.Description, description, lang.Id); } // product variant <-> attributes mappings var associatedAttributes = new Dictionary<int, int>(); var associatedAttributeValues = new Dictionary<int, int>(); foreach (var productVariantAttribute in _productAttributeService.GetProductVariantAttributesByProductVariantId(productVariant.Id)) { var productVariantAttributeCopy = new ProductVariantAttribute() { ProductVariantId = productVariantCopy.Id, ProductAttributeId = productVariantAttribute.ProductAttributeId, TextPrompt = productVariantAttribute.TextPrompt, IsRequired = productVariantAttribute.IsRequired, AttributeControlTypeId = productVariantAttribute.AttributeControlTypeId, DisplayOrder = productVariantAttribute.DisplayOrder }; _productAttributeService.InsertProductVariantAttribute(productVariantAttributeCopy); //save associated value (used for combinations copying) associatedAttributes.Add(productVariantAttribute.Id, productVariantAttributeCopy.Id); // product variant attribute values var productVariantAttributeValues = _productAttributeService.GetProductVariantAttributeValues(productVariantAttribute.Id); foreach (var productVariantAttributeValue in productVariantAttributeValues) { var pvavCopy = new ProductVariantAttributeValue() { ProductVariantAttributeId = productVariantAttributeCopy.Id, Name = productVariantAttributeValue.Name, PriceAdjustment = productVariantAttributeValue.PriceAdjustment, WeightAdjustment = productVariantAttributeValue.WeightAdjustment, IsPreSelected = productVariantAttributeValue.IsPreSelected, DisplayOrder = productVariantAttributeValue.DisplayOrder }; _productAttributeService.InsertProductVariantAttributeValue(pvavCopy); //save associated value (used for combinations copying) associatedAttributeValues.Add(productVariantAttributeValue.Id, pvavCopy.Id); //localization foreach (var lang in languages) { var name = productVariantAttributeValue.GetLocalized(x => x.Name, lang.Id, false, false); if (!String.IsNullOrEmpty(name)) _localizedEntityService.SaveLocalizedValue(pvavCopy, x => x.Name, name, lang.Id); } } } foreach (var combination in _productAttributeService.GetAllProductVariantAttributeCombinations(productVariant.Id)) { //generate new AttributesXml according to new value IDs string newAttributesXml = ""; var parsedProductVariantAttributes = _productAttributeParser.ParseProductVariantAttributes(combination.AttributesXml); foreach (var oldPva in parsedProductVariantAttributes) { if (associatedAttributes.ContainsKey(oldPva.Id)) { int newPvaId = associatedAttributes[oldPva.Id]; var newPva = _productAttributeService.GetProductVariantAttributeById(newPvaId); if (newPva != null) { var oldPvaValuesStr = _productAttributeParser.ParseValues(combination.AttributesXml, oldPva.Id); foreach (var oldPvaValueStr in oldPvaValuesStr) { if (newPva.ShouldHaveValues()) { //attribute values int oldPvaValue = int.Parse(oldPvaValueStr); if (associatedAttributeValues.ContainsKey(oldPvaValue)) { int newPvavId = associatedAttributeValues[oldPvaValue]; var newPvav = _productAttributeService.GetProductVariantAttributeValueById(newPvavId); if (newPvav != null) { newAttributesXml = _productAttributeParser.AddProductAttribute(newAttributesXml, newPva, newPvav.Id.ToString()); } } } else { //just a text newAttributesXml = _productAttributeParser.AddProductAttribute(newAttributesXml, newPva, oldPvaValueStr); } } } } } var combinationCopy = new ProductVariantAttributeCombination() { ProductVariantId = productVariantCopy.Id, AttributesXml = newAttributesXml, StockQuantity = combination.StockQuantity, AllowOutOfStockOrders = combination.AllowOutOfStockOrders }; _productAttributeService.InsertProductVariantAttributeCombination(combinationCopy); } // product variant tier prices foreach (var tierPrice in productVariant.TierPrices) { _productService.InsertTierPrice( new TierPrice() { ProductVariantId = productVariantCopy.Id, CustomerRoleId = tierPrice.CustomerRoleId, Quantity = tierPrice.Quantity, Price = tierPrice.Price }); } // product variant <-> discounts mapping foreach (var discount in productVariant.AppliedDiscounts) { productVariantCopy.AppliedDiscounts.Add(discount); _productService.UpdateProductVariant(productVariantCopy); } //update "HasTierPrices" and "HasDiscountsApplied" properties _productService.UpdateHasTierPricesProperty(productVariantCopy); _productService.UpdateHasDiscountsApplied(productVariantCopy); } //uncomment this line to support transactions //scope.Complete(); } return productCopy; }
public ActionResult ProductVariantAttributeInsert(ProductModel.ProductVariantAttributeModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); var product = _productService.GetProductById(model.ProductId); if (product == null) throw new ArgumentException("No product found with the specified id"); //a vendor should have access only to his products if (_workContext.CurrentVendor != null && product.VendorId != _workContext.CurrentVendor.Id) { return Content("This is not your product"); } var pva = new ProductVariantAttribute() { ProductId = model.ProductId, ProductAttributeId = model.ProductAttributeId, TextPrompt = model.TextPrompt, IsRequired = model.IsRequired, AttributeControlTypeId = model.AttributeControlTypeId, DisplayOrder = model.DisplayOrder }; _productAttributeService.InsertProductVariantAttribute(pva); return new NullJsonResult(); }
protected virtual void InstallProducts(string defaultUserEmail) { var productTemplateSimple = _productTemplateRepository.Table.FirstOrDefault(pt => pt.Name == "Simple product"); if (productTemplateSimple == null) throw new Exception("Simple product template could not be loaded"); var productTemplateGrouped = _productTemplateRepository.Table.FirstOrDefault(pt => pt.Name == "Grouped product"); if (productTemplateGrouped == null) throw new Exception("Simple product template could not be loaded"); //delivery date var deliveryDate = _deliveryDateRepository.Table.FirstOrDefault(); if (deliveryDate == null) throw new Exception("No default deliveryDate could be loaded"); //default customer/user var defaultCustomer = _customerRepository.Table.FirstOrDefault(x => x.Email == defaultUserEmail); if (defaultCustomer == null) throw new Exception("Cannot load default customer"); //pictures var pictureService = EngineContext.Current.Resolve<IPictureService>(); var sampleImagesPath = _webHelper.MapPath("~/content/samples/"); //downloads var downloadService = EngineContext.Current.Resolve<IDownloadService>(); var sampleDownloadsPath = _webHelper.MapPath("~/content/samples/"); //products var allProducts = new List<Product>(); var product5GiftCard = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "$5 Virtual Gift Card", ShortDescription = "$5 Gift Card. Gift Cards must be redeemed through our site Web site toward the purchase of eligible products.", FullDescription = "<p>Gift Cards must be redeemed through our site Web site toward the purchase of eligible products. Purchases are deducted from the GiftCard balance. Any unused balance will be placed in the recipient's GiftCard account when redeemed. If an order exceeds the amount of the GiftCard, the balance must be paid with a credit card or other available payment method.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "5-virtual-gift-card", AllowCustomerReviews = true, Price = 5M, IsGiftCard = true, GiftCardType = GiftCardType.Virtual, ManageInventoryMethod = ManageInventoryMethod.DontManageStock, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(product5GiftCard); product5GiftCard.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Gift Cards"), DisplayOrder = 1, }); product5GiftCard.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_5giftcart.jpeg"), "image/jpeg", pictureService.GetPictureSeName(product5GiftCard.Name), true), DisplayOrder = 1, }); _productRepository.Insert(product5GiftCard); var product25GiftCard = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "$25 Virtual Gift Card", ShortDescription = "$25 Gift Card. Gift Cards must be redeemed through our site Web site toward the purchase of eligible products.", FullDescription = "<p>Gift Cards must be redeemed through our site Web site toward the purchase of eligible products. Purchases are deducted from the GiftCard balance. Any unused balance will be placed in the recipient's GiftCard account when redeemed. If an order exceeds the amount of the GiftCard, the balance must be paid with a credit card or other available payment method.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "25-virtual-gift-card", AllowCustomerReviews = true, Price = 25M, IsGiftCard = true, GiftCardType = GiftCardType.Virtual, ManageInventoryMethod = ManageInventoryMethod.DontManageStock, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, Published = true, ShowOnHomePage = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(product25GiftCard); product25GiftCard.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Gift Cards"), DisplayOrder = 2, }); product25GiftCard.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_25giftcart.jpeg"), "image/jpeg", pictureService.GetPictureSeName(product25GiftCard.Name), true), DisplayOrder = 1, }); _productRepository.Insert(product25GiftCard); var product50GiftCard = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "$50 Physical Gift Card", ShortDescription = "$50 Gift Card. Gift Cards must be redeemed through our site Web site toward the purchase of eligible products.", FullDescription = "<p>Gift Cards must be redeemed through our site Web site toward the purchase of eligible products. Purchases are deducted from the GiftCard balance. Any unused balance will be placed in the recipient's GiftCard account when redeemed. If an order exceeds the amount of the GiftCard, the balance must be paid with a credit card or other available payment method.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "50-physical-gift-card", AllowCustomerReviews = true, Price = 50M, IsGiftCard = true, GiftCardType = GiftCardType.Physical, IsShipEnabled = true, IsFreeShipping = true, DeliveryDateId = deliveryDate.Id, Weight = 1, Length = 1, Width = 1, Height = 1, ManageInventoryMethod = ManageInventoryMethod.DontManageStock, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(product50GiftCard); product50GiftCard.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Gift Cards"), DisplayOrder = 3, }); product50GiftCard.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_50giftcart.jpeg"), "image/jpeg", pictureService.GetPictureSeName(product50GiftCard.Name), true), DisplayOrder = 1, }); _productRepository.Insert(product50GiftCard); var product100GiftCard = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "$100 Physical Gift Card", ShortDescription = "$100 Gift Card. Gift Cards must be redeemed through our site Web site toward the purchase of eligible products.", FullDescription = "<p>Gift Cards must be redeemed through our site Web site toward the purchase of eligible products. Purchases are deducted from the GiftCard balance. Any unused balance will be placed in the recipient's GiftCard account when redeemed. If an order exceeds the amount of the GiftCard, the balance must be paid with a credit card or other available payment method.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "100-physical-gift-card", AllowCustomerReviews = true, Price = 100M, IsGiftCard = true, GiftCardType = GiftCardType.Physical, IsShipEnabled = true, DeliveryDateId = deliveryDate.Id, Weight = 1, Length = 1, Width = 1, Height = 1, ManageInventoryMethod = ManageInventoryMethod.DontManageStock, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(product100GiftCard); product100GiftCard.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Gift Cards"), DisplayOrder = 4, }); product100GiftCard.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_100giftcart.jpeg"), "image/jpeg", pictureService.GetPictureSeName(product100GiftCard.Name), true), DisplayOrder = 1, }); _productRepository.Insert(product100GiftCard); var productRockabillyPolka = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "50's Rockabilly Polka Dot Top JR Plus Size", ShortDescription = "", FullDescription = "<p>Fitted polkadot print cotton top with tie cap sleeves.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "50s-rockabilly-polka-dot-top-jr-plus-size", AllowCustomerReviews = true, Published = true, Price = 15M, IsShipEnabled = true, Weight = 1, Length = 2, Width = 3, Height = 3, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productRockabillyPolka); var pvaRockabillyPolka1 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "Size"), AttributeControlType = AttributeControlType.DropdownList, IsRequired = true, }; pvaRockabillyPolka1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Small", DisplayOrder = 1, }); pvaRockabillyPolka1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "1X", DisplayOrder = 2, }); pvaRockabillyPolka1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "2X", DisplayOrder = 3, }); pvaRockabillyPolka1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "3X", DisplayOrder = 4, }); pvaRockabillyPolka1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "4X", DisplayOrder = 5, }); pvaRockabillyPolka1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "5X", DisplayOrder = 6, }); productRockabillyPolka.ProductVariantAttributes.Add(pvaRockabillyPolka1); productRockabillyPolka.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productRockabillyPolka.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_RockabillyPolka.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productRockabillyPolka.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productRockabillyPolka); var productAcerAspireOne = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Acer Aspire One 8.9\" Mini-Notebook Case - (Black)", ShortDescription = "Acer Aspire One 8.9\" Mini-Notebook and 6 Cell Battery model (AOA150-1447)", FullDescription = "<p>Acer Aspire One 8.9" Memory Foam Pouch is the perfect fit for Acer Aspire One 8.9". This pouch is made out of premium quality shock absorbing memory form and it provides extra protection even though case is very light and slim. This pouch is water resistant and has internal supporting bands for Acer Aspire One 8.9". Made In Korea.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "acer-aspire-one-89-mini-notebook-case-black", AllowCustomerReviews = true, Price = 21.6M, IsShipEnabled = true, IsFreeShipping = true, Weight = 2, Length = 2, Width = 2, Height = 3, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productAcerAspireOne); productAcerAspireOne.TierPrices.Add(new TierPrice() { Quantity = 2, Price = 19 }); productAcerAspireOne.TierPrices.Add(new TierPrice() { Quantity = 5, Price = 17 }); productAcerAspireOne.TierPrices.Add(new TierPrice() { Quantity = 10, Price = 15 }); productAcerAspireOne.HasTierPrices = true; productAcerAspireOne.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Accessories"), DisplayOrder = 1, }); productAcerAspireOne.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_AcerAspireOne_1.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productAcerAspireOne.Name), true), DisplayOrder = 1, }); productAcerAspireOne.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_AcerAspireOne_2.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productAcerAspireOne.Name), true), DisplayOrder = 2, }); _productRepository.Insert(productAcerAspireOne); var productAdidasShoe = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "adidas Women's Supernova CSH 7 Running Shoe", ShortDescription = "Now there are even more reasons to love this training favorite. An improved last, new step-in sockliner and the smooth control of 3-D ForMotion™ deliver a natural, balanced touchdown that feels better than ever.", FullDescription = "<p>Built to take you far and fast, Adidas Supernova Cushion 7 road-running shoes offer incredible cushioning and comfort with low weight. * Abrasion-resistant nylon mesh uppers are lightweight and highly breathable; synthetic leather overlays create structure and support * GeoFit construction at ankles provides an anatomically correct fit and extra comfort * Nylon linings and molded, antimicrobial dual-layer EVA footbeds dry quickly and fight odor * adiPRENE® midsoles absorb shock in the heels and help maximize heel protection and stability * adiPRENE®+ under forefeet retains natural propulsive forces for improved efficiency * Torsion® system at the midfoot allows natural rotation between the rearfoot and the forefoot, helping improve surface adaptability * ForMotion® freely moving, decoupled heel system allows your feet to adapt to the ground strike and adjust for forward momentum * adiWEAR® rubber outsoles give ample durability in high-wear areas and offer lightweight grip and cushion Mens shoes , men's shoes , running shoes , adidas shoes , adidas running shoes , mens running shoes , snova running shoes , snova mens adidas , snova adidas running , snova shoes , sport shoes mens , sport shoes adidas , mens shoes , men's shoes , running , adidas</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "adidas-womens-supernova-csh-7-running-shoe", AllowCustomerReviews = true, Price = 40M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productAdidasShoe); var pvaAdidasShoe1 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "Size"), AttributeControlType = AttributeControlType.DropdownList, IsRequired = true, }; pvaAdidasShoe1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "8", DisplayOrder = 1, }); pvaAdidasShoe1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "9", DisplayOrder = 2, }); pvaAdidasShoe1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "10", DisplayOrder = 3, }); pvaAdidasShoe1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "11", DisplayOrder = 4, }); productAdidasShoe.ProductVariantAttributes.Add(pvaAdidasShoe1); var pvaAdidasShoe2 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "Color"), AttributeControlType = AttributeControlType.DropdownList, IsRequired = true, }; pvaAdidasShoe2.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "White/Blue", DisplayOrder = 1, }); pvaAdidasShoe2.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "White/Black", DisplayOrder = 2, }); productAdidasShoe.ProductVariantAttributes.Add(pvaAdidasShoe2); productAdidasShoe.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productAdidasShoe.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_AdidasShoe_1.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productAdidasShoe.Name), true), DisplayOrder = 1, }); productAdidasShoe.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_AdidasShoe_2.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productAdidasShoe.Name), true), DisplayOrder = 2, }); _productRepository.Insert(productAdidasShoe); var productAdobePhotoshop = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Adobe Photoshop Elements 7", ShortDescription = "Easily find and view all your photos", FullDescription = "<p>Adobe Photoshop Elements 7 software combines power and simplicity so you can make ordinary photos extraordinary; tell engaging stories in beautiful, personalized creations for print and web; and easily find and view all your photos. New Photoshop.com membership* works with Photoshop Elements so you can protect your photos with automatic online backup and 2 GB of storage; view your photos anywhere you are; and share your photos in fun, interactive ways with invitation-only Online Albums.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "adobe-photoshop-elements-7", AllowCustomerReviews = true, Price = 75M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 3, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productAdobePhotoshop); productAdobePhotoshop.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Software & Games"), DisplayOrder = 1, }); productAdobePhotoshop.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_AdobePhotoshop.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productAdobePhotoshop.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productAdobePhotoshop); var productApcUps = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "APC Back-UPS RS 800VA - UPS - 800 VA - UPS battery - lead acid ( BR800BLK )", ShortDescription = "APC Back-UPS RS, 800VA/540W, Input 120V/Output 120V, Interface Port USB. ", FullDescription = "<p>The Back-UPS RS offers high performance protection for your business and office computer systems. It provides abundant battery backup power, allowing you to work through medium and extended length power outages. It also safeguards your equipment from damaging surges and spikes that travel along utility, phone and network lines. A distinguishing feature of the Back-UPS RS is automatic voltage regulation (AVR). AVR instantly adjusts both low and high voltages to safe levels, so you can work indefinitely during brownouts and overvoltage situations, saving the battery for power outages when you need it most. Award-winning shutdown software automatically powers down your computer system in the event of an extended power outage.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "apc-back-ups-rs-800va-ups-800-va-ups-battery-lead-acid-br800blk", AllowCustomerReviews = true, Price = 75M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 3, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productApcUps); productApcUps.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Accessories"), DisplayOrder = 1, }); productApcUps.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_ApcUps.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productApcUps.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productApcUps); var productArrow = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Arrow Men's Wrinkle Free Pinpoint Solid Long Sleeve", ShortDescription = "", FullDescription = "<p>This Wrinkle Free Pinpoint Long Sleeve Dress Shirt needs minimum ironing. It is a great product at a great value!</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "arrow-mens-wrinkle-free-pinpoint-solid-long-sleeve", AllowCustomerReviews = true, Price = 24M, IsShipEnabled = true, Weight = 4, Length = 3, Width = 3, Height = 3, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productArrow); productArrow.TierPrices.Add(new TierPrice() { Quantity = 3, Price = 21 }); productArrow.TierPrices.Add(new TierPrice() { Quantity = 7, Price = 19 }); productArrow.TierPrices.Add(new TierPrice() { Quantity = 10, Price = 16 }); productArrow.HasTierPrices = true; productArrow.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productArrow.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_arrow.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productArrow.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productArrow); var productAsusPc1000 = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "ASUS Eee PC 1000HA 10-Inch Netbook", ShortDescription = "Super Hybrid Engine offers a choice of performance and power consumption modes for easy adjustments according to various needs", FullDescription = "<p>Much more compact than a standard-sized notebook and weighing just over 3 pounds, the Eee PC 1000HA is perfect for students toting to school or road warriors packing away to Wi-Fi hotspots. The Eee PC 1000HA also features a 160 GB hard disk drive (HDD), 1 GB of RAM, 1.3-megapixel webcam integrated into the bezel above the LCD, 54g Wi-Fi networking (802.11b/g), Secure Digital memory card slot, multiple USB ports, a VGA output for connecting to a monitor.</p><p>It comes preinstalled with the Microsoft Windows XP Home operating system, which offers more experienced users an enhanced and innovative experience that incorporates Windows Live features like Windows Live Messenger for instant messaging and Windows Live Mail for consolidated email accounts on your desktop. Complementing this is Microsoft Works, which equips the user with numerous office applications to work efficiently.</p><p>The new Eee PC 1000HA has a customized, cutting-edge Infusion casing technology in Fine Ebony. Inlaid within the chassis itself, the motifs are an integral part of the entire cover and will not fade with time. The Infusion surface also provides a new level of resilience, providing scratch resistance and a beautiful style while out and about.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "asus-eee-pc-1000ha-10-inch-netbook", AllowCustomerReviews = true, Price = 2600M, IsShipEnabled = true, IsFreeShipping = true, Weight = 3, Length = 3, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productAsusPc1000); productAsusPc1000.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Notebooks"), DisplayOrder = 1, }); productAsusPc1000.ProductManufacturers.Add(new ProductManufacturer() { Manufacturer = _manufacturerRepository.Table.Single(c => c.Name == "ASUS"), DisplayOrder = 2, }); productAsusPc1000.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_asuspc1000.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productAsusPc1000.Name), true), DisplayOrder = 1, }); productAsusPc1000.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 1, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Screensize").SpecificationAttributeOptions.Single(sao => sao.Name == "10.0''") }); productAsusPc1000.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 2, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "CPU Type").SpecificationAttributeOptions.Single(sao => sao.Name == "AMD") }); productAsusPc1000.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 3, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Memory").SpecificationAttributeOptions.Single(sao => sao.Name == "1 GB") }); productAsusPc1000.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 4, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Hardrive").SpecificationAttributeOptions.Single(sao => sao.Name == "160 GB") }); _productRepository.Insert(productAsusPc1000); var productAsusPc900 = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "ASUS Eee PC 900HA 8.9-Inch Netbook Black", ShortDescription = "High Speed Connectivity Anywhere with Wi-Fi 802.11b/g.", FullDescription = "<p>Much more compact than a standard-sized notebook and weighing just 2.5 pounds, the Eee PC 900HA is perfect for students toting to school or road warriors packing away to Wi-Fi hotspots. In addition to the 160 GB hard disk drive (HDD), the Eee PC 900HA also features 1 GB of RAM, VGA-resolution webcam integrated into the bezel above the LCD, 54g Wi-Fi networking (802.11b/g), multiple USB ports, SD memory card slot, a VGA output for connecting to a monitor, and up to 10 GB of online storage (complimentary for 18 months).</p><p>It comes preinstalled with the Microsoft Windows XP Home operating system, which offers more experienced users an enhanced and innovative experience that incorporates Windows Live features like Windows Live Messenger for instant messaging and Windows Live Mail for consolidated email accounts on your desktop. Complementing this is Microsoft Works, which equips the user with numerous office applications to work efficiently.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "asus-eee-pc-900ha-89-inch-netbook-black", AllowCustomerReviews = true, Price = 1500M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productAsusPc900); productAsusPc900.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Notebooks"), DisplayOrder = 1, }); productAsusPc900.ProductManufacturers.Add(new ProductManufacturer() { Manufacturer = _manufacturerRepository.Table.Single(c => c.Name == "ASUS"), DisplayOrder = 1, }); productAsusPc900.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_asuspc900.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productAsusPc900.Name), true), DisplayOrder = 1, }); productAsusPc900.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 2, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "CPU Type").SpecificationAttributeOptions.Single(sao => sao.Name == "AMD") }); productAsusPc900.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 3, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Memory").SpecificationAttributeOptions.Single(sao => sao.Name == "1 GB") }); productAsusPc900.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 4, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Hardrive").SpecificationAttributeOptions.Single(sao => sao.Name == "160 GB") }); _productRepository.Insert(productAsusPc900); var productBestGrillingRecipes = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Best Grilling Recipes", ShortDescription = "More Than 100 Regional Favorites Tested and Perfected for the Outdoor Cook (Hardcover)", FullDescription = "<p>Take a winding cross-country trip and you'll discover barbecue shacks with offerings like tender-smoky Baltimore pit beef and saucy St. Louis pork steaks. To bring you the best of these hidden gems, along with all the classics, the editors of Cook's Country magazine scoured the country, then tested and perfected their favorites. HEre traditions large and small are brought into the backyard, from Hawaii's rotisserie favorite, the golden-hued Huli Huli Chicken, to fall-off-the-bone Chicago Barbecued Ribs. In Kansas City, they're all about the sauce, and for our saucy Kansas City Sticky Ribs, we found a surprise ingredient-root beer. We also tackle all the best sides. <br /><br />Not sure where or how to start? This cookbook kicks off with an easy-to-follow primer that will get newcomers all fired up. Whether you want to entertain a crowd or just want to learn to make perfect burgers, Best Grilling Recipes shows you the way.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "best-grilling-recipes", AllowCustomerReviews = true, Price = 27M, OldPrice = 30M, IsShipEnabled = true, IsFreeShipping = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Books").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productBestGrillingRecipes); productBestGrillingRecipes.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Books"), DisplayOrder = 1, }); productBestGrillingRecipes.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_BestGrillingRecipes.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productBestGrillingRecipes.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productBestGrillingRecipes); var productDiamondHeart = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Black & White Diamond Heart", ShortDescription = "Heart Pendant 1/4 Carat (ctw) in Sterling Silver", FullDescription = "<p>Bold black diamonds alternate with sparkling white diamonds along a crisp sterling silver heart to create a look that is simple and beautiful. This sleek and stunning 1/4 carat (ctw) diamond heart pendant which includes an 18 inch silver chain, and a free box of godiva chocolates makes the perfect Valentine's Day gift.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "black-white-diamond-heart", AllowCustomerReviews = true, Price = 130M, IsShipEnabled = true, IsFreeShipping = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Jewelry").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productDiamondHeart); productDiamondHeart.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Jewelry"), DisplayOrder = 1, }); productDiamondHeart.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_DiamondHeart.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productDiamondHeart.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productDiamondHeart); var productBlackBerry = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "BlackBerry Bold 9000 Phone, Black (AT&T)", ShortDescription = "Global Blackberry messaging smartphone with quad-band GSM", FullDescription = "<p>Keep yourself on track for your next meeting with turn-by-turn directions via the AT&T Navigator service, which is powered by TeleNav and provides spoken or text-based turn-by-turn directions with automatic missed turn rerouting and a local business finder service in 20 countries. It also supports AT&T mobile music services and access to thousands of video clips via Cellular Video. Other features include a 2-megapixel camera/camcorder, Bluetooth for handsfree communication, 1 GB of internal memory with MicroSD expansion (up to 32 GB), multi-format audio/video playback, and up to 4.5 hours of talk time.</p><p>The Blackberry Bold also comes with free access to AT&T Wi-Fi Hotspots, available at more than 17,000 locations nationwide including Starbucks. The best part is that you do'nt need to sign up for anything new to use this service--Wi-Fi access for is included in all Blackberry Personal and Enterprise Rate Plans. (You must subscribe to a Blackberry Data Rate Plan to access AT&T Wi-Fi Hotspots.) Additionally, the Blackberry Bold is the first RIM device that supports AT&T Cellular Video (CV).</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "blackberry-bold-9000-phone-black-att", AllowCustomerReviews = true, Price = 245M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productBlackBerry); productBlackBerry.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Cell phones"), DisplayOrder = 1, }); productBlackBerry.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_BlackBerry.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productBlackBerry.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productBlackBerry); var productBuildComputer = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Build your own computer", ShortDescription = "Build it", FullDescription = "<p>Fight back against cluttered workspaces with the stylish Sony VAIO JS All-in-One desktop PC, featuring powerful computing resources and a stunning 20.1-inch widescreen display with stunning XBRITE-HiColor LCD technology. The silver Sony VAIO VGC-JS110J/S has a built-in microphone and MOTION EYE camera with face-tracking technology that allows for easy communication with friends and family. And it has a built-in DVD burner and Sony's Movie Store software so you can create a digital entertainment library for personal viewing at your convenience. Easy to setup and even easier to use, this JS-series All-in-One includes an elegantly designed keyboard and a USB mouse.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "build-your-own-computer", AllowCustomerReviews = true, Price = 1200M, IsShipEnabled = true, IsFreeShipping = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, ShowOnHomePage = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productBuildComputer); var pvaBuildComputer1 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "Processor"), AttributeControlType = AttributeControlType.DropdownList, IsRequired = true, }; pvaBuildComputer1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "2.2 GHz Intel Pentium Dual-Core E2200", DisplayOrder = 1, }); pvaBuildComputer1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "2.5 GHz Intel Pentium Dual-Core E2200", IsPreSelected = true, PriceAdjustment = 15, DisplayOrder = 2, }); productBuildComputer.ProductVariantAttributes.Add(pvaBuildComputer1); var pvaBuildComputer2 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "RAM"), AttributeControlType = AttributeControlType.DropdownList, IsRequired = true, }; pvaBuildComputer2.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "2 GB", DisplayOrder = 1, }); pvaBuildComputer2.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "4GB", PriceAdjustment = 20, DisplayOrder = 2, }); pvaBuildComputer2.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "8GB", PriceAdjustment = 60, DisplayOrder = 3, }); productBuildComputer.ProductVariantAttributes.Add(pvaBuildComputer2); var pvaBuildComputer3 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "HDD"), AttributeControlType = AttributeControlType.RadioList, IsRequired = true, }; pvaBuildComputer3.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "320 GB", DisplayOrder = 1, }); pvaBuildComputer3.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "400 GB", PriceAdjustment = 100, DisplayOrder = 2, }); productBuildComputer.ProductVariantAttributes.Add(pvaBuildComputer3); var pvaBuildComputer4 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "OS"), AttributeControlType = AttributeControlType.RadioList, IsRequired = true, }; pvaBuildComputer4.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Vista Home", PriceAdjustment = 50, IsPreSelected = true, DisplayOrder = 1, }); pvaBuildComputer4.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Vista Premium", PriceAdjustment = 60, DisplayOrder = 2, }); productBuildComputer.ProductVariantAttributes.Add(pvaBuildComputer4); var pvaBuildComputer5 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "Software"), AttributeControlType = AttributeControlType.Checkboxes, }; pvaBuildComputer5.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Microsoft Office", PriceAdjustment = 50, IsPreSelected = true, DisplayOrder = 1, }); pvaBuildComputer5.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Acrobat Reader", PriceAdjustment = 10, DisplayOrder = 2, }); pvaBuildComputer5.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Total Commander", PriceAdjustment = 5, DisplayOrder = 2, }); productBuildComputer.ProductVariantAttributes.Add(pvaBuildComputer5); productBuildComputer.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Desktops"), DisplayOrder = 1, }); productBuildComputer.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Desktops_1.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productBuildComputer.Name), true), DisplayOrder = 1, }); productBuildComputer.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Desktops_2.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productBuildComputer.Name), true), DisplayOrder = 2, }); productBuildComputer.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Desktops_3.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productBuildComputer.Name), true), DisplayOrder = 3, }); _productRepository.Insert(productBuildComputer); //this one is a grouped product with two associated ones var productCanonCamera = new Product() { ProductType = ProductType.GroupedProduct, VisibleIndividually = true, Name = "Canon Digital SLR Camera", ShortDescription = "12.2-megapixel CMOS sensor captures enough detail for poster-size, photo-quality prints", FullDescription = "<p>For stunning photography with point and shoot ease, look no further than Canon’s EOS Rebel XSi. The EOS Rebel XSi brings staggering technological innovation to the masses. It features Canon’s EOS Integrated Cleaning System, Live View Function, a powerful DIGIC III Image Processor, plus a new 12.2-megapixel CMOS sensor and is available in a kit with the new EF-S 18-55mm f/3.5-5.6 IS lens with Optical Image Stabilizer. The EOS Rebel XSi’s refined, ergonomic design includes a new 3.0-inch LCD monitor, compatibility with SD and SDHC memory cards and new accessories that enhance every aspect of the photographic experience.</p>", ProductTemplateId = productTemplateGrouped.Id, //SeName = "canon-digital-slr-camera", AllowCustomerReviews = true, Published = true, Price = 670M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productCanonCamera); productCanonCamera.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Camera, photo"), DisplayOrder = 1, }); productCanonCamera.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_CanonCamera_1.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productCanonCamera.Name), true), DisplayOrder = 1, }); productCanonCamera.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_CanonCamera_2.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productCanonCamera.Name), true), DisplayOrder = 2, }); _productRepository.Insert(productCanonCamera); var productCanonCamera_associated_1 = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = false, //hide this products ParentGroupedProductId = productCanonCamera.Id, Name = "Canon Digital SLR Camera - Black", ProductTemplateId = productTemplateSimple.Id, //SeName = "canon-digital-slr-camera-black", AllowCustomerReviews = true, Published = true, Price = 670M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productCanonCamera_associated_1); productCanonCamera_associated_1.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_CanonCamera_black.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Canon Digital SLR Camera - Black"), true), DisplayOrder = 1, }); _productRepository.Insert(productCanonCamera_associated_1); var productCanonCamera_associated_2 = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = false, //hide this products ParentGroupedProductId = productCanonCamera.Id, Name = "Canon Digital SLR Camera - Silver", ProductTemplateId = productTemplateSimple.Id, //SeName = "canon-digital-slr-camera-silver", AllowCustomerReviews = true, Published = true, Price = 630M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productCanonCamera_associated_2); productCanonCamera_associated_2.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_CanonCamera_silver.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Canon Digital SLR Camera - Silver"), true), DisplayOrder = 1, }); _productRepository.Insert(productCanonCamera_associated_2); var productCanonCamcoder = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Canon VIXIA HF100 Camcorder", ShortDescription = "12x optical zoom; SuperRange Optical Image Stabilizer", FullDescription = "<p>From Canon's long history of optical excellence, advanced image processing, superb performance and technological innovation in photographic and broadcast television cameras comes the latest in high definition camcorders. <br /><br />Now, with the light, compact Canon VIXIA HF100, you can have stunning AVCHD (Advanced Video Codec High Definition) format recording with the ease and numerous benefits of Flash Memory. It's used in some of the world's most innovative electronic products such as laptop computers, MP3 players, PDAs and cell phones. <br /><br />Add to that the VIXIA HF100's Canon Exclusive features such as our own 3.3 Megapixel Full HD CMOS sensor and advanced DIGIC DV II Image Processor, SuperRange Optical Image Stabilization, Instant Auto Focus, our 2.7-inch Widescreen Multi-Angle Vivid LCD and the Genuine Canon 12x HD video zoom lens and you have a Flash Memory camcorder that's hard to beat.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "canon-vixia-hf100-camcorder", AllowCustomerReviews = true, Price = 530M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productCanonCamcoder); productCanonCamcoder.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Camera, photo"), DisplayOrder = 1, }); productCanonCamcoder.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_CanonCamcoder.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productCanonCamcoder.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productCanonCamcoder); var productCompaq = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Compaq Presario SR1519X Pentium 4 Desktop PC with CDRW", ShortDescription = "Compaq Presario Desktop PC", FullDescription = "<p>Compaq Presario PCs give you solid performance, ease of use, and deliver just what you need so you can do more with less effort. Whether you are e-mailing family, balancing your online checkbook or creating school projects, the Presario is the right PC for you.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "compaq-presario-sr1519x-pentium-4-desktop-pc-with-cdrw", AllowCustomerReviews = true, Price = 500M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productCompaq); productCompaq.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Desktops"), DisplayOrder = 1, }); productCompaq.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Compaq.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productCompaq.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productCompaq); var productCookingForTwo = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Cooking for Two", ShortDescription = "More Than 200 Foolproof Recipes for Weeknights and Special Occasions (Hardcover)", FullDescription = "<p>Hardcover: 352 pages<br />Publisher: America's Test Kitchen (May 2009)<br />Language: English<br />ISBN-10: 1933615435<br />ISBN-13: 978-1933615431</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "cooking-for-two", AllowCustomerReviews = true, Price = 19M, OldPrice = 27M, IsShipEnabled = true, DeliveryDateId = deliveryDate.Id, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Books").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productCookingForTwo); productCookingForTwo.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Books"), DisplayOrder = 1, }); productCookingForTwo.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_CookingForTwo.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productCookingForTwo.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productCookingForTwo); var productCorel = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Corel Paint Shop Pro Photo X2", ShortDescription = "The ideal choice for any aspiring photographer's digital darkroom", FullDescription = "<p>Corel Paint Shop Pro Photo X2 is the ideal choice for any aspiring photographer's digital darkroom. Fix brightness, color, and photo flaws in a few clicks; use precision editing tools to create the picture you want; give photos a unique, exciting look using hundreds of special effects, and much more! Plus, the NEW one-of-a-kind Express Lab helps you quickly view and fix dozens of photos in the time it used to take to edit a few. Paint Shop Pro Photo X2 even includes a built-in Learning Center to help you get started, it's the easiest way to get professional-looking photos - fast!</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "corel-paint-shop-pro-photo-x2", AllowCustomerReviews = true, Price = 65M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 3, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productCorel); productCorel.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Software & Games"), DisplayOrder = 1, }); productCorel.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Corel.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productCorel.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productCorel); var productCustomTShirt = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Custom T-Shirt", ShortDescription = "T-Shirt - Add Your Content", FullDescription = "<p>Comfort comes in all shapes and forms, yet this tee out does it all. Rising above the rest, our classic cotton crew provides the simple practicality you need to make it through the day. Tag-free, relaxed fit wears well under dress shirts or stands alone in laid-back style. Reinforced collar and lightweight feel give way to long-lasting shape and breathability. One less thing to worry about, rely on this tee to provide comfort and ease with every wear.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "custom-t-shirt", AllowCustomerReviews = true, Price = 15M, IsShipEnabled = true, Weight = 4, Length = 3, Width = 3, Height = 3, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productCustomTShirt); productCustomTShirt.ProductVariantAttributes.Add(new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "Custom Text"), TextPrompt = "Enter your text:", AttributeControlType = AttributeControlType.TextBox, IsRequired = true, }); productCustomTShirt.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productCustomTShirt.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_CustomTShirt.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productCustomTShirt.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productCustomTShirt); var productDiamondEarrings = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Diamond Pave Earrings", ShortDescription = "1/2 Carat (ctw) in White Gold", FullDescription = "<p>Perfect for both a professional look as well as perhaps something more sensual, these 10 karat white gold huggie earrings boast 86 sparkling round diamonds set in a pave arrangement that total 1/2 carat (ctw).</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "diamond-pave-earrings", AllowCustomerReviews = true, Price = 569M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Jewelry").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productDiamondEarrings); productDiamondEarrings.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Jewelry"), DisplayOrder = 1, }); productDiamondEarrings.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_DiamondEarrings.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productDiamondEarrings.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productDiamondEarrings); var productDiamondBracelet = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Diamond Tennis Bracelet", ShortDescription = "1.0 Carat (ctw) in White Gold", FullDescription = "<p>Jazz up any outfit with this classic diamond tennis bracelet. This piece has one full carat of diamonds uniquely set in brilliant 10 karat white gold.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "diamond-tennis-bracelet", AllowCustomerReviews = true, Price = 360M, IsShipEnabled = true, IsFreeShipping = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Jewelry").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productDiamondBracelet); productDiamondBracelet.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Jewelry"), DisplayOrder = 1, }); productDiamondBracelet.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_DiamondBracelet_1.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productDiamondBracelet.Name), true), DisplayOrder = 1, }); productDiamondBracelet.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_DiamondBracelet_2.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productDiamondBracelet.Name), true), DisplayOrder = 2, }); _productRepository.Insert(productDiamondBracelet); var productEatingWell = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "EatingWell in Season", ShortDescription = "A Farmers' Market Cookbook (Hardcover)", FullDescription = "<p>Trying to get big chocolate flavor into a crisp holiday cookie is no easy feat. Any decent baker can get a soft, chewy cookie to scream “chocolate,” but a dough that can withstand a rolling pin and cookie cutters simply can’t be too soft. Most chocolate butter cookies skimp on the gooey chocolate and their chocolate flavor is quite modest.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "eatingwell-in-season", AllowCustomerReviews = true, Price = 51M, OldPrice = 67M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Books").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productEatingWell); productEatingWell.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Books"), DisplayOrder = 1, }); productEatingWell.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_EatingWell.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productEatingWell.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productEatingWell); var productEtnies = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "etnies Men's Digit Sneaker", ShortDescription = "This sleek shoe has all you need--from the padded tongue and collar and internal EVA midsole, to the STI Level 2 cushioning for impact absorption and stability.", FullDescription = "<p>Established in 1986, etnies is the first skateboarder-owned and skateboarder-operated global action sports footwear and apparel company. etnies not only pushed the envelope by creating the first pro model skate shoe, but it pioneered technological advances and changed the face of skateboard footwear forever. Today, etnies' vision is to remain the leading action sports company committed to creating functional products that provide the most style, comfort, durability and protection possible. etnies stays true to its roots by sponsoring a world-class team of skateboarding, surfing, snowboarding, moto-x, and BMX athletes and continues its dedication by giving back to each of these communities.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "etnies-mens-digit-sneaker", AllowCustomerReviews = true, Price = 17.56M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productEtnies); var pvaEtnies1 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "Size"), AttributeControlType = AttributeControlType.DropdownList, IsRequired = true, }; pvaEtnies1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "8", DisplayOrder = 1, }); pvaEtnies1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "9", DisplayOrder = 2, }); pvaEtnies1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "10", DisplayOrder = 3, }); pvaEtnies1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "11", DisplayOrder = 4, }); productEtnies.ProductVariantAttributes.Add(pvaEtnies1); var pvaEtnies2 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "Color"), AttributeControlType = AttributeControlType.ColorSquares, IsRequired = true, }; pvaEtnies2.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "White", IsPreSelected = true, ColorSquaresRgb = "#FFFFFF", DisplayOrder = 1, }); pvaEtnies2.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Black", ColorSquaresRgb = "#000000", DisplayOrder = 2, }); pvaEtnies2.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Green", ColorSquaresRgb = "#1fcb1a", DisplayOrder = 3, }); productEtnies.ProductVariantAttributes.Add(pvaEtnies2); productEtnies.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productEtnies.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Etnies.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productEtnies.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productEtnies); var productLeatherHandbag = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Genuine Leather Handbag with Cell Phone Holder & Many Pockets", ShortDescription = "Classic Leather Handbag", FullDescription = "<p>This fine leather handbag will quickly become your favorite bag. It has a zipper organizer on the front that includes a notepad pocket, pen holder, credit card slots and zipper pocket divider. On top of this is a zipper pocket and another flap closure pocket. The main compartment is fully lined and includes a side zipper pocket. On the back is another zipper pocket. And don't forget the convenient built in cell phone holder on the side! The long strap is fully adjustable so you can wear it crossbody or over the shoulder. This is a very well-made, quality leather bag that is not too big, but not too small.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "genuine-leather-handbag-with-cell-phone-holder-many-pockets", AllowCustomerReviews = true, Price = 35M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productLeatherHandbag); productLeatherHandbag.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productLeatherHandbag.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_LeatherHandbag_1.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productLeatherHandbag.Name), true), DisplayOrder = 1, }); productLeatherHandbag.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_LeatherHandbag_2.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productLeatherHandbag.Name), true), DisplayOrder = 2, }); _productRepository.Insert(productLeatherHandbag); var productHp506 = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "HP IQ506 TouchSmart Desktop PC", ShortDescription = "", FullDescription = "<p>Redesigned with a next-generation, touch-enabled 22-inch high-definition LCD screen, the HP TouchSmart IQ506 all-in-one desktop PC is designed to fit wherever life happens: in the kitchen, family room, or living room. With one touch you can check the weather, download your e-mail, or watch your favorite TV show. It's also designed to maximize energy, with a power-saving Intel Core 2 Duo processor and advanced power management technology, as well as material efficiency--right down to the packaging. It has a sleek piano black design with elegant espresso side-panel highlights, and the HP Ambient Light lets you set a mood--or see your keyboard in the dark.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "hp-iq506-touchsmart-desktop-pc", AllowCustomerReviews = true, Price = 1199M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productHp506); productHp506.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Desktops"), DisplayOrder = 1, }); productHp506.ProductManufacturers.Add(new ProductManufacturer() { Manufacturer = _manufacturerRepository.Table.Single(c => c.Name == "HP"), DisplayOrder = 1, }); productHp506.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Hp506.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productHp506.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productHp506); var productHpPavilion1 = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "HP Pavilion Artist Edition DV2890NR 14.1-inch Laptop", ShortDescription = "Unique Asian-influenced HP imprint wraps the laptop both inside and out", FullDescription = "<p>Optimize your mobility with a BrightView 14.1-inch display that has the same viewable area as a 15.4-inch screen--in a notebook that weighs a pound less. Encouraging more direct interaction, the backlit media control panel responds to the touch or sweep of a finger. Control settings for audio and video playback from up to 10 feet away with the included HP remote, then store it conveniently in the PC card slot. Enjoy movies or music in seconds with the external DVD or music buttons to launch HP QuickPlay (which bypasses the boot process).</p><p>It's powered by the 1.83 GHz Intel Core 2 Duo T5550 processor, which provides an optimized, multithreaded architecture for improved gaming and multitasking performance, as well as excellent battery management. It also includes Intel's 4965 AGN wireless LAN, which will connect to draft 802.11n routers and offers compatibility with 802.11a/b/g networks as well. It also features a 250 GB hard drive, 3 GB of installed RAM (4 GB maximum), LighScribe dual-layer DVD±R burner, HDMI port for connecting to an HDTV, and Nvidia GeForce Go 8400M GS video/graphics card with up to 1407 MB of total allocated video memory (128 MB dedicated). It also includes an integrated Webcam in the LCD's bezel and an omnidirectional microphone for easy video chats.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "hp-pavilion-artist-edition-dv2890nr-141-inch-laptop", AllowCustomerReviews = true, Price = 1590M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, ShowOnHomePage = true, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productHpPavilion1); productHpPavilion1.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Notebooks"), DisplayOrder = 1, }); productHpPavilion1.ProductManufacturers.Add(new ProductManufacturer() { Manufacturer = _manufacturerRepository.Table.Single(c => c.Name == "HP"), DisplayOrder = 2, }); productHpPavilion1.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_HpPavilion1.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productHpPavilion1.Name), true), DisplayOrder = 1, }); productHpPavilion1.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 1, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Screensize").SpecificationAttributeOptions.Single(sao => sao.Name == "14.1''") }); productHpPavilion1.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 2, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "CPU Type").SpecificationAttributeOptions.Single(sao => sao.Name == "Intel") }); productHpPavilion1.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 3, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Memory").SpecificationAttributeOptions.Single(sao => sao.Name == "3 GB") }); productHpPavilion1.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 4, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Hardrive").SpecificationAttributeOptions.Single(sao => sao.Name == "250 GB") }); _productRepository.Insert(productHpPavilion1); var productHpPavilion2 = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "HP Pavilion Elite M9150F Desktop PC", ShortDescription = "Top-of-the-line multimedia desktop featuring 2.4 GHz Intel Core 2 Quad Processor Q6600 with four lightning fast execution cores", FullDescription = "<p>The updated chassis with sleek piano black paneling and components is far from the most significant improvements in the multimedia powerhouse HP Pavilion Elite m9150f desktop PC. It's powered by Intel's newest processor--the 2.4 GHz Intel Core 2 Quad Q6600--which delivers four complete execution cores within a single processor for unprecedented performance and responsiveness in multi-threaded and multi-tasking business/home environments. You can also go wireless and clutter-free with wireless keyboard, mouse, and remote control, and it includes the next step in Wi-Fi networking with a 54g wireless LAN (802.11b/g).</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "hp-pavilion-elite-m9150f-desktop-pc", AllowCustomerReviews = true, Price = 1350M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productHpPavilion2); productHpPavilion2.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Desktops"), DisplayOrder = 1, }); productHpPavilion2.ProductManufacturers.Add(new ProductManufacturer() { Manufacturer = _manufacturerRepository.Table.Single(c => c.Name == "HP"), DisplayOrder = 3, }); productHpPavilion2.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_HpPavilion2_1.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productHpPavilion2.Name), true), DisplayOrder = 1, }); productHpPavilion2.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_HpPavilion2_2.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productHpPavilion2.Name), true), DisplayOrder = 2, }); _productRepository.Insert(productHpPavilion2); var productHpPavilion3 = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "HP Pavilion G60-230US 16.0-Inch Laptop", ShortDescription = "Streamlined multimedia laptop with 16-inch screen for basic computing, entertainment and online communication", FullDescription = "<p>Chat face to face, or take pictures and video clips with the webcam and integrated digital microphone. Play games and enhance multimedia with the Intel GMA 4500M with up to 1309 MB of total available graphics memory. And enjoy movies or music in seconds with the external DVD or music buttons to launch HP QuickPlay (which bypasses the boot process). It offers dual-core productivity from its 2.0 GHz Intel Pentium T4200 processor for excellent multitasking. Other features include a 320 GB hard drive, 3 GB of installed RAM (4 GB maximum capacity), dual-layer DVD±RW drive (which also burns CDs), quad-mode Wi-Fi (802.11a/b/g/n), 5-in-1 memory card reader, and pre-installed Windows Vista Home Premium (SP1).</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "hp-pavilion-g60-230us-160-inch-laptop", AllowCustomerReviews = true, Price = 1460M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productHpPavilion3); productHpPavilion3.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Notebooks"), DisplayOrder = 1, }); productHpPavilion3.ProductManufacturers.Add(new ProductManufacturer() { Manufacturer = _manufacturerRepository.Table.Single(c => c.Name == "HP"), DisplayOrder = 4, }); productHpPavilion3.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_HpPavilion3.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productHpPavilion3.Name), true), DisplayOrder = 1, }); productHpPavilion3.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 1, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Screensize").SpecificationAttributeOptions.Single(sao => sao.Name == "16.0''") }); productHpPavilion3.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 2, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "CPU Type").SpecificationAttributeOptions.Single(sao => sao.Name == "Intel") }); productHpPavilion3.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 3, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Memory").SpecificationAttributeOptions.Single(sao => sao.Name == "3 GB") }); productHpPavilion3.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 4, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Hardrive").SpecificationAttributeOptions.Single(sao => sao.Name == "320 GB") }); _productRepository.Insert(productHpPavilion3); var productHat = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Indiana Jones® Shapeable Wool Hat", ShortDescription = "Wear some adventure with the same hat Indiana Jones® wears in his movies.", FullDescription = "<p>Wear some adventure with the same hat Indiana Jones® wears in his movies. Easy to shape to fit your personal style. Wool. Import. Please Note - Due to new UPS shipping rules and the size of the box, if you choose to expedite your hat order (UPS 3-day, 2-day or Overnight), an additional non-refundable $20 shipping charge per hat will be added at the time your order is processed.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "indiana-jones-shapeable-wool-hat", AllowCustomerReviews = true, Price = 30M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productHat); var pvaHat1 = new ProductVariantAttribute() { ProductAttribute = _productAttributeRepository.Table.Single(x => x.Name == "Size"), AttributeControlType = AttributeControlType.DropdownList, IsRequired = true, }; pvaHat1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Small", DisplayOrder = 1, }); pvaHat1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Medium", DisplayOrder = 2, }); pvaHat1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "Large", DisplayOrder = 3, }); pvaHat1.ProductVariantAttributeValues.Add(new ProductVariantAttributeValue() { AttributeValueType = AttributeValueType.Simple, Name = "X-Large", DisplayOrder = 4, }); productHat.ProductVariantAttributes.Add(pvaHat1); productHat.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productHat.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_hat.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productHat.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productHat); var productKensington = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Kensington 33117 International All-in-One Travel Plug Adapter", ShortDescription = "Includes plug adapters for use in more than 150 countries", FullDescription = "<p>The Kensington 33117 Travel Plug Adapter is a pocket-sized power adapter for go-anywhere convenience. This all-in-one unit provides plug adapters for use in more than 150 countries, so you never need to be at a loss for power again. The Kensington 33117 is easy to use, with slide-out power plugs that ensure you won't lose any vital pieces, in a compact, self-contained unit that eliminates any hassles. This all-in-one plug adapts power outlets for laptops, chargers, and similar devices, and features a safety release button and built-in fuse to ensure safe operation. The Kensington 33117 does not reduce or convert electrical voltage, is suitable for most consumer electronics ranging from 110-volts to Mac 275-watts, to 220-volts to Mac 550-watts. Backed by Kensington's one-year warranty, this unit weighs 0.5, and measures 1.875 x 2 x 2.25 inches (WxDxH). Please note that this adapter is not designed for use with high-watt devices such as hairdryers and irons, so users should check electronic device specifications before using.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "kensington-33117-international-all-in-one-travel-plug-adapter", AllowCustomerReviews = true, Price = 35M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productKensington); productKensington.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Accessories"), DisplayOrder = 1, }); productKensington.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Kensington.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productKensington.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productKensington); var productLeviJeans = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Levi's Skinny 511 Jeans", ShortDescription = "Levi's Faded Black Skinny 511 Jeans ", FullDescription = "", ProductTemplateId = productTemplateSimple.Id, //SeName = "levis-skinny-511-jeans", AllowCustomerReviews = true, Price = 43.5M, OldPrice = 55M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productLeviJeans); productLeviJeans.TierPrices.Add(new TierPrice() { Quantity = 3, Price = 40 }); productLeviJeans.TierPrices.Add(new TierPrice() { Quantity = 6, Price = 38 }); productLeviJeans.TierPrices.Add(new TierPrice() { Quantity = 10, Price = 35 }); productLeviJeans.HasTierPrices = true; productLeviJeans.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productLeviJeans.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_LeviJeans_1.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productLeviJeans.Name), true), DisplayOrder = 1, }); productLeviJeans.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_LeviJeans_2.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productLeviJeans.Name), true), DisplayOrder = 2, }); _productRepository.Insert(productLeviJeans); var productBaseball = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Major League Baseball 2K9", ShortDescription = "Take charge of your franchise and enjoy the all-new MLB.com presentation style", FullDescription = "<p>Major League Baseball 2K9 captures the essence of baseball down to some of the most minute, player- specific details including batting stances, pitching windups and signature swings. 2K Sports has gone above and beyond the call of duty to deliver this in true major league fashion. Additionally, gameplay enhancements in pitching, batting, fielding and base running promise this year's installment to be user-friendly and enjoyable for rookies or veterans. New commentary and presentation provide the icing to this ultimate baseball experience. If you really want to Play Ball this is the game for you.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "major-league-baseball-2k9", AllowCustomerReviews = true, Price = 14.99M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productBaseball); productBaseball.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Software & Games"), DisplayOrder = 1, }); productBaseball.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Baseball.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productBaseball.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productBaseball); var productMedalOfHonor = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Medal of Honor - Limited Edition (Xbox 360)", ShortDescription = "One of the great pioneers in military simulations returns to gaming as the Medal of Honor series depicts modern warfare for the first time, with a harrowing tour of duty in current day Afghanistan.", FullDescription = "You'll take control of both ordinary U.S. Army Rangers and Tier 1 Elite Ops Special Forces as you fight enemy insurgents in the most dangerous theatre of war of the modern age. The intense first person combat has been created with input from U.S. military consultants and based on real-life descriptions from veteran soldiers. This allows you to use genuine military tactics and advanced technology including combat drones and targeted air strikes.", ProductTemplateId = productTemplateSimple.Id, //SeName = "medal-of-honor-limited-edition-xbox-360", AllowCustomerReviews = true, Price = 37M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productMedalOfHonor); productMedalOfHonor.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Software & Games"), DisplayOrder = 1, }); productMedalOfHonor.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_MedalOfHonor.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productMedalOfHonor.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productMedalOfHonor); var productMouse = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Microsoft Bluetooth Notebook Mouse 5000 Mac/Windows", ShortDescription = "Enjoy reliable, transceiver-free wireless connection to your PC with Bluetooth Technology", FullDescription = "<p>Enjoy wireless freedom with the Microsoft® Bluetooth® Notebook Mouse 5000 — no transceiver to connect or lose! Keep USB ports free for other devices. And, take it with you in a convenient carrying case (included)</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "microsoft-bluetooth-notebook-mouse-5000-macwindows", AllowCustomerReviews = true, Price = 37M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productMouse); productMouse.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Accessories"), DisplayOrder = 1, }); productMouse.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Mouse.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productMouse.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productMouse); var productGolfBelt = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "NIKE Golf Casual Belt", ShortDescription = "NIKE Golf Casual Belt is a great look for in the clubhouse after a round of golf.", FullDescription = "<p>NIKE Golf Casual Belt is a great look for in the clubhouse after a round of golf. The belt strap is made of full grain oil tanned leather. The buckle is made of antique brushed metal with an embossed Swoosh design on it. This belt features an English beveled edge with rivets on the tab and tip of the 38mm wide strap. Size: 32; Color: Black.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "nike-golf-casual-belt", AllowCustomerReviews = true, Price = 45M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productGolfBelt); productGolfBelt.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productGolfBelt.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_GolfBelt.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productGolfBelt.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productGolfBelt); var productPanasonic = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Panasonic HDC-SDT750K, High Definition 3D Camcorder", ShortDescription = "World's first 3D Shooting Camcorder", FullDescription = "<p>Unlike previous 3D images that required complex, professional equipment to create, now you can shoot your own. Simply attach the 3D Conversion Lens to the SDT750 for quick and easy 3D shooting. And because the SDT750 features the Advanced 3MOS System, which has gained worldwide popularity, colors are vivid and 3D images are extremely realistic. Let the SDT750 save precious moments for you in true-to-life images.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "panasonic-hdc-sdt750k-high-definition-3d-camcorder", AllowCustomerReviews = true, Price = 1300M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productPanasonic); productPanasonic.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Camera, photo"), DisplayOrder = 1, }); productPanasonic.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_productPanasonic.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productPanasonic.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productPanasonic); var productSunglasses = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Ray Ban Aviator Sunglasses RB 3025", ShortDescription = "Aviator sunglasses are one of the first widely popularized styles of modern day sunwear.", FullDescription = "<p>Since 1937, Ray-Ban can genuinely claim the title as the world's leading sunglasses and optical eyewear brand. Combining the best of fashion and sports performance, the Ray-Ban line of Sunglasses delivers a truly classic style that will have you looking great today and for years to come.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "ray-ban-aviator-sunglasses-rb-3025", AllowCustomerReviews = true, Price = 25M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productSunglasses); productSunglasses.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productSunglasses.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Sunglasses.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productSunglasses.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productSunglasses); var productSamsungPhone = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Samsung Rugby A837 Phone, Black (AT&T)", ShortDescription = "Ruggedized 3G handset in black great for outdoor workforces", FullDescription = "<p>Ideal for on-site field services, the ruggedized Samsung Rugby for AT&T can take just about anything you can throw at it. This highly durable handset is certified to Military Standard MIL-STD 810F standards that's perfect for users like construction foremen and landscape designers. In addition to access to AT&T Navigation turn-by-turn direction service, the Rugby also features compatibility with Push to Talk communication, Enterprise Paging, and AT&T's breakthrough Video Share calling services. This quad-band GSM phone runs on AT&T's dual-band 3G (HSDPA/UMTS) network, for fast downloads and seamless video calls. It also offers a 1.3-megapixel camera, microSD memory expansion to 8 GB, Bluetooth for handsfree communication and stereo music streaming, access to personal email and instant messaging, and up to 5 hours of talk time.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "samsung-rugby-a837-phone-black-att", AllowCustomerReviews = true, Price = 100M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productSamsungPhone); productSamsungPhone.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Cell phones"), DisplayOrder = 1, }); productSamsungPhone.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_SamsungPhone_1.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productSamsungPhone.Name), true), DisplayOrder = 1, }); productSamsungPhone.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_SamsungPhone_2.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productSamsungPhone.Name), true), DisplayOrder = 2, }); _productRepository.Insert(productSamsungPhone); var productSonyCamcoder = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Sony DCR-SR85 1MP 60GB Hard Drive Handycam Camcorder", ShortDescription = "Capture video to hard disk drive; 60 GB storage", FullDescription = "<p>You’ll never miss a moment because of switching tapes or discs with the DCR-SR85. Its built-in 60GB hard disk drive offers plenty of storage as you zero in on your subjects with the professional-quality Carl Zeiss Vario-Tessar lens and a powerful 25x optical/2000x digital zoom. Compose shots using the 2.7-inch wide (16:9) touch-panel LCD display, and maintain total control and clarity with the Super SteadyShot image stabilization system. Hybrid recording technology even gives you the choice to record video to either the internal hard disk drive or removable Memory Stick Pro Duo media.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "sony-dcr-sr85-1mp-60gb-hard-drive-handycam-camcorder", AllowCustomerReviews = true, Price = 349M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productSonyCamcoder); productSonyCamcoder.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Camera, photo"), DisplayOrder = 1, }); productSonyCamcoder.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_SonyCamcoder.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productSonyCamcoder.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productSonyCamcoder); var productBestSkilletRecipes = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "The Best Skillet Recipes", ShortDescription = "What's the Best Way to Make Lasagna With Rich, Meaty Flavor, Chunks of Tomato, and Gooey Cheese, Without Ever Turning on the Oven or Boiling a Pot of (Hardcover)", FullDescription = "<p>In this latest addition of the Best Recipe Classic series, <em>Cooks Illustrated</em> editor Christopher Kimball and his team of kitchen scientists celebrate the untold versatility of that ordinary workhorse, the 12-inch skillet. An indispensable tool for eggs, pan-seared meats and sautéed vegetables, the skillet can also be used for stovetop-to-oven dishes such as All-American Mini Meatloaves; layered dishes such as tamale pie and Tuscan bean casserole; and even desserts such as hot fudge pudding cake. In the trademark style of other America's Test Kitchen publications, the cookbook contains plenty of variations on basic themes (you can make chicken and rice with peas and scallions, broccoli and cheddar, or coconut milk and pistachios); ingredient and equipment roundups; and helpful illustrations for preparing mango and stringing snowpeas. Yet the true strength of the series lies in the sheer thoughtfulness and detail of the recipes. Whether or not you properly appreciate your skillet, this book will at least teach you to wield it gracefully. <i>(Mar.)</i> <br />Copyright © Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "the-best-skillet-recipes", AllowCustomerReviews = true, Price = 24M, OldPrice = 35M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Books").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productBestSkilletRecipes); productBestSkilletRecipes.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Books"), DisplayOrder = 1, }); productBestSkilletRecipes.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_BestSkilletRecipes.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productBestSkilletRecipes.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productBestSkilletRecipes); var productSatellite = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Toshiba Satellite A305-S6908 15.4-Inch Laptop", ShortDescription = "Stylish, highly versatile laptop with 15.4-inch LCD, webcam integrated into bezel, and high-gloss finish", FullDescription = "<p>It's powered by the 2.0 GHz Intel Core 2 Duo T6400 processor, which boosts speed, reduces power requirements, and saves on battery life. It also offers a fast 800 MHz front-side bus speed and 2 MB L2 cache. It also includes Intel's 5100AGN wireless LAN, which will connect to draft 802.11n routers and offers compatibility with 802.11a/b/g networks as well. Other features include an enormous 250 GB hard drive, 1 GB of installed RAM (max capacity), dual-layer DVD±RW burner (with Labelflash disc printing), ExpressCard 54/34 slot, a combo USB/eSATA port, SPDIF digital audio output for surround sound, and a 5-in-1 memory card adapter.</p><p>This PC comes preinstalled with the 64-bit version of Microsoft Windows Vista Home Premium (SP1), which includes all of the Windows Media Center capabilities for turning your PC into an all-in-one home entertainment center. In addition to easily playing your DVD movies and managing your digital audio library, you'll be able to record and watch your favorite TV shows (even HDTV). Vista also integrates new search tools throughout the operating system, includes new parental control features, and offers new tools that can warn you of impending hardware failures</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "toshiba-satellite-a305-s6908-154-inch-laptop", AllowCustomerReviews = true, Price = 1360M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productSatellite); productSatellite.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Notebooks"), DisplayOrder = 1, }); productSatellite.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Notebooks.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productSatellite.Name), true), DisplayOrder = 1, }); productSatellite.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 1, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Screensize").SpecificationAttributeOptions.Single(sao => sao.Name == "15.4''") }); productSatellite.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 2, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "CPU Type").SpecificationAttributeOptions.Single(sao => sao.Name == "Intel") }); productSatellite.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = true, ShowOnProductPage = true, DisplayOrder = 3, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Memory").SpecificationAttributeOptions.Single(sao => sao.Name == "1 GB") }); productSatellite.ProductSpecificationAttributes.Add(new ProductSpecificationAttribute() { AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 4, SpecificationAttributeOption = _specificationAttributeRepository.Table.Single(sa => sa.Name == "Hardrive").SpecificationAttributeOptions.Single(sao => sao.Name == "250 GB") }); _productRepository.Insert(productSatellite); var productDenimShort = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "V-Blue Juniors' Cuffed Denim Short with Rhinestones", ShortDescription = "Superior construction and reinforced seams", FullDescription = "", ProductTemplateId = productTemplateSimple.Id, //SeName = "v-blue-juniors-cuffed-denim-short-with-rhinestones", AllowCustomerReviews = true, Price = 10M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Apparel & Shoes").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productDenimShort); productDenimShort.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Apparel & Shoes"), DisplayOrder = 1, }); productDenimShort.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_DenimShort.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productDenimShort.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productDenimShort); var productEngagementRing = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Vintage Style Three Stone Diamond Engagement Ring", ShortDescription = "1.24 Carat (ctw) in 14K White Gold (Certified)", FullDescription = "<p>Dazzle her with this gleaming 14 karat white gold vintage proposal. A ravishing collection of 11 decadent diamonds come together to invigorate a superbly ornate gold shank. Total diamond weight on this antique style engagement ring equals 1 1/4 carat (ctw). Item includes diamond certificate.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "vintage-style-three-stone-diamond-engagement-ring", AllowCustomerReviews = true, Price = 2100M, IsShipEnabled = true, Weight = 2, Length = 2, Width = 2, Height = 2, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Jewelry").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productEngagementRing); productEngagementRing.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Jewelry"), DisplayOrder = 1, }); productEngagementRing.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_EngagementRing_1.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productEngagementRing.Name), true), DisplayOrder = 1, }); productEngagementRing.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_EngagementRing_2.jpg"), "image/pjpeg", pictureService.GetPictureSeName(productEngagementRing.Name), true), DisplayOrder = 2, }); _productRepository.Insert(productEngagementRing); var productWoW = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "World of Warcraft: Wrath of the Lich King Expansion Pack", ShortDescription = "This expansion pack REQUIRES the original World of Warcraft game in order to run", FullDescription = "<p>Fans of World of Warcraft, prepare for Blizzard Entertainment's next installment -- World of Warcraft: Wrath of King Lich. In this latest expansion, something is afoot in the cold, harsh northlands. The Lich King Arthas has set in motion events that could lead to the extinction of all life on Azeroth. The necromantic power of the plague and legions of undead armies threaten to sweep across the land. Only the mightiest heroes can oppose the Lich King and end his reign of terror.</p><p>This expansion adds a host of content to the already massive existing game world. Players will achieve soaring levels of power, explore Northrend (the vast icy continent of the Lich King), and battle high-level heroes to determine the ultimate fate of Azeroth. As you face the dangers of the frigid, harsh north, prepare to master the dark necromantic powers of the Death Night -- World of Warcraft's first Hero class. No longer servants of the Lich King, the Death Knights begin their new calling as experienced, formidable adversaries. Each is heavily armed, armored, and in possession of a deadly arsenal of forbidden magic.</p><p>If you have a World of Warcraft account with a character of at least level 55, you will be able to create a new level-55 Death Knight of any race (if on a PvP realm, the Death Knight must be the same faction as your existing character). And upon entering the new world, your Death Knight will begin to quest to level 80, gaining potent new abilities and talents along the way. This expansion allows for only one Death Knight per realm, per account.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "world-of-warcraft-wrath-of-the-lich-king-expansion-pack", AllowCustomerReviews = true, Price = 29.5M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productWoW); productWoW.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Software & Games"), DisplayOrder = 1, }); productWoW.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_wow.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productWoW.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productWoW); var productSoccer = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "World Wide Soccer Manager 2009", ShortDescription = "Worldwide Soccer Manager 2009 from Sega for the PC or Mac is an in-depth soccer management game", FullDescription = "<p>Worldwide Soccer Manager 2009 from Sega for the PC or Mac is an in-depth soccer management game. At the helm, you'll enter the new season with a wide array of all-new features. The most impressive update is the first-time-ever, real-time 3D match engine with motion captured animations. With over 5,000 playable teams and every management decision in the palm of your hand, you'll love watching your matches and decisions unfold from multiple camera angles as you compete in leagues around the world and major international tournaments.</p><p>Watch your match in real-time, or use the Match Time Bar to fast-forward through sluggish minutes or rewind key moments in the game. With this customization at your fingertips you can also choose the information you'd like to see during the match, such as latest scores or player performance stats for the match.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "world-wide-soccer-manager-2009", AllowCustomerReviews = true, Price = 25.99M, IsShipEnabled = true, Weight = 7, Length = 7, Width = 7, Height = 7, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Electronics & Software").Id, ManageInventoryMethod = ManageInventoryMethod.ManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productSoccer); productSoccer.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Software & Games"), DisplayOrder = 1, }); productSoccer.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_Soccer.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productSoccer.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productSoccer); var downloadPokerFace1 = new Download() { DownloadGuid = Guid.NewGuid(), ContentType = "application/x-zip-co", DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_PokerFace_1.zip"), Extension = ".zip", Filename = "Poker_Face_1", IsNew = true, }; downloadService.InsertDownload(downloadPokerFace1); var downloadPokerFace2 = new Download() { DownloadGuid = Guid.NewGuid(), ContentType = "text/plain", DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_PokerFace_2.txt"), Extension = ".txt", Filename = "Poker_Face_1", IsNew = true, }; downloadService.InsertDownload(downloadPokerFace2); var productPokerFace = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Poker Face", ShortDescription = "Poker Face by Lady GaGa", FullDescription = "<p>Original Release Date: October 28, 2008</p><p>Release Date: October 28, 2008</p><p>Label: Streamline/Interscoope/KonLive/Cherrytree</p><p>Copyright: (C) 2008 Interscope Records</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "poker-face", AllowCustomerReviews = true, Price = 2.8M, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Downloadable Products").Id, ManageInventoryMethod = ManageInventoryMethod.DontManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, IsDownload = true, DownloadId = downloadPokerFace1.Id, DownloadActivationType = DownloadActivationType.WhenOrderIsPaid, UnlimitedDownloads = true, HasUserAgreement = false, HasSampleDownload = true, SampleDownloadId = downloadPokerFace2.Id, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productPokerFace); productPokerFace.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Digital downloads"), DisplayOrder = 1, }); productPokerFace.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_PokerFace.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productPokerFace.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productPokerFace); var downloadSingleLadies1 = new Download() { DownloadGuid = Guid.NewGuid(), ContentType = "application/x-zip-co", DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_SingleLadies_1.zip"), Extension = ".zip", Filename = "Single_Ladies_1", IsNew = true, }; downloadService.InsertDownload(downloadSingleLadies1); var downloadSingleLadies2 = new Download() { DownloadGuid = Guid.NewGuid(), ContentType = "text/plain", DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_SingleLadies_2.txt"), Extension = ".txt", Filename = "Single_Ladies_1", IsNew = true, }; downloadService.InsertDownload(downloadSingleLadies2); var productSingleLadies = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "Single Ladies (Put A Ring On It)", ShortDescription = "Single Ladies (Put A Ring On It) by Beyonce", FullDescription = "<p>Original Release Date: November 18, 2008</p><p>Label: Music World Music/Columbia</p><p>Copyright: (P) 2008 SONY BMG MUSIC ENTERTAINMENT</p><p>Song Length: 3:13 minutes</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "single-ladies-put-a-ring-on-it", AllowCustomerReviews = true, Price = 3M, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Downloadable Products").Id, ManageInventoryMethod = ManageInventoryMethod.DontManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, IsDownload = true, DownloadId = downloadSingleLadies1.Id, DownloadActivationType = DownloadActivationType.WhenOrderIsPaid, UnlimitedDownloads = true, HasUserAgreement = false, HasSampleDownload = true, SampleDownloadId = downloadSingleLadies2.Id, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productSingleLadies); productSingleLadies.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Digital downloads"), DisplayOrder = 1, }); productSingleLadies.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_SingleLadies.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productSingleLadies.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productSingleLadies); var downloadBattleOfLa = new Download() { DownloadGuid = Guid.NewGuid(), ContentType = "application/x-zip-co", DownloadBinary = File.ReadAllBytes(sampleDownloadsPath + "product_BattleOfLa_1.zip"), Extension = ".zip", Filename = "The_Battle_Of_Los_Angeles", IsNew = true, }; downloadService.InsertDownload(downloadBattleOfLa); var productBattleOfLa = new Product() { ProductType = ProductType.SimpleProduct, VisibleIndividually = true, Name = "The Battle Of Los Angeles", ShortDescription = "The Battle Of Los Angeles by Rage Against The Machine", FullDescription = "<p># Original Release Date: November 2, 1999<br /># Label: Epic<br /># Copyright: 1999 Sony Music Entertainment Inc. (c) 1999 Sony Music Entertainment Inc.</p>", ProductTemplateId = productTemplateSimple.Id, //SeName = "the-battle-of-los-angeles", AllowCustomerReviews = true, Price = 3M, TaxCategoryId = _taxCategoryRepository.Table.Single(tc => tc.Name == "Downloadable Products").Id, ManageInventoryMethod = ManageInventoryMethod.DontManageStock, StockQuantity = 10000, NotifyAdminForQuantityBelow = 1, AllowBackInStockSubscriptions = false, DisplayStockAvailability = true, LowStockActivity = LowStockActivity.DisableBuyButton, BackorderMode = BackorderMode.NoBackorders, OrderMinimumQuantity = 1, OrderMaximumQuantity = 10000, IsDownload = true, DownloadId = downloadBattleOfLa.Id, DownloadActivationType = DownloadActivationType.WhenOrderIsPaid, UnlimitedDownloads = true, HasUserAgreement = false, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; allProducts.Add(productBattleOfLa); productBattleOfLa.ProductCategories.Add(new ProductCategory() { Category = _categoryRepository.Table.Single(c => c.Name == "Digital downloads"), DisplayOrder = 1, }); productBattleOfLa.ProductPictures.Add(new ProductPicture() { Picture = pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_BattleOfLA.jpeg"), "image/jpeg", pictureService.GetPictureSeName(productBattleOfLa.Name), true), DisplayOrder = 1, }); _productRepository.Insert(productBattleOfLa); //search engine names foreach (var product in allProducts) { _urlRecordRepository.Insert(new UrlRecord() { EntityId = product.Id, EntityName = "Product", LanguageId = 0, IsActive = true, Slug = product.ValidateSeName("", product.Name, true) }); } //related products var relatedProducts = new List<RelatedProduct>() { new RelatedProduct() { ProductId1 = productDiamondHeart.Id, ProductId2 = productDiamondBracelet.Id, }, new RelatedProduct() { ProductId1 = productDiamondHeart.Id, ProductId2 = productDiamondEarrings.Id, }, new RelatedProduct() { ProductId1 = productDiamondHeart.Id, ProductId2 = productEngagementRing.Id, }, new RelatedProduct() { ProductId1 = productDiamondBracelet.Id, ProductId2 = productDiamondHeart.Id, }, new RelatedProduct() { ProductId1 = productDiamondBracelet.Id, ProductId2 = productEngagementRing.Id, }, new RelatedProduct() { ProductId1 = productDiamondBracelet.Id, ProductId2 = productDiamondEarrings.Id, }, new RelatedProduct() { ProductId1 = productEngagementRing.Id, ProductId2 = productDiamondHeart.Id, }, new RelatedProduct() { ProductId1 = productEngagementRing.Id, ProductId2 = productDiamondBracelet.Id, }, new RelatedProduct() { ProductId1 = productEngagementRing.Id, ProductId2 = productDiamondEarrings.Id, }, new RelatedProduct() { ProductId1 = productDiamondEarrings.Id, ProductId2 = productDiamondHeart.Id, }, new RelatedProduct() { ProductId1 = productDiamondEarrings.Id, ProductId2 = productDiamondBracelet.Id, }, new RelatedProduct() { ProductId1 = productDiamondEarrings.Id, ProductId2 = productEngagementRing.Id, }, new RelatedProduct() { ProductId1 = productSingleLadies.Id, ProductId2 = productPokerFace.Id, }, new RelatedProduct() { ProductId1 = productSingleLadies.Id, ProductId2 = productBattleOfLa.Id, }, new RelatedProduct() { ProductId1 = productPokerFace.Id, ProductId2 = productSingleLadies.Id, }, new RelatedProduct() { ProductId1 = productPokerFace.Id, ProductId2 = productBattleOfLa.Id, }, new RelatedProduct() { ProductId1 = productBestSkilletRecipes.Id, ProductId2 = productCookingForTwo.Id, }, new RelatedProduct() { ProductId1 = productBestSkilletRecipes.Id, ProductId2 = productEatingWell.Id, }, new RelatedProduct() { ProductId1 = productBestSkilletRecipes.Id, ProductId2 = productBestGrillingRecipes.Id, }, new RelatedProduct() { ProductId1 = productCookingForTwo.Id, ProductId2 = productBestSkilletRecipes.Id, }, new RelatedProduct() { ProductId1 = productCookingForTwo.Id, ProductId2 = productEatingWell.Id, }, new RelatedProduct() { ProductId1 = productCookingForTwo.Id, ProductId2 = productBestGrillingRecipes.Id, }, new RelatedProduct() { ProductId1 = productEatingWell.Id, ProductId2 = productBestSkilletRecipes.Id, }, new RelatedProduct() { ProductId1 = productEatingWell.Id, ProductId2 = productCookingForTwo.Id, }, new RelatedProduct() { ProductId1 = productEatingWell.Id, ProductId2 = productBestGrillingRecipes.Id, }, new RelatedProduct() { ProductId1 = productBestGrillingRecipes.Id, ProductId2 = productCookingForTwo.Id, }, new RelatedProduct() { ProductId1 = productBestGrillingRecipes.Id, ProductId2 = productEatingWell.Id, }, new RelatedProduct() { ProductId1 = productBestGrillingRecipes.Id, ProductId2 = productBestSkilletRecipes.Id, }, new RelatedProduct() { ProductId1 = productAsusPc900.Id, ProductId2 = productSatellite.Id, }, new RelatedProduct() { ProductId1 = productAsusPc900.Id, ProductId2 = productAsusPc1000.Id, }, new RelatedProduct() { ProductId1 = productAsusPc900.Id, ProductId2 = productHpPavilion1.Id, }, new RelatedProduct() { ProductId1 = productSatellite.Id, ProductId2 = productAsusPc900.Id, }, new RelatedProduct() { ProductId1 = productSatellite.Id, ProductId2 = productAsusPc1000.Id, }, new RelatedProduct() { ProductId1 = productSatellite.Id, ProductId2 = productAcerAspireOne.Id, }, new RelatedProduct() { ProductId1 = productAsusPc1000.Id, ProductId2 = productSatellite.Id, }, new RelatedProduct() { ProductId1 = productAsusPc1000.Id, ProductId2 = productHpPavilion1.Id, }, new RelatedProduct() { ProductId1 = productAsusPc1000.Id, ProductId2 = productAcerAspireOne.Id, }, new RelatedProduct() { ProductId1 = productHpPavilion3.Id, ProductId2 = productAsusPc900.Id, }, new RelatedProduct() { ProductId1 = productHpPavilion3.Id, ProductId2 = productAsusPc1000.Id, }, new RelatedProduct() { ProductId1 = productHpPavilion3.Id, ProductId2 = productAcerAspireOne.Id, }, new RelatedProduct() { ProductId1 = productHpPavilion1.Id, ProductId2 = productAsusPc900.Id, }, new RelatedProduct() { ProductId1 = productHpPavilion1.Id, ProductId2 = productAsusPc1000.Id, }, new RelatedProduct() { ProductId1 = productHpPavilion1.Id, ProductId2 = productAcerAspireOne.Id, }, new RelatedProduct() { ProductId1 = productCanonCamcoder.Id, ProductId2 = productSamsungPhone.Id, }, new RelatedProduct() { ProductId1 = productCanonCamcoder.Id, ProductId2 = productSonyCamcoder.Id, }, new RelatedProduct() { ProductId1 = productCanonCamcoder.Id, ProductId2 = productCanonCamera.Id, }, new RelatedProduct() { ProductId1 = productSonyCamcoder.Id, ProductId2 = productSamsungPhone.Id, }, new RelatedProduct() { ProductId1 = productSonyCamcoder.Id, ProductId2 = productCanonCamcoder.Id, }, new RelatedProduct() { ProductId1 = productSonyCamcoder.Id, ProductId2 = productCanonCamera.Id, }, }; relatedProducts.ForEach(rp => _relatedProductRepository.Insert(rp)); //product tags AddProductTag(product25GiftCard, "nice"); AddProductTag(product25GiftCard, "gift"); AddProductTag(product5GiftCard, "nice"); AddProductTag(product5GiftCard, "gift"); AddProductTag(productRockabillyPolka, "cool"); AddProductTag(productRockabillyPolka, "apparel"); AddProductTag(productRockabillyPolka, "shirt"); AddProductTag(productAcerAspireOne, "computer"); AddProductTag(productAcerAspireOne, "cool"); AddProductTag(productAdidasShoe, "cool"); AddProductTag(productAdidasShoe, "shoes"); AddProductTag(productAdidasShoe, "apparel"); AddProductTag(productAdobePhotoshop, "computer"); AddProductTag(productAdobePhotoshop, "awesome"); AddProductTag(productApcUps, "computer"); AddProductTag(productApcUps, "cool"); AddProductTag(productArrow, "cool"); AddProductTag(productArrow, "apparel"); AddProductTag(productArrow, "shirt"); AddProductTag(productAsusPc1000, "compact"); AddProductTag(productAsusPc1000, "awesome"); AddProductTag(productAsusPc1000, "computer"); AddProductTag(productAsusPc900, "compact"); AddProductTag(productAsusPc900, "awesome"); AddProductTag(productAsusPc900, "computer"); AddProductTag(productBestGrillingRecipes, "awesome"); AddProductTag(productBestGrillingRecipes, "book"); AddProductTag(productBestGrillingRecipes, "nice"); AddProductTag(productDiamondHeart, "awesome"); AddProductTag(productDiamondHeart, "jewelry"); AddProductTag(productBlackBerry, "cell"); AddProductTag(productBlackBerry, "compact"); AddProductTag(productBlackBerry, "awesome"); AddProductTag(productBuildComputer, "awesome"); AddProductTag(productBuildComputer, "computer"); AddProductTag(productCanonCamera, "cool"); AddProductTag(productCanonCamera, "camera"); AddProductTag(productCanonCamcoder, "camera"); AddProductTag(productCanonCamcoder, "cool"); AddProductTag(productCompaq, "cool"); AddProductTag(productCompaq, "computer"); AddProductTag(productCookingForTwo, "awesome"); AddProductTag(productCookingForTwo, "book"); AddProductTag(productCorel, "awesome"); AddProductTag(productCorel, "computer"); AddProductTag(productCustomTShirt, "cool"); AddProductTag(productCustomTShirt, "shirt"); AddProductTag(productCustomTShirt, "apparel"); AddProductTag(productDiamondEarrings, "jewelry"); AddProductTag(productDiamondEarrings, "awesome"); AddProductTag(productDiamondBracelet, "awesome"); AddProductTag(productDiamondBracelet, "jewelry"); AddProductTag(productEatingWell, "book"); AddProductTag(productEtnies, "cool"); AddProductTag(productEtnies, "shoes"); AddProductTag(productEtnies, "apparel"); AddProductTag(productLeatherHandbag, "apparel"); AddProductTag(productLeatherHandbag, "cool"); AddProductTag(productLeatherHandbag, "awesome"); AddProductTag(productHp506, "awesome"); AddProductTag(productHp506, "computer"); AddProductTag(productHpPavilion1, "nice"); AddProductTag(productHpPavilion1, "computer"); AddProductTag(productHpPavilion1, "compact"); AddProductTag(productHpPavilion2, "nice"); AddProductTag(productHpPavilion2, "computer"); AddProductTag(productHpPavilion3, "computer"); AddProductTag(productHpPavilion3, "cool"); AddProductTag(productHpPavilion3, "compact"); AddProductTag(productHat, "apparel"); AddProductTag(productHat, "cool"); AddProductTag(productKensington, "computer"); AddProductTag(productKensington, "cool"); AddProductTag(productLeviJeans, "cool"); AddProductTag(productLeviJeans, "jeans"); AddProductTag(productLeviJeans, "apparel"); AddProductTag(productBaseball, "game"); AddProductTag(productBaseball, "computer"); AddProductTag(productBaseball, "cool"); AddProductTag(productPokerFace, "awesome"); AddProductTag(productPokerFace, "digital"); AddProductTag(productSunglasses, "apparel"); AddProductTag(productSunglasses, "cool"); AddProductTag(productSamsungPhone, "awesome"); AddProductTag(productSamsungPhone, "compact"); AddProductTag(productSamsungPhone, "cell"); AddProductTag(productSingleLadies, "digital"); AddProductTag(productSingleLadies, "awesome"); AddProductTag(productSonyCamcoder, "awesome"); AddProductTag(productSonyCamcoder, "cool"); AddProductTag(productSonyCamcoder, "camera"); AddProductTag(productBattleOfLa, "digital"); AddProductTag(productBattleOfLa, "awesome"); AddProductTag(productBestSkilletRecipes, "book"); AddProductTag(productSatellite, "awesome"); AddProductTag(productSatellite, "computer"); AddProductTag(productSatellite, "compact"); AddProductTag(productDenimShort, "jeans"); AddProductTag(productDenimShort, "cool"); AddProductTag(productDenimShort, "apparel"); AddProductTag(productEngagementRing, "jewelry"); AddProductTag(productEngagementRing, "awesome"); AddProductTag(productWoW, "computer"); AddProductTag(productWoW, "cool"); AddProductTag(productWoW, "game"); AddProductTag(productSoccer, "game"); AddProductTag(productSoccer, "cool"); AddProductTag(productSoccer, "computer"); //reviews var random = new Random(); foreach (var product in allProducts) { if (product.ProductType != ProductType.SimpleProduct) continue; //only 3 of 4 products will have reviews if (random.Next(4) == 3) continue; //rating from 4 to 5 var rating = random.Next(4, 6); product.ProductReviews.Add(new ProductReview() { CustomerId = defaultCustomer.Id, ProductId = product.Id, IsApproved = true, Title = "Some sample review", ReviewText = string.Format("This sample review is for the {0}. I've been waiting for this product to be available. It is priced just right.", product.Name), //random (4 or 5) Rating = rating, HelpfulYesTotal = 0, HelpfulNoTotal = 0, CreatedOnUtc = DateTime.UtcNow }); product.ApprovedRatingSum = rating; product.ApprovedTotalReviews = product.ProductReviews.Count; _productRepository.Update(product); } }
/// <summary> /// Adds an attribute /// </summary> /// <param name="attributes">Attributes</param> /// <param name="pva">Product variant attribute</param> /// <param name="value">Value</param> /// <returns>Attributes</returns> public virtual string AddProductAttribute(string attributes, ProductVariantAttribute pva, string value) { string result = string.Empty; try { var xmlDoc = new XmlDocument(); if (String.IsNullOrEmpty(attributes)) { var element1 = xmlDoc.CreateElement("Attributes"); xmlDoc.AppendChild(element1); } else { xmlDoc.LoadXml(attributes); } var rootElement = (XmlElement)xmlDoc.SelectSingleNode(@"//Attributes"); XmlElement pvaElement = null; //find existing var nodeList1 = xmlDoc.SelectNodes(@"//Attributes/ProductVariantAttribute"); foreach (XmlNode node1 in nodeList1) { if (node1.Attributes != null && node1.Attributes["ID"] != null) { string str1 =node1.Attributes["ID"].InnerText.Trim(); int id = 0; if (int.TryParse(str1, out id)) { if (id == pva.Id) { pvaElement = (XmlElement)node1; break; } } } } //create new one if not found if (pvaElement == null) { pvaElement = xmlDoc.CreateElement("ProductVariantAttribute"); pvaElement.SetAttribute("ID", pva.Id.ToString()); rootElement.AppendChild(pvaElement); } var pvavElement = xmlDoc.CreateElement("ProductVariantAttributeValue"); pvaElement.AppendChild(pvavElement); var pvavVElement = xmlDoc.CreateElement("Value"); pvavVElement.InnerText = value; pvavElement.AppendChild(pvavVElement); result = xmlDoc.OuterXml; } catch (Exception exc) { Debug.Write(exc.ToString()); } return result; }
public new void SetUp() { #region Test data //color (dropdownlist) pa1 = new ProductAttribute { Id = 1, Name = "Color", }; pva1_1 = new ProductVariantAttribute { Id = 11, ProductId = 1, TextPrompt = "Select color:", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa1.Id }; pvav1_1 = new ProductVariantAttributeValue { Id = 11, Name = "Green", DisplayOrder = 1, ProductVariantAttribute = pva1_1, ProductVariantAttributeId = pva1_1.Id }; pvav1_2 = new ProductVariantAttributeValue { Id = 12, Name = "Red", DisplayOrder = 2, ProductVariantAttribute = pva1_1, ProductVariantAttributeId = pva1_1.Id }; pva1_1.ProductVariantAttributeValues.Add(pvav1_1); pva1_1.ProductVariantAttributeValues.Add(pvav1_2); //custom option (checkboxes) pa2 = new ProductAttribute { Id = 2, Name = "Some custom option", }; pva2_1 = new ProductVariantAttribute { Id = 21, ProductId = 1, TextPrompt = "Select at least one option:", IsRequired = true, AttributeControlType = AttributeControlType.Checkboxes, DisplayOrder = 2, ProductAttribute = pa2, ProductAttributeId = pa2.Id }; pvav2_1 = new ProductVariantAttributeValue { Id = 21, Name = "Option 1", DisplayOrder = 1, ProductVariantAttribute = pva2_1, ProductVariantAttributeId = pva2_1.Id }; pvav2_2 = new ProductVariantAttributeValue { Id = 22, Name = "Option 2", DisplayOrder = 2, ProductVariantAttribute = pva2_1, ProductVariantAttributeId = pva2_1.Id }; pva2_1.ProductVariantAttributeValues.Add(pvav2_1); pva2_1.ProductVariantAttributeValues.Add(pvav2_2); //custom text pa3 = new ProductAttribute { Id = 3, Name = "Custom text", }; pva3_1 = new ProductVariantAttribute { Id = 31, ProductId = 1, TextPrompt = "Enter custom text:", IsRequired = true, AttributeControlType = AttributeControlType.TextBox, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa3.Id }; #endregion _productAttributeRepo = MockRepository.GenerateMock<IRepository<ProductAttribute>>(); _productAttributeRepo.Expect(x => x.Table).Return(new List<ProductAttribute>() { pa1, pa2, pa3 }.AsQueryable()); _productAttributeRepo.Expect(x => x.GetById(pa1.Id)).Return(pa1); _productAttributeRepo.Expect(x => x.GetById(pa2.Id)).Return(pa2); _productAttributeRepo.Expect(x => x.GetById(pa3.Id)).Return(pa3); _productVariantAttributeRepo = MockRepository.GenerateMock<IRepository<ProductVariantAttribute>>(); _productVariantAttributeRepo.Expect(x => x.Table).Return(new List<ProductVariantAttribute>() { pva1_1, pva2_1, pva3_1 }.AsQueryable()); _productVariantAttributeRepo.Expect(x => x.GetById(pva1_1.Id)).Return(pva1_1); _productVariantAttributeRepo.Expect(x => x.GetById(pva2_1.Id)).Return(pva2_1); _productVariantAttributeRepo.Expect(x => x.GetById(pva3_1.Id)).Return(pva3_1); _productVariantAttributeCombinationRepo = MockRepository.GenerateMock<IRepository<ProductVariantAttributeCombination>>(); _productVariantAttributeCombinationRepo.Expect(x => x.Table).Return(new List<ProductVariantAttributeCombination>().AsQueryable()); _productVariantAttributeValueRepo = MockRepository.GenerateMock<IRepository<ProductVariantAttributeValue>>(); _productVariantAttributeValueRepo.Expect(x => x.Table).Return(new List<ProductVariantAttributeValue>() { pvav1_1, pvav1_2, pvav2_1, pvav2_2 }.AsQueryable()); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_1.Id)).Return(pvav1_1); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_2.Id)).Return(pvav1_2); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_1.Id)).Return(pvav2_1); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_2.Id)).Return(pvav2_2); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); var cacheManager = new NopNullCache(); _productAttributeService = new ProductAttributeService(cacheManager, _productAttributeRepo, _productVariantAttributeRepo, _productVariantAttributeCombinationRepo, _productVariantAttributeValueRepo, _eventPublisher); _productAttributeParser = new ProductAttributeParser(_productAttributeService); _priceCalculationService = MockRepository.GenerateMock<IPriceCalculationService>(); var workingLanguage = new Language(); _workContext = MockRepository.GenerateMock<IWorkContext>(); _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage); _currencyService = MockRepository.GenerateMock<ICurrencyService>(); _localizationService = MockRepository.GenerateMock<ILocalizationService>(); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Virtual")).Return("For: {0} <{1}>"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Virtual")).Return("From: {0} <{1}>"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Physical")).Return("For: {0}"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Physical")).Return("From: {0}"); _taxService = MockRepository.GenerateMock<ITaxService>(); _priceFormatter = MockRepository.GenerateMock<IPriceFormatter>(); _downloadService = MockRepository.GenerateMock<IDownloadService>(); _webHelper = MockRepository.GenerateMock<IWebHelper>(); _productAttributeFormatter = new ProductAttributeFormatter(_workContext, _productAttributeService, _productAttributeParser, _currencyService, _localizationService, _taxService, _priceFormatter, _downloadService, _webHelper, _priceCalculationService); }
/// <summary> /// Create a copy of product with all depended data /// </summary> /// <param name="product">The product to copy</param> /// <param name="newName">The name of product duplicate</param> /// <param name="isPublished">A value indicating whether the product duplicate should be published</param> /// <param name="copyImages">A value indicating whether the product images should be copied</param> /// <param name="copyAssociatedProducts">A value indicating whether the copy associated products</param> /// <returns>Product copy</returns> public virtual Product CopyProduct(Product product, string newName, bool isPublished = true, bool copyImages = true, bool copyAssociatedProducts = true) { if (product == null) throw new ArgumentNullException("product"); if (String.IsNullOrEmpty(newName)) throw new ArgumentException("Product name is required"); Product productCopy = null; //product download & sample download int downloadId = product.DownloadId; int sampleDownloadId = product.SampleDownloadId; if (product.IsDownload) { var download = _downloadService.GetDownloadById(product.DownloadId); if (download != null) { var downloadCopy = new Download() { DownloadGuid = Guid.NewGuid(), UseDownloadUrl = download.UseDownloadUrl, DownloadUrl = download.DownloadUrl, DownloadBinary = download.DownloadBinary, ContentType = download.ContentType, Filename = download.Filename, Extension = download.Extension, IsNew = download.IsNew, }; _downloadService.InsertDownload(downloadCopy); downloadId = downloadCopy.Id; } if (product.HasSampleDownload) { var sampleDownload = _downloadService.GetDownloadById(product.SampleDownloadId); if (sampleDownload != null) { var sampleDownloadCopy = new Download() { DownloadGuid = Guid.NewGuid(), UseDownloadUrl = sampleDownload.UseDownloadUrl, DownloadUrl = sampleDownload.DownloadUrl, DownloadBinary = sampleDownload.DownloadBinary, ContentType = sampleDownload.ContentType, Filename = sampleDownload.Filename, Extension = sampleDownload.Extension, IsNew = sampleDownload.IsNew }; _downloadService.InsertDownload(sampleDownloadCopy); sampleDownloadId = sampleDownloadCopy.Id; } } } // product productCopy = new Product() { ProductTypeId = product.ProductTypeId, ParentGroupedProductId = product.ParentGroupedProductId, VisibleIndividually = product.VisibleIndividually, Name = newName, ShortDescription = product.ShortDescription, FullDescription = product.FullDescription, VendorId = product.VendorId, ProductTemplateId = product.ProductTemplateId, AdminComment = product.AdminComment, ShowOnHomePage = product.ShowOnHomePage, MetaKeywords = product.MetaKeywords, MetaDescription = product.MetaDescription, MetaTitle = product.MetaTitle, AllowCustomerReviews = product.AllowCustomerReviews, LimitedToStores = product.LimitedToStores, Sku = product.Sku, ManufacturerPartNumber = product.ManufacturerPartNumber, Gtin = product.Gtin, IsGiftCard = product.IsGiftCard, GiftCardType = product.GiftCardType, FirstCostCurrencyType = product.FirstCostCurrencyType, RequireOtherProducts = product.RequireOtherProducts, RequiredProductIds = product.RequiredProductIds, AutomaticallyAddRequiredProducts = product.AutomaticallyAddRequiredProducts, IsDownload = product.IsDownload, DownloadId = downloadId, UnlimitedDownloads = product.UnlimitedDownloads, MaxNumberOfDownloads = product.MaxNumberOfDownloads, DownloadExpirationDays = product.DownloadExpirationDays, DownloadActivationType = product.DownloadActivationType, HasSampleDownload = product.HasSampleDownload, SampleDownloadId = sampleDownloadId, HasUserAgreement = product.HasUserAgreement, UserAgreementText = product.UserAgreementText, IsRecurring = product.IsRecurring, RecurringCycleLength = product.RecurringCycleLength, RecurringCyclePeriod = product.RecurringCyclePeriod, RecurringTotalCycles = product.RecurringTotalCycles, IsShipEnabled = product.IsShipEnabled, IsFreeShipping = product.IsFreeShipping, AdditionalShippingCharge = product.AdditionalShippingCharge, DeliveryDateId = product.DeliveryDateId, WarehouseId = product.WarehouseId, IsTaxExempt = product.IsTaxExempt, TaxCategoryId = product.TaxCategoryId, ManageInventoryMethod = product.ManageInventoryMethod, StockQuantity = product.StockQuantity, DisplayStockAvailability = product.DisplayStockAvailability, DisplayStockQuantity = product.DisplayStockQuantity, MinStockQuantity = product.MinStockQuantity, LowStockActivityId = product.LowStockActivityId, NotifyAdminForQuantityBelow = product.NotifyAdminForQuantityBelow, BackorderMode = product.BackorderMode, AllowBackInStockSubscriptions = product.AllowBackInStockSubscriptions, OrderMinimumQuantity = product.OrderMinimumQuantity, OrderMaximumQuantity = product.OrderMaximumQuantity, AllowedQuantities = product.AllowedQuantities, AllowAddingOnlyExistingAttributeCombinations = product.AllowAddingOnlyExistingAttributeCombinations, DisableBuyButton = product.DisableBuyButton, DisableWishlistButton = product.DisableWishlistButton, AvailableForPreOrder = product.AvailableForPreOrder, PreOrderAvailabilityStartDateTimeUtc = product.PreOrderAvailabilityStartDateTimeUtc, CallForPrice = product.CallForPrice, Price = product.Price, FirstCost = product.FirstCost, DollarPrice = product.DollarPrice, DesiredProfit = product.DesiredProfit, OldPrice = product.OldPrice, ProductCost = product.ProductCost, SpecialPrice = product.SpecialPrice, SpecialPriceStartDateTimeUtc = product.SpecialPriceStartDateTimeUtc, SpecialPriceEndDateTimeUtc = product.SpecialPriceEndDateTimeUtc, CustomerEntersPrice = product.CustomerEntersPrice, MinimumCustomerEnteredPrice = product.MinimumCustomerEnteredPrice, MaximumCustomerEnteredPrice = product.MaximumCustomerEnteredPrice, Weight = product.Weight, Length = product.Length, Width = product.Width, Height = product.Height, AvailableStartDateTimeUtc = product.AvailableStartDateTimeUtc, AvailableEndDateTimeUtc = product.AvailableEndDateTimeUtc, DisplayOrder = product.DisplayOrder, Published = isPublished, Deleted = product.Deleted, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; //validate search engine name _productService.InsertProduct(productCopy); //search engine name _urlRecordService.SaveSlug(productCopy, productCopy.ValidateSeName("", productCopy.Name, true), 0); var languages = _languageService.GetAllLanguages(true); //localization foreach (var lang in languages) { var name = product.GetLocalized(x => x.Name, lang.Id, false, false); if (!String.IsNullOrEmpty(name)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.Name, name, lang.Id); var shortDescription = product.GetLocalized(x => x.ShortDescription, lang.Id, false, false); if (!String.IsNullOrEmpty(shortDescription)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.ShortDescription, shortDescription, lang.Id); var fullDescription = product.GetLocalized(x => x.FullDescription, lang.Id, false, false); if (!String.IsNullOrEmpty(fullDescription)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.FullDescription, fullDescription, lang.Id); var metaKeywords = product.GetLocalized(x => x.MetaKeywords, lang.Id, false, false); if (!String.IsNullOrEmpty(metaKeywords)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.MetaKeywords, metaKeywords, lang.Id); var metaDescription = product.GetLocalized(x => x.MetaDescription, lang.Id, false, false); if (!String.IsNullOrEmpty(metaDescription)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.MetaDescription, metaDescription, lang.Id); var metaTitle = product.GetLocalized(x => x.MetaTitle, lang.Id, false, false); if (!String.IsNullOrEmpty(metaTitle)) _localizedEntityService.SaveLocalizedValue(productCopy, x => x.MetaTitle, metaTitle, lang.Id); //search engine name _urlRecordService.SaveSlug(productCopy, productCopy.ValidateSeName("", name, false), lang.Id); } //product tags foreach (var productTag in product.ProductTags) { productCopy.ProductTags.Add(productTag); } _productService.UpdateProduct(product); // product pictures //variant to store original and new picture identifiers var originalNewPictureIdentifiers = new Dictionary<int, int>(); if (copyImages) { foreach (var productPicture in product.ProductPictures) { var picture = productPicture.Picture; var pictureCopy = _pictureService.InsertPicture( _pictureService.LoadPictureBinary(picture), picture.MimeType, _pictureService.GetPictureSeName(newName), true); _productService.InsertProductPicture(new ProductPicture() { ProductId = productCopy.Id, PictureId = pictureCopy.Id, DisplayOrder = productPicture.DisplayOrder }); originalNewPictureIdentifiers.Add(picture.Id, pictureCopy.Id); } } // product <-> categories mappings foreach (var productCategory in product.ProductCategories) { var productCategoryCopy = new ProductCategory() { ProductId = productCopy.Id, CategoryId = productCategory.CategoryId, IsFeaturedProduct = productCategory.IsFeaturedProduct, DisplayOrder = productCategory.DisplayOrder }; _categoryService.InsertProductCategory(productCategoryCopy); } // product <-> manufacturers mappings foreach (var productManufacturers in product.ProductManufacturers) { var productManufacturerCopy = new ProductManufacturer() { ProductId = productCopy.Id, ManufacturerId = productManufacturers.ManufacturerId, IsFeaturedProduct = productManufacturers.IsFeaturedProduct, DisplayOrder = productManufacturers.DisplayOrder }; _manufacturerService.InsertProductManufacturer(productManufacturerCopy); } // product <-> releated products mappings foreach (var relatedProduct in _productService.GetRelatedProductsByProductId1(product.Id, true)) { _productService.InsertRelatedProduct( new RelatedProduct() { ProductId1 = productCopy.Id, ProductId2 = relatedProduct.ProductId2, DisplayOrder = relatedProduct.DisplayOrder }); } // product <-> cross sells mappings foreach (var csProduct in _productService.GetCrossSellProductsByProductId1(product.Id, true)) { _productService.InsertCrossSellProduct( new CrossSellProduct() { ProductId1 = productCopy.Id, ProductId2 = csProduct.ProductId2, }); } // product specifications foreach (var productSpecificationAttribute in product.ProductSpecificationAttributes) { var psaCopy = new ProductSpecificationAttribute() { ProductId = productCopy.Id, SpecificationAttributeOptionId = productSpecificationAttribute.SpecificationAttributeOptionId, CustomValue = productSpecificationAttribute.CustomValue, AllowFiltering = productSpecificationAttribute.AllowFiltering, ShowOnProductPage = productSpecificationAttribute.ShowOnProductPage, DisplayOrder = productSpecificationAttribute.DisplayOrder }; _specificationAttributeService.InsertProductSpecificationAttribute(psaCopy); } //store mapping var selectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(product); foreach (var id in selectedStoreIds) { _storeMappingService.InsertStoreMapping(productCopy, id); } // product <-> attributes mappings var associatedAttributes = new Dictionary<int, int>(); var associatedAttributeValues = new Dictionary<int, int>(); foreach (var productVariantAttribute in _productAttributeService.GetProductVariantAttributesByProductId(product.Id)) { var productVariantAttributeCopy = new ProductVariantAttribute() { ProductId = productCopy.Id, ProductAttributeId = productVariantAttribute.ProductAttributeId, TextPrompt = productVariantAttribute.TextPrompt, IsRequired = productVariantAttribute.IsRequired, AttributeControlTypeId = productVariantAttribute.AttributeControlTypeId, DisplayOrder = productVariantAttribute.DisplayOrder, ValidationMinLength = productVariantAttribute.ValidationMinLength, ValidationMaxLength = productVariantAttribute.ValidationMaxLength, ValidationFileAllowedExtensions = productVariantAttribute.ValidationFileAllowedExtensions, ValidationFileMaximumSize = productVariantAttribute.ValidationFileMaximumSize, DefaultValue = productVariantAttribute.DefaultValue, }; _productAttributeService.InsertProductVariantAttribute(productVariantAttributeCopy); //save associated value (used for combinations copying) associatedAttributes.Add(productVariantAttribute.Id, productVariantAttributeCopy.Id); // product variant attribute values var productVariantAttributeValues = _productAttributeService.GetProductVariantAttributeValues(productVariantAttribute.Id); foreach (var productVariantAttributeValue in productVariantAttributeValues) { int pvavPictureId = 0; if (originalNewPictureIdentifiers.ContainsKey(productVariantAttributeValue.PictureId)) { pvavPictureId = originalNewPictureIdentifiers[productVariantAttributeValue.PictureId]; } var pvavCopy = new ProductVariantAttributeValue() { ProductVariantAttributeId = productVariantAttributeCopy.Id, AttributeValueTypeId = productVariantAttributeValue.AttributeValueTypeId, AssociatedProductId = productVariantAttributeValue.AssociatedProductId, Name = productVariantAttributeValue.Name, ColorSquaresRgb = productVariantAttributeValue.ColorSquaresRgb, PriceAdjustment = productVariantAttributeValue.PriceAdjustment, WeightAdjustment = productVariantAttributeValue.WeightAdjustment, Cost = productVariantAttributeValue.Cost, Quantity = productVariantAttributeValue.Quantity, IsPreSelected = productVariantAttributeValue.IsPreSelected, DisplayOrder = productVariantAttributeValue.DisplayOrder, PictureId = pvavPictureId, }; _productAttributeService.InsertProductVariantAttributeValue(pvavCopy); //save associated value (used for combinations copying) associatedAttributeValues.Add(productVariantAttributeValue.Id, pvavCopy.Id); //localization foreach (var lang in languages) { var name = productVariantAttributeValue.GetLocalized(x => x.Name, lang.Id, false, false); if (!String.IsNullOrEmpty(name)) _localizedEntityService.SaveLocalizedValue(pvavCopy, x => x.Name, name, lang.Id); } } } //attribute combinations foreach (var combination in _productAttributeService.GetAllProductVariantAttributeCombinations(product.Id)) { //generate new AttributesXml according to new value IDs string newAttributesXml = ""; var parsedProductVariantAttributes = _productAttributeParser.ParseProductVariantAttributes(combination.AttributesXml); foreach (var oldPva in parsedProductVariantAttributes) { if (associatedAttributes.ContainsKey(oldPva.Id)) { int newPvaId = associatedAttributes[oldPva.Id]; var newPva = _productAttributeService.GetProductVariantAttributeById(newPvaId); if (newPva != null) { var oldPvaValuesStr = _productAttributeParser.ParseValues(combination.AttributesXml, oldPva.Id); foreach (var oldPvaValueStr in oldPvaValuesStr) { if (newPva.ShouldHaveValues()) { //attribute values int oldPvaValue = int.Parse(oldPvaValueStr); if (associatedAttributeValues.ContainsKey(oldPvaValue)) { int newPvavId = associatedAttributeValues[oldPvaValue]; var newPvav = _productAttributeService.GetProductVariantAttributeValueById(newPvavId); if (newPvav != null) { newAttributesXml = _productAttributeParser.AddProductAttribute(newAttributesXml, newPva, newPvav.Id.ToString()); } } } else { //just a text newAttributesXml = _productAttributeParser.AddProductAttribute(newAttributesXml, newPva, oldPvaValueStr); } } } } } var combinationCopy = new ProductVariantAttributeCombination() { ProductId = productCopy.Id, AttributesXml = newAttributesXml, StockQuantity = combination.StockQuantity, AllowOutOfStockOrders = combination.AllowOutOfStockOrders, Sku = combination.Sku, ManufacturerPartNumber = combination.ManufacturerPartNumber, Gtin = combination.Gtin, OverriddenPrice = combination.OverriddenPrice }; _productAttributeService.InsertProductVariantAttributeCombination(combinationCopy); } //tier prices foreach (var tierPrice in product.TierPrices) { _productService.InsertTierPrice( new TierPrice() { ProductId = productCopy.Id, StoreId = tierPrice.StoreId, CustomerRoleId = tierPrice.CustomerRoleId, Quantity = tierPrice.Quantity, Price = tierPrice.Price }); } // product <-> discounts mapping foreach (var discount in product.AppliedDiscounts) { productCopy.AppliedDiscounts.Add(discount); _productService.UpdateProduct(productCopy); } //update "HasTierPrices" and "HasDiscountsApplied" properties _productService.UpdateHasTierPricesProperty(productCopy); _productService.UpdateHasDiscountsApplied(productCopy); //associated products if (copyAssociatedProducts) { var associatedProducts = _productService.GetAssociatedProducts(product.Id, showHidden: true); foreach (var associatedProduct in associatedProducts) { var associatedProductCopy = CopyProduct(associatedProduct, string.Format("Copy of {0}", associatedProduct.Name), isPublished, copyImages, false); associatedProductCopy.ParentGroupedProductId = productCopy.Id; _productService.UpdateProduct(productCopy); } } return productCopy; }