fix(core-flows): variant pricing batch update (#7677)
* fix: variant pricing batch update * fix: batch endpoint throwing when `create` array isn't passed * fix: batch variants workflow
This commit is contained in:
@@ -26,15 +26,23 @@ export const batchProductVariantsWorkflow = createWorkflow(
|
||||
>
|
||||
>
|
||||
): WorkflowData<BatchWorkflowOutput<ProductTypes.ProductVariantDTO>> => {
|
||||
const normalizedInput = transform({ input }, (data) => {
|
||||
return {
|
||||
create: data.input.create ?? [],
|
||||
update: data.input.update ?? [],
|
||||
delete: data.input.delete ?? [],
|
||||
}
|
||||
})
|
||||
|
||||
const res = parallelize(
|
||||
createProductVariantsWorkflow.runAsStep({
|
||||
input: { product_variants: input.create ?? [] },
|
||||
input: { product_variants: normalizedInput.create },
|
||||
}),
|
||||
updateProductVariantsWorkflow.runAsStep({
|
||||
input: { product_variants: input.update ?? [] },
|
||||
input: { product_variants: normalizedInput.update },
|
||||
}),
|
||||
deleteProductVariantsWorkflow.runAsStep({
|
||||
input: { ids: input.delete ?? [] },
|
||||
input: { ids: normalizedInput.delete },
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ export const updateProductVariantsWorkflow = createWorkflow(
|
||||
}
|
||||
|
||||
if ("product_variants" in data.input) {
|
||||
return data.variantPriceSetLinks
|
||||
const priceSets = data.variantPriceSetLinks
|
||||
.map((link) => {
|
||||
if (!("product_variants" in data.input)) {
|
||||
return
|
||||
@@ -94,6 +94,8 @@ export const updateProductVariantsWorkflow = createWorkflow(
|
||||
} as PricingTypes.UpsertPriceSetDTO
|
||||
})
|
||||
.filter(Boolean)
|
||||
|
||||
return { price_sets: priceSets }
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user