My querys to import product directly into database

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
I have 100k products with no product photos to upload but the nopCommerce import program takes forever. I came to this forum to search and ask how to import products directly into database directly but no luck then I wrote the following queries. Hope it will help someone in the same situation. I'm not a nopCommerce expert. This queries have no warranty. Use for your own risk. Feel free to leave comments.

1. create the excel file using the upload format provided by nopcommerce.
2. import the excel file into sql server. In this example, I used Products_Imported_From_Excel_File as the table name
3. run the following queries

update Products_Imported_From_Excel_File set price=0 where price is null;
update Products_Imported_From_Excel_File set oldprice=0 where oldprice is null;
update Products_Imported_From_Excel_File set ProductCost=0 where ProductCost is null;

INSERT INTO Product
                      (ProductTypeId, ParentGroupedProductId, VisibleIndividually, Name, ShortDescription, FullDescription, ProductTemplateId, VendorId, ShowOnHomePage,
                      MetaKeywords, MetaDescription, MetaTitle, AllowCustomerReviews, ApprovedRatingSum, NotApprovedRatingSum, ApprovedTotalReviews, NotApprovedTotalReviews,
                      SubjectToAcl, LimitedToStores, HasTierPrices, HasDiscountsApplied, DisplayOrder, Deleted, Sku, UpdatedOnUtc, ManufacturerPartNumber, Gtin, IsGiftCard,
                      GiftCardTypeId, RequireOtherProducts, RequiredProductIds, AutomaticallyAddRequiredProducts, IsDownload, DownloadId, UnlimitedDownloads,
                      MaxNumberOfDownloads, DownloadActivationTypeId, HasSampleDownload, SampleDownloadId, HasUserAgreement, UserAgreementText, IsRecurring,
                      RecurringCycleLength, RecurringCyclePeriodId, RecurringTotalCycles, IsShipEnabled, IsFreeShipping, AdditionalShippingCharge, DeliveryDateId, WarehouseId,
                      IsTaxExempt, TaxCategoryId, ManageInventoryMethodId, StockQuantity, DisplayStockAvailability, DisplayStockQuantity, MinStockQuantity, LowStockActivityId,
                      NotifyAdminForQuantityBelow, BackorderModeId, AllowBackInStockSubscriptions, OrderMinimumQuantity, OrderMaximumQuantity, AllowedQuantities,
                      AllowAddingOnlyExistingAttributeCombinations, DisableBuyButton, DisableWishlistButton, AvailableForPreOrder, PreOrderAvailabilityStartDateTimeUtc, CallForPrice,
                      Price, OldPrice, ProductCost, SpecialPrice, SpecialPriceStartDateTimeUtc, SpecialPriceEndDateTimeUtc, CustomerEntersPrice, MinimumCustomerEnteredPrice,
                      MaximumCustomerEnteredPrice, Weight, Length, Width, Height, Published, CreatedOnUtc)
SELECT     ProductTypeId, ParentGroupedProductId, VisibleIndividually, Name,  [Short Description] ShortDescription, [Long Description]FullDescription, ProductTemplateId, VendorId, ShowOnHomePage,
                      MetaKeywords, MetaDescription, MetaTitle, AllowCustomerReviews, 0 AS ApprovedRatingSum, 0 AS NotApprovedRatingSum, 0 AS ApprovedTotalReviews,
                      0 AS NotApprovedTotalReviews, 0 AS SubjectToAcl, 0 AS LimitedToStores, 0 AS HasTierPrices, 0 AS HasDiscountsApplied, 0 AS DisplayOrder, 0 AS Deleted, SKU,
                      GETDATE() AS UpdatedOnUtc, ManufacturerPartNumber, Gtin, IsGiftCard, GiftCardTypeId, RequireOtherProducts, RequiredProductIds,
                      AutomaticallyAddRequiredProducts, IsDownload, DownloadId, UnlimitedDownloads, MaxNumberOfDownloads, DownloadActivationTypeId, HasSampleDownload,
                      SampleDownloadId, HasUserAgreement, UserAgreementText, IsRecurring, RecurringCycleLength, RecurringCyclePeriodId, RecurringTotalCycles, IsShipEnabled,
                      IsFreeShipping, AdditionalShippingCharge, DeliveryDateId, WarehouseId, IsTaxExempt, TaxCategoryId, ManageInventoryMethodId, StockQuantity,
                      DisplayStockAvailability, DisplayStockQuantity, MinStockQuantity, LowStockActivityId, NotifyAdminForQuantityBelow, BackorderModeId,
                      AllowBackInStockSubscriptions, OrderMinimumQuantity, OrderMaximumQuantity, AllowedQuantities, AllowAddingOnlyExistingAttributeCombinations,
                      DisableBuyButton, DisableWishlistButton, AvailableForPreOrder, PreOrderAvailabilityStartDateTimeUtc, CallForPrice, Price, OldPrice, ProductCost, SpecialPrice,
                      SpecialPriceStartDateTimeUtc, SpecialPriceEndDateTimeUtc, CustomerEntersPrice, MinimumCustomerEnteredPrice, MaximumCustomerEnteredPrice, Weight, Length,
                      Width, Height, Published, CreatedOnUtc
FROM         Products_Imported_From_Excel_File




INSERT INTO Product_Category_Mapping
                      (ProductId, CategoryId, IsFeaturedProduct, DisplayOrder)
SELECT     Product.Id, Products_Imported_From_Excel_File.CategoryIds, 0 AS Expr1, 1 AS Expr2
FROM         Products_Imported_From_Excel_File INNER JOIN
                      Product ON Products_Imported_From_Excel_File.SKU = Product.Sku AND Product.Deleted = 0




INSERT INTO UrlRecord
                      (EntityId, EntityName, Slug, IsActive, LanguageId)
SELECT     Product.Id, 'Product' AS Expr1, Products_Imported_From_Excel_File.SKU, 1 AS Expr2, 0 AS Expr3
FROM         Products_Imported_From_Excel_File INNER JOIN
                      Product ON Products_Imported_From_Excel_File.SKU = Product.Sku AND Product.Deleted = 0
8 years ago
There is an issue so far: the search won't return result if I search the some contents of the FullDescription. Anyone knows which table I should work on?
7 years ago
Necro'ing this thread, but did you ever complete your SQL scripts?  I'm looking at a similar problem.
7 years ago
CMDPrompt wrote:
Necro'ing this thread, but did you ever complete your SQL scripts?  I'm looking at a similar problem.

I only used it once. I remember it worked.  The search issue was caused by other things. The advanced search checkbox has to be checked if end user wants to search from full description.

I also found out later that nopcommerce's import program actually works. It's just very slow.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.