Andyphillips99 wrote:Hey Guys!
Have maually added a HEAP of products onto my new site... However each one has several variants, which are BASIC bits of information like sizes etc..
How can I Import these from a database or into the database? What's the fastest way?
If I do it from a database for example, how will it assign the various variants TO each main product??
Thanks :) :)
I can tell you the changes I made to do it. Only about 10% of my products were variants.
The changes were in:
C:\Projects\DisneyShopping180\Libraries\Nop.BusinessLogic\ExportImport\ImportManager.cs
public static void ImportProductsFromXls(string filePath)
I made 2 changes:
1) I added a column to the excel spreadsheet... VariantName ( I set it to size for clothes and blank otherwise
code change to read it:
string VariantName = dr["VariantName"].ToString();
2) The import code just updated the product info and main product variant if it encountered a SKU that already existed. I changed the code to insert a new variant if the SKU already existed.
So the new code:
if (productVariant != null) // sku already exists
{
var product = ProductManager.GetProductById(productVariant.ProductId);
// do not update product
//product = ProductManager.UpdateProduct( ... )
//Insert new variant instead of updating... pass in VariantName
productVariant = ProductManager.
InsertProductVariant(product.ProductId,
VariantName, SKU, string.Empty, string.Empty, ManufacturerPartNumber,
IsGiftCard, GiftCardType, IsDownload, DownloadId,
UnlimitedDownloads, MaxNumberOfDownloads, null, (DownloadActivationTypeEnum)DownloadActivationType,
HasSampleDownload, SampleDownloadId, HasUserAgreement, UserAgreementText, IsRecurring, CycleLength, CyclePeriod, TotalCycles,
IsShipEnabled, IsFreeShipping, AdditionalShippingCharge, IsTaxExempt,
TaxCategoryId, ManageInventory, StockQuantity,
DisplayStockAvailability, DisplayStockQuantity, MinStockQuantity,
(LowStockActivityEnum)LowStockActivityId, NotifyAdminForQuantityBelow,
Backorders, OrderMinimumQuantity,
OrderMaximumQuantity, 0, DisableBuyButton, CallForPrice,
Price, OldPrice, ProductCost, CustomerEntersPrice,
MinimumCustomerEnteredPrice, MaximumCustomerEnteredPrice,
Weight, Length, Width, Height, 0, null, null,
true, false, 1, CreatedOn, DateTime.UtcNow);
}