Skip to content

Commit fb6a6b5

Browse files
authored
fix(order): Prevent fetching all db adjustments when no items are pre… (medusajs#14351)
* fix(order): Prevent fetching all db adjustments when no items are present * Create funny-suns-think.md
1 parent 7172995 commit fb6a6b5

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.changeset/funny-suns-think.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/order": patch
3+
---
4+
5+
fix(order): Prevent fetching all db adjustments when no items are pre…

packages/modules/order/src/utils/base-repository-find.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ async function loadItemAdjustments(manager, orders) {
225225
const items = orders.flatMap((r) => [...(r.items ?? [])])
226226
const itemsIdMap = new Map<string, any>(items.map((i) => [i.item.id, i.item]))
227227

228+
if (!items.length) {
229+
return
230+
}
231+
228232
const params = items.map((i) => {
229233
// preinitialise all items so an empty array is returned for ones without adjustments
230234
if (!i.item.adjustments.isInitialized()) {

0 commit comments

Comments
 (0)