internal static List<ProductImportModel> ConvertCsvDataToProductImportModel(CsvData csvData, UploadConfig config)
        {
            List<ProductImportModel> dataToInsertInDatabase = new List<ProductImportModel>();
            foreach (var dataRow in csvData.Rows)
            {
                ProductImportModel rowToInsert = new ProductImportModel();
                rowToInsert.Title = dataRow[0];
                rowToInsert.ProductTypeTitle = dataRow[1];
                rowToInsert.Description = dataRow[2];
                rowToInsert.Url = dataRow[3];
                rowToInsert.Price = Convert.ToDecimal(dataRow[4]);
                rowToInsert.Weight = Convert.ToDecimal(dataRow[5]);
                rowToInsert.Sku = dataRow[6];

                rowToInsert.ImagesPath = dataRow[7].Split(config.MultipleItemsSeparator).ToList();
                rowToInsert.DocumentsAndFilesPath = dataRow[8].Split(config.MultipleItemsSeparator).ToList();
                rowToInsert.Departments = dataRow[9].Split(config.MultipleItemsSeparator).ToList();
                rowToInsert.Tags = dataRow[10].Split(config.MultipleItemsSeparator).ToList();

                rowToInsert.TrackInventory = GetTrackInventory(dataRow[11]);
                rowToInsert.InventoryAmount = GetSafeInt(dataRow[12]);
                rowToInsert.OutOfStockOption = GetOutOfStockOption(dataRow[13]);

                rowToInsert.IsActive = Convert.ToBoolean(dataRow[14]);

                rowToInsert.CustomFieldData = new List<CustomFieldData>();

                for (int i = 12; i < config.NumberOfColumns; i++)
                {
                    CustomFieldData customFieldData = new CustomFieldData { PropertyName = csvData.Header[i], PropertyValue = dataRow[i] };
                    rowToInsert.CustomFieldData.Add(customFieldData);
                }

                rowToInsert.CorrespondingRowData = dataRow;

                dataToInsertInDatabase.Add(rowToInsert);
            }
            return dataToInsertInDatabase;
        }
        internal static List<ProductImage> ImportImagesAndGetProductImages(ProductImportModel productImportModel, UploadConfig config)
        {
            List<ProductImageInfo> importedImages = ImagesImporter.ImportImages(productImportModel.ImagesPath, config);

            List<ProductImage> productImages = ImagesImporter.GetProductImages(importedImages);

            return productImages;
        }
 private static void ImportTags(UploadConfig config, List<ImportError> importErrors, ref int numberOfFailedRecords, ProductImportModel productImportModel, ref bool isFailedSet, Product product)
 {
     try
     {
         TagsImporter.ImportTags(product, productImportModel.Tags, config);
     }
     catch (Exception tagsEx)
     {
         if (!isFailedSet)
         {
             isFailedSet = true;
             numberOfFailedRecords++;
             importErrors.Add(new ImportError { ErrorMessage = tagsEx.Message, ErrorRow = productImportModel.CorrespondingRowData });
         }
     }
 }
        private static void ImportImages(UploadConfig config, CatalogManager catalogManager, List<ImportError> importErrors, ref int numberOfFailedRecords, ProductImportModel productImportModel, ref bool isFailedSet, Product product)
        {
            try
            {
                List<ProductImage> productImages = ImagesImporter.ImportImagesAndGetProductImages(productImportModel, config);
                product.Images.AddRange(productImages);

                catalogManager.SaveChanges();

                ContentLinkGenerator.GenerateContentLinksForProductImages(product);
            }
            catch (Exception imageEx)
            {
                if (!isFailedSet)
                {
                    isFailedSet = true;
                    numberOfFailedRecords++;
                    importErrors.Add(new ImportError { ErrorMessage = imageEx.Message, ErrorRow = productImportModel.CorrespondingRowData });
                }
            }
        }
        private static void ImportFiles(UploadConfig config, CatalogManager catalogManager, List<ImportError> importErrors, ref int numberOfFailedRecords, ProductImportModel productImportModel, ref bool isFailedSet, Product product)
        {
            try
            {
                List<ProductFile> productFiles = DocumentsAndFilesImporter.ImportDocumentsAndGetProductDocuments(productImportModel, config);
                product.DocumentsAndFiles.AddRange(productFiles);

                catalogManager.SaveChanges();

                ProductSynchronizer.UpdateProductDocumentsAndFilesLinks(product, DefaultProvider);
            }
            catch (Exception filesEx)
            {
                if (!isFailedSet)
                {
                    isFailedSet = true;
                    numberOfFailedRecords++;
                    importErrors.Add(new ImportError { ErrorMessage = filesEx.Message, ErrorRow = productImportModel.CorrespondingRowData });
                }
            }
        }
        internal static List<ProductFile> ImportDocumentsAndGetProductDocuments(ProductImportModel productImportModel, UploadConfig config)
        {
            List<ProductDocumentFileInfo> importedDocuments = DocumentsAndFilesImporter.ImportDocuments(productImportModel.DocumentsAndFilesPath, config);

            List<ProductFile> productDocumentsAndFiles = DocumentsAndFilesImporter.GetProductDocumentsAndFiles(importedDocuments);

            return productDocumentsAndFiles;
        }