fix(order): Prevent fetching all db adjustments when no items are pre… (#14351)
* fix(order): Prevent fetching all db adjustments when no items are present * Create funny-suns-think.md
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/order": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(order): Prevent fetching all db adjustments when no items are pre…
|
||||||
@@ -225,6 +225,10 @@ async function loadItemAdjustments(manager, orders) {
|
|||||||
const items = orders.flatMap((r) => [...(r.items ?? [])])
|
const items = orders.flatMap((r) => [...(r.items ?? [])])
|
||||||
const itemsIdMap = new Map<string, any>(items.map((i) => [i.item.id, i.item]))
|
const itemsIdMap = new Map<string, any>(items.map((i) => [i.item.id, i.item]))
|
||||||
|
|
||||||
|
if (!items.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const params = items.map((i) => {
|
const params = items.map((i) => {
|
||||||
// preinitialise all items so an empty array is returned for ones without adjustments
|
// preinitialise all items so an empty array is returned for ones without adjustments
|
||||||
if (!i.item.adjustments.isInitialized()) {
|
if (!i.item.adjustments.isInitialized()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user