Skip to content

Commit

Permalink
fix(core-flows): Actually emit event in update products workflow (#9682)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl authored Oct 21, 2024
1 parent b485582 commit 604c182
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/core/core-flows/src/product/workflows/update-products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ function prepareUpdateProductInput({
}
}

function updateProductIds({
// This helper finds the IDs of products that have associated sales channels.
function findProductsWithSalesChannels({
updatedProducts,
input,
}: {
Expand Down Expand Up @@ -252,10 +253,6 @@ export const updateProductsWorkflow = createWorkflow(

const toUpdateInput = transform({ input }, prepareUpdateProductInput)
const updatedProducts = updateProductsStep(toUpdateInput)
const updatedProductIds = transform(
{ updatedProducts, input },
updateProductIds
)

const salesChannelLinks = transform(
{ input, updatedProducts },
Expand All @@ -267,10 +264,15 @@ export const updateProductsWorkflow = createWorkflow(
prepareVariantPrices
)

const productsWithSalesChannels = transform(
{ updatedProducts, input },
findProductsWithSalesChannels
)

const currentSalesChannelLinks = useRemoteQueryStep({
entry_point: "product_sales_channel",
fields: ["product_id", "sales_channel_id"],
variables: { filters: { product_id: updatedProductIds } },
variables: { filters: { product_id: productsWithSalesChannels } },
}).config({ name: "get-current-sales-channel-links-step" })

const toDeleteSalesChannelLinks = transform(
Expand All @@ -285,10 +287,10 @@ export const updateProductsWorkflow = createWorkflow(
dismissRemoteLinkStep(toDeleteSalesChannelLinks)

const productIdEvents = transform(
{ updatedProductIds },
({ updatedProductIds }) => {
return updatedProductIds?.map((id) => {
return { id }
{ updatedProducts },
({ updatedProducts }) => {
return updatedProducts?.map((p) => {
return { id: p.id }
})
}
)
Expand Down

0 comments on commit 604c182

Please sign in to comment.