Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Ensure latest version is fetched before updating product prices
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenko committed Oct 6, 2014
1 parent a736388 commit 1281ff0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/coffee/pricesync.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class PriceSync
v.sku is masterSku
if match?
data =
productVersion: product.version
productId: product.id
isPublished: product.published is true
variant: match
Expand All @@ -136,12 +135,14 @@ class PriceSync
@logger?.debug prices, "No available update actions for prices in product #{variantDataInMaster.productId}"
Promise.resolve()
else
data =
version: variantDataInMaster.productVersion
variantId: variantDataInMaster.productId
actions: actions
@logger?.debug data, "About to update product #{variantDataInMaster.productId} in master"
@masterClient.products.byId(variantDataInMaster.productId).update(data)
@masterClient.productProjections.staged(true).byId(variantDataInMaster.productId).fetch()
.then (result) =>
data =
version: result.body.version
variantId: variantDataInMaster.productId
actions: actions
@logger?.debug data, "About to update product #{variantDataInMaster.productId} in master"
@masterClient.products.byId(variantDataInMaster.productId).update(data)
.then =>
@summary.synced++
Promise.resolve()
Expand Down

0 comments on commit 1281ff0

Please sign in to comment.