EntityUpdated<Order> handle event has only 1 orderitem in order

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
I have a plugin that does additional processing when an order is created. I am using the IConsumer<EntityUpdated<Order>> to handle the order event.

I need to look through the orderitems to check product categories but there seems to be a bug with the number of products when the order is first created.

Here's how I can reproduce the problem:

- I place 3 different products in the cart and go through the checkout process.
- When I click on the confirm button, the order is created and the EntityUpdated<Order> is triggered.
- Looking in the EntityUpdated.OrderItems there is only 1 order item - there should be 3!

However, if I go to the admin panel to update the order, 3 orderitems are in the order when the event is triggered.

Is this normal behaviour?
7 years ago
[email protected] wrote:
Is this normal behaviour?

It looks like it is. The PlaceOrder function in the OrderProcessingService creates the order then loops through the shopping cart items moving each one from the cart to the order. For each item it calls the OrderService.UpdateOrder function which will raise the EntityUpdated<Order> event. I'd expect you to be seeing the event raised 3 times as each item is moved to the order (first with 1 item, then 2 items, then 3 items).

Once the order is finished processing the OrderPlacedEvent is raised. It sounds like that's what you want to respond to.
7 years ago
It worked! The OrderPlacedEvent is the event I should have been using instead of EntityUpdated<Order>.

When the OrderPlacedEvent is triggered the number of products is correct and I can loop throught them.

Thanks for the help.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.