Skip to content

Commit 7158f24

Browse files
committed
Export: Some improvements
1 parent 4571fd8 commit 7158f24

8 files changed

Lines changed: 49 additions & 32 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* #637 Integrated PayPal PLUS payment provider
88
* #932 Implement paydirekt payment plugin
99
* New Viveum payment plugin
10+
* #979 Implement BeezUP product feed
1011

1112
### New Features
1213
* #637 Integrated PayPal PLUS payment Provider

src/Libraries/SmartStore.Core/Domain/DataExchange/ExportEnums.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@ public enum ExportFeatures
126126
/// <summary>
127127
/// Whether to not automatically send a completion email
128128
/// </summary>
129-
CanOmitCompletionMail = 1 << 12
129+
CanOmitCompletionMail = 1 << 12,
130+
131+
/// <summary>
132+
/// Whether to provide additional data of attribute combinations
133+
/// </summary>
134+
UsesAttributeCombination = 1 << 13
130135
}
131136

132137
/// <summary>

src/Libraries/SmartStore.Services/Catalog/IProductAttributeParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ public partial interface IProductAttributeParser
3535
/// <summary>
3636
/// Get list of localized product variant attribute values
3737
/// </summary>
38-
/// <param name="attributesXml">XML formatted attributes</param>
38+
/// <param name="attributeCombination">Map of combined attributes</param>
3939
/// <param name="attributes">Product variant attributes</param>
4040
/// <param name="languageId">Language identifier</param>
4141
/// <returns>List of localized product variant attribute values</returns>
42-
IList<string> ParseProductVariantAttributeValues(string attributesXml, IEnumerable<ProductVariantAttribute> attributes, int languageId = 0);
42+
IList<string> ParseProductVariantAttributeValues(Multimap<int, string> attributeCombination, IEnumerable<ProductVariantAttribute> attributes, int languageId = 0);
4343

4444
/// <summary>
4545
/// Gets selected product variant attribute value

src/Libraries/SmartStore.Services/Catalog/ProductAttributeParser.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,20 @@ where id.HasValue()
194194
return values;
195195
}
196196

