Skip to content

Commit 929592d

Browse files
committed
More on import/export enhancements
1 parent 0263026 commit 929592d

5 files changed

Lines changed: 45 additions & 18 deletions

File tree

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ public enum ExportEntityType
1515
NewsLetterSubscription,
1616
ShoppingCartItem,
1717

18-
// Related data
19-
TierPrice = 100
20-
}
18+
// Related data (data without own export provider or importer).
19+
TierPrice = 100,
20+
ProductVariantAttribute,
21+
ProductVariantAttributeValue,
22+
ProductVariantAttributeCombination,
23+
ProductSpecificationAttribute
24+
}
2125

2226
/// <summary>
2327
/// Supported deployment types
@@ -140,7 +144,12 @@ public enum ExportFeatures
140144
/// <summary>
141145
/// Whether to export attribute combinations as products including parent product. Only effective with CanProjectAttributeCombinations.
142146
/// </summary>
143-
UsesAttributeCombinationParent = 1 << 14
147+
UsesAttributeCombinationParent = 1 << 14,
148+
149+
/// <summary>
150+
/// Whether to provide extra data units for related data
151+
/// </summary>
152+
UsesRelatedDataUnits = 1 << 15
144153
}
145154

146155
/// <summary>

src/Libraries/SmartStore.Data/Migrations/MigrationsConfiguration.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,12 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
577577
builder.AddOrUpdate("Admin.Configuration.Settings.CustomerUser.AddressFormFields.Description",
578578
"Manage form fields that are displayed during checkout and on \"My account\" page.",
579579
"Verwalten Sie Formularfelder, die während des Checkout-Prozesses und im \"Mein Konto\" Bereich angezeigt werden.");
580+
581+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.DataExchange.ExportEntityType.TierPrice", "Tier price", "Staffelpreis");
582+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.DataExchange.ExportEntityType.ProductVariantAttribute", "Product variant attribute", "Produkt Variant Attribut");
583+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.DataExchange.ExportEntityType.ProductVariantAttributeValue", "Product attribute option", "Produkt Attribut Option");
584+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.DataExchange.ExportEntityType.ProductVariantAttributeCombination", "Product attribute combination", "Produkt Attribut Kombination");
585+
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.DataExchange.ExportEntityType.ProductSpecificationAttribute", "Product specification attribute", "Produkt Spezifikations Attribut");
580586
}
581587
}
582588
}

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -496,26 +496,37 @@ private IExportDataSegmenterProvider CreateSegmenter(DataExporterContext ctx, in
496496
return ctx.ExecuteContext.DataSegmenter as IExportDataSegmenterProvider;
497497
}
498498

499-
private void AddUnitsForRelatedData(DataExporterContext ctx)
499+
private IEnumerable<ExportDataUnit> GetRelatedDataUnits(DataExporterContext ctx)
500500
{
501-
if (ctx.Request.Provider.Value.EntityType != ExportEntityType.Product)
502-
{
503-
return;
504-
}
501+
// Related data is data without own export provider or importer. For a flat formatted export
502+
// they have to be exported together with metadata to know what to be edited.
503+
ExportEntityType[] types = null;
505504

506-
var entityTypes = new ExportEntityType[]
505+
switch (ctx.Request.Provider.Value.EntityType)
507506
{
508-
ExportEntityType.TierPrice
509-
};
507+
case ExportEntityType.Product:
508+
types = new ExportEntityType[]
509+
{
510+
ExportEntityType.TierPrice,
511+
ExportEntityType.ProductVariantAttribute,
512+
ExportEntityType.ProductVariantAttributeValue,
513+
ExportEntityType.ProductVariantAttributeCombination,
514+
ExportEntityType.ProductSpecificationAttribute
515+
};
516+
break;
517+
default:
518+
return Enumerable.Empty<ExportDataUnit>();
519+
}
510520

521+
var result = new List<ExportDataUnit>();
511522
var context = ctx.ExecuteContext;
512523
var fileExtension = Path.GetExtension(context.FileName);
513524

514-
foreach (var type in entityTypes)
525+
foreach (var type in types)
515526
{
516527
var fileName = ctx.Request.Profile.ResolveFileNamePattern(ctx.Store, context.FileIndex, context.MaxFileNameLength, type.ToString()) + fileExtension;
517528

518-
context.ExtraDataUnits.Add(new ExportDataUnit
529+
result.Add(new ExportDataUnit
519530
{
520531
IsRelatedData = true,
521532
EntityType = type,
@@ -524,6 +535,8 @@ private void AddUnitsForRelatedData(DataExporterContext ctx)
524535
DataStream = new MemoryStream()
525536
});
526537
}
538+
539+
return result;
527540
}
528541

529542
private bool CallProvider(DataExporterContext ctx, string method, string path)
@@ -1372,9 +1385,9 @@ private void ExportCoreInner(DataExporterContext ctx, Store store)
13721385
context.FileName = profile.ResolveFileNamePattern(ctx.Store, context.FileIndex, context.MaxFileNameLength) + fileExtension;
13731386
path = Path.Combine(context.Folder, context.FileName);
13741387

1375-
if (profile.ExportRelatedData)
1388+
if (profile.ExportRelatedData && ctx.Supports(ExportFeatures.UsesRelatedDataUnits))
13761389
{
1377-
AddUnitsForRelatedData(ctx);
1390+
context.ExtraDataUnits.AddRange(GetRelatedDataUnits(ctx));
13781391
}
13791392
}
13801393

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ public void WriteProduct(dynamic product, string node)
752752
_writer.Write("BasePriceAmount", entityPvac.BasePriceAmount.HasValue ? entityPvac.BasePriceAmount.Value.ToString(_culture) : "");
753753
_writer.Write("BasePriceBaseAmount", entityPvac.BasePriceBaseAmount.HasValue ? entityPvac.BasePriceBaseAmount.Value.ToString() : "");
754754
_writer.Write("AssignedPictureIds", entityPvac.AssignedPictureIds);
755-
_writer.Write("DeliveryTimeId", entityPvac.DeliveryTimeId.HasValue ? entityPvac.DeliveryTimeId.Value.ToString() : "");
756755
_writer.Write("IsActive", entityPvac.IsActive.ToString());
757756

758757
WriteDeliveryTime(combination.DeliveryTime, "DeliveryTime");

src/Presentation/SmartStore.Web/Administration/Views/Export/Edit.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
@Html.ValidationMessageFor(x => x.Enabled)
122122
</td>
123123
</tr>
124-
@if (Model.Provider.EntityType == ExportEntityType.Product && Model.Provider.IsFileBasedExport)
124+
@if (Model.Provider.IsFileBasedExport && Model.Provider.Feature.HasFlag(ExportFeatures.UsesRelatedDataUnits))
125125
{
126126
<tr>
127127
<td class="adminTitle">

0 commit comments

Comments
 (0)