Hi
I would like to fetch orders from database but want to Litium’s own OrderViewFilteringInfo, is there a way to filter orders from one customerid, additionalInfo and websiteId?
maybe using CustomFilter or CustomFilterColumns?
Litium version: 6.2
Hi
I would like to fetch orders from database but want to Litium’s own OrderViewFilteringInfo, is there a way to filter orders from one customerid, additionalInfo and websiteId?
maybe using CustomFilter or CustomFilterColumns?
Litium version: 6.2
If you still need help with this topic you can escalate this to Litium support for help.
This sample method is not exactly what you ask for but shows how OrderViewFilteringInfo
can be used so perhaps you can use it as a starting point to create your query:
public IHttpActionResult Search([FromBody]OrderSearchModel model)
{
if (model is null)
{
ModelState.AddModelError(string.Empty, "Missing body.");
}
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (!_authorizationService.HasOperation(Operations.Function.Sales.Content))
{
return Unauthorized();
}
var filterInfo = new OrderViewFilteringInfo(
model.Filter.OrderDateUtc?.From?.ToLocalTime().DateTime ?? DateTime.MinValue,
model.Filter.OrderDateUtc?.To?.ToLocalTime().DateTime ?? DateTime.MaxValue,
model.Filter.OrderState ?? -1,
model.Filter.Text?.Replace('*', '%').Replace('?', '_'),
(model.Filter.FilterColumns ?? Enum.GetValues(typeof(OrderFilterColumn)).OfType<OrderFilterColumn>()).Select(x => x.ToString()).ToList(),
null, // orderids
string.Join(",", model.Filter.PaymentStates ?? new List<short>()), // payment statues
string.Join(",", model.Filter.DeliveryStates ?? new List<short>()), // deliverystatuses
model.Filter.WebsiteSystemId ?? Guid.Empty,
model.Filter.OrderType ?? OrderType.None);
var pageInfo = new PagingInfo(1, model.Take ?? int.MaxValue, model.Skip.GetValueOrDefault());
var sortInfo = new OrderViewSortingInfo(
model.Sort.Direction,
model.Sort.FieldId);
QueryInfo queryInfo = new QueryInfo(
new AdditionalInfo(model.Filter.AdditionalFilterKeys ?? new List<string>()),
filterInfo,
pageInfo,
sortInfo
);
var orderViewRows = _module.Orders.GetOrderViewRows(queryInfo, SecurityToken.CurrentSecurityToken);
var orders = _module.Orders.GetOrders(orderViewRows.Select(x => x.OrderID), SecurityToken.CurrentSecurityToken).ToList();
var orderCarriers = orders.Select(x => x.GetAsCarrier(true, true, true, true, true, true)).Select(RemoveOrderCarrierProperties).ToList();
return Ok(new SearchResult<OrderCarrier>
{
Total = pageInfo.TotalRecordCount,
Items = orderCarriers
});
}
Values for the enum Litium.Web.WebApi.AdminApi.Sales.OrderFilterColumn
:
public enum OrderFilterColumn
{
Address1,
Address2,
City,
Country,
CustomerNumber,
Email,
ExternalOrderID,
FirstName,
LastName,
MobilePhone,
Phone,
State,
OrganizationName,
Zip,
Title,
CareOf,
HouseNumber,
HouseExtension,
}
var orderViewFilteringInfo = new OrderViewFilteringInfo()
{
CustomFilter = string.Empty, <-----what kind of customFilter can i use and how
CustomFilterColumns = new List<string>(),<-----what kind of customFilter can i use and how
DeliveryStatuses = string.Empty,
EndDate = dateTime.Now,
OrderIDs = string.Empty,
OrderStatus = (short)OrderState.Confirmed,
PaymentStatuses = string.Empty,
StartDate = dateTime.AddYears(-5),
WebSiteID = websiteIds.FirstOrDefault()
};
var queryInfo = new QueryInfo(new AdditionalInfo(new List<string>()), orderViewFilteringInfo, new PagingInfo(pageNumber, pageSize), new OrderViewSortingInfo(SortOrder.DESC, OrderViewSortingInfo.OrderBy.OrderDate));
For new AdditionalInfo is that the same as an order’s AdditionalInfo. So that i can filter out orders with addtionalInfo?
CustomFilter = string.Empty, <-----what kind of customFilter can i use and how
Customfilter
will search in the fields defined in CustomFilterColumns
AND in AdditionalOrderInfo.
Note from previous code that you should use Replace('*', '%').Replace('?', '_')
to define correct wildcard values in Customfilter
.
CustomFilterColumns = new List(),<-----what kind of customFilter can i use and how
CustomFilterColumns
define which order fields to search in, in the previous code sample this was defined with OrderFilterColumn
For new AdditionalInfo is that the same as an order’s AdditionalInfo. So that i can filter out orders with addtionalInfo?
Should work, does it not when you try?
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.