commercetools / commercetools/nodejs

Expose Price sync actions in syncActions

Open
#1,432 1 comment 0 reactions 1 assignee Claimed by @danrleyt View on GitHub
Type: New Feature Type: Onboarding Task
Dominant language
JavaScript
Stars
77
Forks
70
PR merge metrics
No merged PRs in 30d

Description

### Description

In our project we need to calculate update actions for 2 price drafts. We don't have a full product representation for the old price. It'd be very useful to have a `createSyncPrices` API which would return update actions for 2 price drafts.

Something like this

```js
import { createSyncPrices } from '@commercetools/sync-actions'
import { createClient } from '@commercetools/sdk-client'

const syncPrices = createSyncPrices()
const client = createClient({
middlewares: [...],
})
const before = {
// ...
}
const now = {
// ...
}
const actions = syncPrices.buildActions(now, before)
const productsRequest = {
url: `/products/${before.id}`,
method: 'POST',
body: JSON.stringify({ version: before.version, actions }),
}

client.execute(productsRequest)
.then(result => ...)
.catch(error => ...)
```

### Current Behavior

Currently the only way to achieve the goal is to provide 2 empty products with prices for which we want to get update actions.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.