Skip to content

Commit

Permalink
Merged PR 48309: Specify table in order status query
Browse files Browse the repository at this point in the history
## What's being changed

A query in SalesDataManager.

## Why it's being changed

We had a `WHERE` clause in our query that filtered orders for certain statuses. We didn't specify the table before because natively, Magento's `sales_order_item` table has no `status` column. However it must be the case that some merchants do have such a column added, and in this case we get an exception thrown:
```
Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous
```

## How to review / test this change

- Place an order as a customer
- In Dotdigital > Configuration > Data Fields observe the statuses selected for "Data fields calculation with status"
- Run customer sync
- Ensure that first and last order ids are retrieved as expected according to the statuses selected (you can put breakpoints at lines 117 and 124 of SalesDataManager to observe this)

Related work items: #227644
  • Loading branch information
sta1r committed Oct 3, 2023
1 parent 72f7ec7 commit da67324
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Model/Sync/Export/SalesDataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private function getOrderIds(array $emails, array $storeIds, array $statuses, st
->where('sales_order_item.product_type = ?', 'simple');

if (!empty($statuses)) {
$select->where('status in (?)', $statuses);
$select->where('sales_order.status in (?)', $statuses);
}
$select->group('customer_email');

Expand Down

0 comments on commit da67324

Please sign in to comment.