fix(core-flows): Actually emit event in update products workflow (#9682)
This commit is contained in:
@@ -81,7 +81,8 @@ function prepareUpdateProductInput({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateProductIds({
|
// This helper finds the IDs of products that have associated sales channels.
|
||||||
|
function findProductsWithSalesChannels({
|
||||||
updatedProducts,
|
updatedProducts,
|
||||||
input,
|
input,
|
||||||
}: {
|
}: {
|
||||||
@@ -252,10 +253,6 @@ export const updateProductsWorkflow = createWorkflow(
|
|||||||
|
|
||||||
const toUpdateInput = transform({ input }, prepareUpdateProductInput)
|
const toUpdateInput = transform({ input }, prepareUpdateProductInput)
|
||||||
const updatedProducts = updateProductsStep(toUpdateInput)
|
const updatedProducts = updateProductsStep(toUpdateInput)
|
||||||
const updatedProductIds = transform(
|
|
||||||
{ updatedProducts, input },
|
|
||||||
updateProductIds
|
|
||||||
)
|
|
||||||
|
|
||||||
const salesChannelLinks = transform(
|
const salesChannelLinks = transform(
|
||||||
{ input, updatedProducts },
|
{ input, updatedProducts },
|
||||||
@@ -267,10 +264,15 @@ export const updateProductsWorkflow = createWorkflow(
|
|||||||
prepareVariantPrices
|
prepareVariantPrices
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const productsWithSalesChannels = transform(
|
||||||
|
{ updatedProducts, input },
|
||||||
|
findProductsWithSalesChannels
|
||||||
|
)
|
||||||
|
|
||||||
const currentSalesChannelLinks = useRemoteQueryStep({
|
const currentSalesChannelLinks = useRemoteQueryStep({
|
||||||
entry_point: "product_sales_channel",
|
entry_point: "product_sales_channel",
|
||||||
fields: ["product_id", "sales_channel_id"],
|
fields: ["product_id", "sales_channel_id"],
|
||||||
variables: { filters: { product_id: updatedProductIds } },
|
variables: { filters: { product_id: productsWithSalesChannels } },
|
||||||
}).config({ name: "get-current-sales-channel-links-step" })
|
}).config({ name: "get-current-sales-channel-links-step" })
|
||||||
|
|
||||||
const toDeleteSalesChannelLinks = transform(
|
const toDeleteSalesChannelLinks = transform(
|
||||||
@@ -285,10 +287,10 @@ export const updateProductsWorkflow = createWorkflow(
|
|||||||
dismissRemoteLinkStep(toDeleteSalesChannelLinks)
|
dismissRemoteLinkStep(toDeleteSalesChannelLinks)
|
||||||
|
|
||||||
const productIdEvents = transform(
|
const productIdEvents = transform(
|
||||||
{ updatedProductIds },
|
{ updatedProducts },
|
||||||
({ updatedProductIds }) => {
|
({ updatedProducts }) => {
|
||||||
return updatedProductIds?.map((id) => {
|
return updatedProducts?.map((p) => {
|
||||||
return { id }
|
return { id: p.id }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user