Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .nuke

This file was deleted.

57 changes: 57 additions & 0 deletions src/VirtoCommerce.CatalogCsvImportModule.Core/Model/CsvProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Omu.ValueInjecter;
using VirtoCommerce.AssetsModule.Core.Assets;
using VirtoCommerce.CatalogModule.Core.Model;
Expand All @@ -15,6 +16,8 @@ namespace VirtoCommerce.CatalogCsvImportModule.Core.Model
public class CsvProduct : CatalogProduct
{
private readonly string[] _csvCellDelimiter = { "--", "|" };
private readonly string _localizedNameDelimiter = ";";
private readonly string _cultureValueDelimiter = "__";
private IBlobUrlResolver _blobUrlResolver;

public CsvProduct()
Expand Down Expand Up @@ -545,5 +548,59 @@ public void CreateImagesFromFlatData()

this.Images.AddRange(images);
}

public string LocalizedNameString
{
get
{
if (LocalizedName == null || LocalizedName.Values.Count == 0)
{
return Name;
}

var result = new StringBuilder(Name ?? string.Empty);

foreach (var localizedName in LocalizedName.Values)
{
if (!string.IsNullOrEmpty(localizedName.Key) && !string.IsNullOrEmpty(localizedName.Value))
{
result.Append(_localizedNameDelimiter);
result.Append(localizedName.Key);
result.Append(_cultureValueDelimiter);
result.Append(localizedName.Value);
}
}

return result.ToString();
}
set
{
if (string.IsNullOrEmpty(value))
{
return;
}

var parts = value.Split(new[] { _localizedNameDelimiter }, StringSplitOptions.None);

if (parts.Length > 0)
{
Name = parts[0];

if (parts.Length > 1)
{
LocalizedName = LocalizedName ?? new LocalizedString();

for (int i = 1; i < parts.Length; i++)
{
var cultureParts = parts[i].Split(new[] { _cultureValueDelimiter }, StringSplitOptions.None);
if (cultureParts.Length == 2)
{
LocalizedName.SetValue(cultureParts[0], cultureParts[1]);
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static CsvProductMappingConfiguration GetDefaultConfiguration()

public virtual IList<string> GetOptionalFields()
{
var optionalFields = ReflectionUtility.GetPropertyNames<CsvProduct>(x => x.Name, x => x.Id, x => x.Sku, x => x.CategoryPath, x => x.CategoryId, x => x.MainProductId,
var optionalFields = ReflectionUtility.GetPropertyNames<CsvProduct>(x => x.LocalizedNameString, x => x.Id, x => x.Sku, x => x.CategoryPath, x => x.CategoryId, x => x.MainProductId,
x => x.PrimaryImage, x => x.PrimaryImageGroup, x => x.AltImage, x => x.AltImageGroup,
x => x.SeoUrl, x => x.SeoTitle, x => x.SeoDescription, x => x.SeoLanguage, x => x.SeoStore, x => x.SeoMetaKeywords, x => x.SeoImageAlternativeText,
x => x.Review, x => x.ReviewType, x => x.IsActive, x => x.IsBuyable, x => x.TrackInventory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="ValueInjecter" Version="3.2.0" />
<PackageReference Include="VirtoCommerce.AssetsModule.Core" Version="3.808.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.822.0" />
<PackageReference Include="VirtoCommerce.CoreModule.Core" Version="3.808.0" />
<PackageReference Include="VirtoCommerce.InventoryModule.Core" Version="3.805.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.853.0" />
<PackageReference Include="VirtoCommerce.PricingModule.Core" Version="3.809.0" />
<PackageReference Include="VirtoCommerce.AssetsModule.Core" Version="3.810.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.867.0" />
<PackageReference Include="VirtoCommerce.CoreModule.Core" Version="3.820.0" />
<PackageReference Include="VirtoCommerce.InventoryModule.Core" Version="3.810.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.889.0" />
<PackageReference Include="VirtoCommerce.PricingModule.Core" Version="3.815.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private async Task ResolvePropertyDictionaryItems(List<CsvProduct> csvProducts,
// For existing propertyValue Alias should be already filled, we shouldn't rewrite it.
propertyValue.Alias = string.IsNullOrEmpty(propertyValue.Alias) ? propertyValue.Value.ToString() : propertyValue.Alias;

var existentDictItem = allDictItems.FirstOrDefault(x => x.PropertyId == propertyValue.PropertyId && x.Alias.EqualsInvariant(propertyValue.Alias));
var existentDictItem = allDictItems.FirstOrDefault(x => x.PropertyId == propertyValue.PropertyId && x.Alias.EqualsIgnoreCase(propertyValue.Alias));

if (existentDictItem == null)
{
Expand Down Expand Up @@ -671,7 +671,7 @@ private async Task<IList<Price>> GetMergedPriceByPriceList(IList<CsvPrice> price
var result = new List<Price>();
foreach (var price in pricesWithPriceListIds)
{
var existPrice = existentPrices.FirstOrDefault(x => x.ProductId.EqualsInvariant(price.ProductId) && x.PricelistId.EqualsInvariant(price.PricelistId));
var existPrice = existentPrices.FirstOrDefault(x => x.ProductId.EqualsIgnoreCase(price.ProductId) && x.PricelistId.EqualsIgnoreCase(price.PricelistId));

if (existPrice != null)
{
Expand Down Expand Up @@ -701,8 +701,8 @@ private async Task<IList<Price>> GetMergedPriceDefault(IList<CsvPrice> restPrice
var existPrices = (await _priceSearchService.SearchAsync(criteria)).Results;
foreach (var price in restPrices)
{
var existPrice = existPrices.FirstOrDefault(x => x.Currency.EqualsInvariant(price.Currency)
&& x.ProductId.EqualsInvariant(price.ProductId));
var existPrice = existPrices.FirstOrDefault(x => x.Currency.EqualsIgnoreCase(price.Currency)
&& x.ProductId.EqualsIgnoreCase(price.ProductId));

if (existPrice != null)
{
Expand Down Expand Up @@ -732,7 +732,7 @@ private async Task LoadProductDependencies(IEnumerable<CsvProduct> csvProducts,

//Try to set parent relations
//By id or code reference
var parentProduct = csvProducts.FirstOrDefault(x => !string.IsNullOrEmpty(csvProduct.MainProductId) && (x.Id.EqualsInvariant(csvProduct.MainProductId) || x.Code.EqualsInvariant(csvProduct.MainProductId)));
var parentProduct = csvProducts.FirstOrDefault(x => !string.IsNullOrEmpty(csvProduct.MainProductId) && (x.Id.EqualsIgnoreCase(csvProduct.MainProductId) || x.Code.EqualsIgnoreCase(csvProduct.MainProductId)));
csvProduct.MainProduct = parentProduct;
csvProduct.MainProductId = parentProduct != null ? parentProduct.Id : null;

Expand All @@ -746,7 +746,7 @@ private async Task LoadProductDependencies(IEnumerable<CsvProduct> csvProducts,
foreach (var property in csvProduct.Properties.ToArray())
{
//Try to find property for product
var inheritedProperty = inheritedProperties.FirstOrDefault(x => x.Name.EqualsInvariant(property.Name));
var inheritedProperty = inheritedProperties.FirstOrDefault(x => x.Name.EqualsIgnoreCase(property.Name));
if (inheritedProperty != null)
{
property.ValueType = inheritedProperty.ValueType;
Expand Down Expand Up @@ -839,7 +839,7 @@ private async Task MergeFromAlreadyExistProducts(IEnumerable<CsvProduct> csvProd
}
foreach (var csvProduct in csvProducts)
{
var existProduct = csvProduct.IsTransient() ? alreadyExistProducts.FirstOrDefault(x => x.Code.EqualsInvariant(csvProduct.Code)) : alreadyExistProducts.FirstOrDefault(x => x.Id == csvProduct.Id);
var existProduct = csvProduct.IsTransient() ? alreadyExistProducts.FirstOrDefault(x => x.Code.EqualsIgnoreCase(csvProduct.Code)) : alreadyExistProducts.FirstOrDefault(x => x.Id == csvProduct.Id);
if (existProduct != null)
{
csvProduct.MergeFrom(existProduct);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="CsvHelper" Version="33.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.CatalogModule.Data" Version="3.822.0" />
<PackageReference Include="VirtoCommerce.StoreModule.Core" Version="3.809.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Data" Version="3.867.0" />
<PackageReference Include="VirtoCommerce.StoreModule.Core" Version="3.817.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.CatalogCsvImportModule.Core\VirtoCommerce.CatalogCsvImportModule.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<None Remove="node_modules\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="VirtoCommerce.Platform.Hangfire" Version="3.853.0" />
<PackageReference Include="VirtoCommerce.Platform.Hangfire" Version="3.889.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtoCommerce.CatalogCsvImportModule.Core\VirtoCommerce.CatalogCsvImportModule.Core.csproj" />
Expand Down
12 changes: 6 additions & 6 deletions src/VirtoCommerce.CatalogCsvImportModule.Web/module.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<version>3.808.0</version>
<version-tag />

<platformVersion>3.853.0</platformVersion>
<platformVersion>3.889.0</platformVersion>
<dependencies>
<dependency id="VirtoCommerce.Assets" version="3.808.0" />
<dependency id="VirtoCommerce.Catalog" version="3.822.0" />
<dependency id="VirtoCommerce.Assets" version="3.810.0" />
<dependency id="VirtoCommerce.Catalog" version="3.867.0" />
<dependency id="VirtoCommerce.Core" version="3.808.0" />
<dependency id="VirtoCommerce.Inventory" version="3.805.0" />
<dependency id="VirtoCommerce.Pricing" version="3.809.0" />
<dependency id="VirtoCommerce.Store" version="3.809.0" />
<dependency id="VirtoCommerce.Inventory" version="3.810.0" />
<dependency id="VirtoCommerce.Pricing" version="3.815.0" />
<dependency id="VirtoCommerce.Store" version="3.817.0" />
</dependencies>

<title>CSV Catalog Export and Import Module</title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
HasUserAgreement,IsBuyable,TrackInventory,Sku,Name
HasUserAgreement,IsBuyable,TrackInventory,Sku,LocalizedNameString
false,no,false,CBLK21111,cblk21113-product-1
yes,true,yes,CBLK21112,cblk21113-product-2
yes,true,yes,CBLK21112,cblk21113-product-2
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Name,CategoryPath
cblk21113-product-1,TestCategory1
LocalizedNameString,CategoryPath
cblk21113-product-1,TestCategory1
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Name,CategoryPath,CategoryId,Id,Sku,ListPrice,SalePrice,Currency,Quantity,FulfillmentCenterId,Gtin,MainProductId,PrimaryImage,SeoUrl,SeoTitle,SeoDescription,Review,ReviewType,ProductType,ShippingType,Vendor,DownloadType,HasUserAgreement,IsBuyable,TrackInventory
cblk21113-product-1,TestCategory1,catId_1,429408,CBLK21113,123.4,456.7,EUR,1,FulfillmentCenterId_Value,GTIN_Value,mainprod_123,"http://localhost/image.jpg",seo-slug-url,Seo_Title_Value,Seo_Descr_Value,Review_Content,ReviewType_Value,ProductType_value,ShippingType_value,Vendor_value,DownloadType_value,true,true,true
LocalizedNameString,CategoryPath,CategoryId,Id,Sku,ListPrice,SalePrice,Currency,Quantity,FulfillmentCenterId,Gtin,MainProductId,PrimaryImage,SeoUrl,SeoTitle,SeoDescription,Review,ReviewType,ProductType,ShippingType,Vendor,DownloadType,HasUserAgreement,IsBuyable,TrackInventory
cblk21113-product-1,TestCategory1,catId_1,429408,CBLK21113,123.4,456.7,EUR,1,FulfillmentCenterId_Value,GTIN_Value,mainprod_123,"http://localhost/image.jpg",seo-slug-url,Seo_Title_Value,Seo_Descr_Value,Review_Content,ReviewType_Value,ProductType_value,ShippingType_value,Vendor_value,DownloadType_value,true,true,true
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Name,id,Sku
cblk21113-product-1,,429408
LocalizedNameString,id,Sku
cblk21113-product-1,,429408
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Name,Id,Sku,CategoryId,Gtin,MainProductId,PrimaryImage,ProductType,ShippingType,Vendor,DownloadType,HasUserAgreement,IsBuyable,TrackInventory,OuterId,PackageType,FulfillmentCenterId,MaxNumberOfDownload,Priority,MaxQuantity,MinQuantity
LocalizedNameString,Id,Sku,CategoryId,Gtin,MainProductId,PrimaryImage,ProductType,ShippingType,Vendor,DownloadType,HasUserAgreement,IsBuyable,TrackInventory,OuterId,PackageType,FulfillmentCenterId,MaxNumberOfDownload,Priority,MaxQuantity,MinQuantity
cblk21113-product-1,429408,CBLK21113,catId_1,GTIN_Value,mainprod_123,http://localhost/image.jpg,ProductType_value,ShippingType_value,Vendor_value,DownloadType_value,TRUE,TRUE,TRUE,OuterId,PackageType,FulfillmentCenterId,1,1,10,5