Customer Order History Empty after 4.9 upgrade

Wednesday, July 28, 2021 12:48:41 PM
  • Posted: Wednesday, July 14, 2021 4:43 PM
  • 32
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?

0
  • Posted: Wednesday, July 14, 2021 5:06 PM
  • 32
A little more digging reveals the following:

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
  • Posted: Wednesday, July 14, 2021 5:50 PM
  • Team
  • 97
Hi,

OwnerId is used when you have subaccounts.
What was your previous version?

Regards
Krzysztof
0
  • Posted: Wednesday, July 14, 2021 5:52 PM
  • 32
Previous version was 4.5.
0
  • Posted: Wednesday, July 14, 2021 6:00 PM
  • 32
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
  • Posted: Wednesday, July 14, 2021 6:32 PM
  • Team
  • 97
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!

1
  • Posted: Wednesday, July 14, 2021 6:34 PM
  • 32
Perfect! Thanks again for the help, Krzysztof!
0
back to top
Filters