197-
public IList<string> ParseProductVariantAttributeValues(string attributesXml, IEnumerable<ProductVariantAttribute> attributes, int languageId = 0)
197+
public virtual IList<string> ParseProductVariantAttributeValues(Multimap<int, string> attributeCombination, IEnumerable<ProductVariantAttribute> attributes, int languageId = 0)
198198
{
199199
var values = new List<string>();
200200

201-
if (attributesXml.IsEmpty())
201+
if (attributeCombination == null || !attributeCombination.Any())
202202
return values;
203203

204204
var allValueIds = new List<int>();
205-
var combinedAttributes = DeserializeProductVariantAttributes(attributesXml);
206205

207206
foreach (var pva in attributes.Where(x => x.ShouldHaveValues()).OrderBy(x => x.DisplayOrder))
208207
{
209-
if (combinedAttributes.ContainsKey(pva.Id))
208+
if (attributeCombination.ContainsKey(pva.Id))
210209
{
211-
var pvaValuesStr = combinedAttributes[pva.Id];
210+
var pvaValuesStr = attributeCombination[pva.Id];
212211
var ids = pvaValuesStr.Where(x => x.HasValue()).Select(x => x.ToInt());
213212

214213
allValueIds.AddRange(ids);

src/Libraries/SmartStore.Services/DataExchange/Csv/CsvWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public CsvConfiguration Configuration
5151
/// to complete writing of the current row.
5252
/// </summary>
5353
/// <param name="fields">The fields to write.</param>
54-
public virtual void WriteFields(string[] fields)
54+
public virtual void WriteFields(IEnumerable<string> fields)
5555
{
5656
Guard.ArgumentNotNull(() => fields);
5757
fields.Each(x => WriteField(x));
@@ -69,7 +69,7 @@ public virtual void WriteFields(string[] fields)
6969
/// </summary>
7070
/// <param name="fields">The fields to write.</param>
7171
/// <param name="shouldQuote">True to quote the fields, otherwise false.</param>
72-
public virtual void WriteFields(string[] fields, bool shouldQuote)
72+
public virtual void WriteFields(IEnumerable<string> fields, bool shouldQuote)
7373
{
7474
Guard.ArgumentNotNull(() => fields);
7575
fields.Each(x => WriteField(x, shouldQuote));

src/Libraries/SmartStore.Services/DataExchange/Export/DataExporter.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,8 +1065,12 @@ private void ExportCoreInner(DataExporterContext ctx, Store store)
10651065

10661066
logHead.AppendLine("Entity:\t\t\t" + ctx.Request.Provider.Value.EntityType.ToString());
10671067

1068-
var storeInfo = (ctx.Request.Profile.PerStore ? "{0} (Id {1})".FormatInvariant(ctx.Store.Name, ctx.Store.Id) : "All stores");
1069-
logHead.AppendLine("Store:\t\t\t" + storeInfo);
1068+
try
1069+
{
1070+
var uri = new Uri(store.Url);
1071+
logHead.AppendLine("Store:\t\t\t{0} (Id {1})".FormatInvariant(uri.DnsSafeHost.NaIfEmpty(), ctx.Store.Id));
1072+
}
1073+
catch { }
10701074

10711075
var customer = _services.WorkContext.CurrentCustomer;
10721076
logHead.Append("Executed by:\t\t" + (customer.Email.HasValue() ? customer.Email : customer.SystemName));

src/Libraries/SmartStore.Services/DataExchange/Export/DynamicEntityHelper.cs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -578,14 +578,14 @@ private dynamic ToDynamic(
578578

579579
#region gerneral data
580580

581-
dynObject.Price = CalculatePrice(ctx, product, combination != null);
582-
583-
if (combination != null && ctx.Projection.AttributeCombinationValueMerging == ExportAttributeValueMerging.AppendAllValuesToName)
584-
{
585-
var values = _productAttributeParser.Value.ParseProductVariantAttributeValues(combination.AttributesXml, productAttributes, ctx.Projection.LanguageId ?? 0);
581+
dynObject._CategoryName = null;
582+
dynObject._CategoryPath = null;
583+
dynObject._AttributeCombination = null;
584+
dynObject._AttributeCombinationValues = null;
585+
dynObject._AttributeCombinationId = (combination == null ? 0 : combination.Id);
586+
dynObject._DetailUrl = ctx.Store.Url.EnsureEndsWith("/") + (string)dynObject.SeName;
586587

587-
dynObject.Name = ((string)dynObject.Name).Grow(string.Join(", ", values), " ");
588-
}
588+
dynObject.Price = CalculatePrice(ctx, product, combination != null);
589589

590590
dynObject._BasePriceInfo = product.GetBasePriceInfo(_services.Localization, _priceFormatter.Value, _currencyService.Value, _taxService.Value,
591591
_priceCalculationService.Value, ctx.ContextCurrency, decimal.Zero, true);
@@ -595,21 +595,34 @@ private dynamic ToDynamic(
595595
else
596596
dynObject._ProductTemplateViewPath = "";
597597

598-
var detailUrl = ctx.Store.Url.EnsureEndsWith("/") + (string)dynObject.SeName;
599-
600598
if (combination != null)
601599
{
600+
if (ctx.Supports(ExportFeatures.UsesAttributeCombination) ||
601+
ctx.Projection.AttributeCombinationValueMerging == ExportAttributeValueMerging.AppendAllValuesToName)
602+
{
603+
var variantAttributes = _productAttributeParser.Value.DeserializeProductVariantAttributes(combination.AttributesXml);
604+
var variantAttributeValues = _productAttributeParser.Value.ParseProductVariantAttributeValues(variantAttributes, productAttributes, languageId);
605+
606+
if (ctx.Supports(ExportFeatures.UsesAttributeCombination))
607+
{
608+
dynObject._AttributeCombination = variantAttributes;
609+
dynObject._AttributeCombinationValues = variantAttributeValues;
610+
}
611+
612+
if (ctx.Projection.AttributeCombinationValueMerging == ExportAttributeValueMerging.AppendAllValuesToName)
613+
{
614+
dynObject.Name = ((string)dynObject.Name).Grow(string.Join(", ", variantAttributeValues), " ");
615+
}
616+
}
617+
602618
var attributeQueryString = _productAttributeParser.Value.SerializeQueryData(combination.AttributesXml, product.Id);
603619
if (attributeQueryString.HasValue())
604620
{
605-
detailUrl = string.Concat(detailUrl, detailUrl.Contains("?") ? "&" : "?", "attributes=", attributeQueryString);
621+
var url = (string)dynObject._DetailUrl;
622+
dynObject._DetailUrl = string.Concat(url, url.Contains("?") ? "&" : "?", "attributes=", attributeQueryString);
606623
}
607624
}
608625

609-
dynObject._IsChild = (combination != null);
610-
dynObject._DetailUrl = detailUrl;
611-
dynObject._CategoryName = null;
612-
613626
if (ctx.Categories.Count > 0)
614627
{
615628
dynObject._CategoryPath = _categoryService.Value.GetCategoryPath(
@@ -621,13 +634,8 @@ private dynamic ToDynamic(
621634
productCategories.OrderBy(x => x.DisplayOrder).FirstOrDefault()
622635
);
623636
}
624-
else
625-
{
626-
dynObject._CategoryPath = null;
627-
}
628637

629638
ToDeliveryTime(ctx, dynObject, product.DeliveryTimeId);
630-
631639
ToQuantityUnit(ctx, dynObject, product.QuantityUnitId);
632640

633641
dynObject.ProductPictures = productPictures

src/Presentation/SmartStore.Web/Administration/Views/Export/_Tab.Deployment.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
{
105105
<div class="alert alert-info">
106106
<button type="button" class="close" data-dismiss="alert">&#215;</button>
107-
@T("Admin.DataExchange.Export.NoProfiles")
107+
@T("Admin.DataExchange.Export.Deployment.NoProfiles")
108108
</div>
109109
}
110110

0 commit comments

Comments
 (0)