Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Count the shelves a feed actually moved

Damian Legawiec4742a84be0d9
diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.ts
index ffe3f1a761..aac027cd23 100644
--- a/packages/admin-sdk/src/admin-client.ts
+++ b/packages/admin-sdk/src/admin-client.ts
@@ -4152,8 +4152,6 @@ export class AdminClient {
this.request('POST', '/stock_levels/bulk_upsert', { ...options, body: params }),
}
- // }
-
// ============================================
// Stock Movements
// ============================================
diff --git a/spree/core/app/services/spree/stock_levels/bulk_upsert.rb b/spree/core/app/services/spree/stock_levels/bulk_upsert.rb
index 0fdd2c98f9..166aa02cd0 100644
--- a/spree/core/app/services/spree/stock_levels/bulk_upsert.rb
+++ b/spree/core/app/services/spree/stock_levels/bulk_upsert.rb
@@ -79,6 +79,7 @@ module Spree
# read and the write must be one step: computing it outside the lock
# lets two concurrent feeds both measure the same stale count and land
# the shelf on neither figure.
+ moved = false
stock_level.with_lock do
delta = delta_for(row, stock_level)
next if delta.blank? || delta.zero?
@@ -87,9 +88,9 @@ module Spree
# hand: it types the row as an adjustment and records the reason, so a
# feed's correction reads like every other change in the history.
stock_level.stock_location.adjust(stock_level.variant, delta, reason: FEED_REASON)
+ moved = true
end
-
- true
+ moved
end
def delta_for(row, stock_level)