Customers are reporting an empty Orders list after upgrading to v4.9. Stepping through the GetOrderQueryHandler with a debugger reveals that the query is filtering orders by StoreId and OwnerId. None of the orders created before the upgrade have an OwnerId. What's the right way to fix this?
Customer Order History Empty after 4.9 upgrade
Monday, November 25, 2024 1:25:18 PM
A little more digging reveals the following:
GetCustomerListHandler.cs
CustomerExtensions.cs
If I am reading this right, anytime customer.OwnerId is null/empty, we are setting GetOrderQuery.OwnerId to customer.Id. If it's not empty, we are setting GetOrderQuery.CustomerId to customer.Id. All of my customers have a null OwnerId, so this handler will never filter orders by CustomerId. Is this backward?
GetCustomerListHandler.cs
if (!request.Customer.IsOwner())
query.CustomerId = request.Customer.Id;
else
query.OwnerId = request.Customer.Id;
CustomerExtensions.cs
public static bool IsOwner(this Customer customer)
{
return string.IsNullOrEmpty(customer.OwnerId);
}
If I am reading this right, anytime customer.OwnerId is null/empty, we are setting GetOrderQuery.OwnerId to customer.Id. If it's not empty, we are setting GetOrderQuery.CustomerId to customer.Id. All of my customers have a null OwnerId, so this handler will never filter orders by CustomerId. Is this backward?
0
I think I understand. A null Customer.OwnerId indicates that the customer is not a subaccount (not owned by another customer). It looks like new Orders are created with an OwnerId (the CustomerId, unless the customer is a subaccount owned by another Customer). Should I just update the orders collection and copy Order.CustomerId to Order.OrderId?
0
It looks like is a problem with upgrade. We should update all orders and set OwnerId as CustomerId.
If you have access to the database you can run this script:
db.Order.updateMany(
{},
[
{"$set": {"OwnerId": "$CustomerId"}}
]
)
(before please make sure that you backup your database)
Btw, in few days we will publish fixed version.
Thanks for reporting!
If you have access to the database you can run this script:
db.Order.updateMany(
{},
[
{"$set": {"OwnerId": "$CustomerId"}}
]
)
(before please make sure that you backup your database)
Btw, in few days we will publish fixed version.
Thanks for reporting!
1