Skip to content

Commit 6e6d28f

Browse files
committed
Customer export filter for shipping and billing country was wrong.
Limit was ignored in export preview.
1 parent 36d763f commit 6e6d28f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,12 +1225,12 @@ private IQueryable<Customer> GetCustomerQuery(DataExporterContext ctx, int? skip
12251225

12261226
if (ctx.Filter.BillingCountryIds != null && ctx.Filter.BillingCountryIds.Any())
12271227
{
1228-
query = query.Where(x => x.BillingAddress != null && ctx.Filter.BillingCountryIds.Contains(x.BillingAddress.Id));
1228+
query = query.Where(x => x.BillingAddress != null && ctx.Filter.BillingCountryIds.Contains(x.BillingAddress.CountryId ?? 0));
12291229
}
12301230

12311231
if (ctx.Filter.ShippingCountryIds != null && ctx.Filter.ShippingCountryIds.Any())
12321232
{
1233-
query = query.Where(x => x.ShippingAddress != null && ctx.Filter.ShippingCountryIds.Contains(x.ShippingAddress.Id));
1233+
query = query.Where(x => x.ShippingAddress != null && ctx.Filter.ShippingCountryIds.Contains(x.ShippingAddress.CountryId ?? 0));
12341234
}
12351235

12361236
if (ctx.Filter.LastActivityFrom.HasValue)
@@ -2060,8 +2060,11 @@ public DataExportPreviewResult Preview(DataExportRequest request, int pageIndex)
20602060
var cancellation = new CancellationTokenSource(TimeSpan.FromMinutes(5.0));
20612061
var ctx = new DataExporterContext(request, cancellation.Token, true);
20622062

2063-
var unused = Init(ctx);
2064-
var skip = Math.Max(ctx.Request.Profile.Offset, 0) + (pageIndex * PageSize);
2063+
Init(ctx);
2064+
2065+
var limit = Math.Max(request.Profile.Limit, 0);
2066+
var take = limit > 0 && limit < PageSize ? limit : PageSize;
2067+
var skip = Math.Max(ctx.Request.Profile.Offset, 0) + (pageIndex * take);
20652068

20662069
if (!HasPermission(ctx))
20672070
{
@@ -2074,43 +2077,43 @@ public DataExportPreviewResult Preview(DataExportRequest request, int pageIndex)
20742077
{
20752078
case ExportEntityType.Product:
20762079
{
2077-
var items = GetProductQuery(ctx, skip, PageSize).ToList();
2080+
var items = GetProductQuery(ctx, skip, take).ToList();
20782081
items.Each(x => result.Data.Add(ToDynamic(ctx, x)));
20792082
}
20802083
break;
20812084
case ExportEntityType.Order:
20822085
{
2083-
var items = GetOrderQuery(ctx, skip, PageSize).ToList();
2086+
var items = GetOrderQuery(ctx, skip, take).ToList();
20842087
items.Each(x => result.Data.Add(ToDynamic(ctx, x)));
20852088
}
20862089
break;
20872090
case ExportEntityType.Category:
20882091
{
2089-
var items = GetCategoryQuery(ctx, skip, PageSize).ToList();
2092+
var items = GetCategoryQuery(ctx, skip, take).ToList();
20902093
items.Each(x => result.Data.Add(ToDynamic(ctx, x)));
20912094
}
20922095
break;
20932096
case ExportEntityType.Manufacturer:
20942097
{
2095-
var items = GetManufacturerQuery(ctx, skip, PageSize).ToList();
2098+
var items = GetManufacturerQuery(ctx, skip, take).ToList();
20962099
items.Each(x => result.Data.Add(ToDynamic(ctx, x)));
20972100
}
20982101
break;
20992102
case ExportEntityType.Customer:
21002103
{
2101-
var items = GetCustomerQuery(ctx, skip, PageSize).ToList();
2104+
var items = GetCustomerQuery(ctx, skip, take).ToList();
21022105
items.Each(x => result.Data.Add(ToDynamic(ctx, x)));
21032106
}
21042107
break;
21052108
case ExportEntityType.NewsLetterSubscription:
21062109
{
2107-
var items = GetNewsLetterSubscriptionQuery(ctx, skip, PageSize).ToList();
2110+
var items = GetNewsLetterSubscriptionQuery(ctx, skip, take).ToList();
21082111
items.Each(x => result.Data.Add(ToDynamic(ctx, x)));
21092112
}
21102113
break;
21112114
case ExportEntityType.ShoppingCartItem:
21122115
{
2113-
var items = GetShoppingCartItemQuery(ctx, skip, PageSize).ToList();
2116+
var items = GetShoppingCartItemQuery(ctx, skip, take).ToList();
21142117
items.Each(x => result.Data.Add(ToDynamic(ctx, x)));
21152118
}
21162119
break;

0 commit comments

Comments
 (0)