Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core-flows): set SalesChannels on Product update #7272

Merged
merged 13 commits into from
May 21, 2024

Conversation

fPolic
Copy link
Contributor

@fPolic fPolic commented May 8, 2024

WHAT

  • set sales channels when updating products

Copy link

vercel bot commented May 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2024 2:40pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) May 21, 2024 2:40pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 2:40pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 2:40pm

Copy link

changeset-bot bot commented May 8, 2024

🦋 Changeset detected

Latest commit: 5b19b01

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@medusajs/core-flows Patch
@medusajs/medusa Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@fPolic fPolic changed the title fix(product): associate SCs on Product update fix(core-flows): set SalesChannels on Product update May 8, 2024
@fPolic fPolic requested review from sradevski and removed request for kasperkristensen May 8, 2024 10:42
@fPolic fPolic marked this pull request as draft May 8, 2024 13:12
products: ProductTypes.UpsertProductDTO[]
}
| UpdateProductsStepInputSelector
| UpdateProductsStepInputProducts

type WorkflowInput = UpdateProductsStepInput
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: We have a mix of workflow types in the types package and in the core-flows package, it will require a cleanup at some point, not now but just raising it. we also have different places in the types package where the workflow types are define, workflows, workflow, and in some dir. maybe we can create a ticket

Copy link
Contributor

@olivermrbl olivermrbl May 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prepareUpdateProductInput, updateProductIds, and prepareToDeleteLinks are all named as if they were generic transformers for updating products, but they are coupled with sales channel management as far as I can tell. So what I mean is, if we add another link to product, we will need to refactor these to account for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry maybe i ve named them wrongly, but we can rework that, i just based the name on the workflow step they were used for. I didnt have a better idea at the moment but the main thing was to extract them (not necessarily generic) to have a better readability of the workflow and transformers themselves

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, those transformers are not exported they are only local so very specific here, i am fine with finding another name or rework the implementation a bit

@adrien2p
Copy link
Member

@fPolic I have done a commit proposal, can I get you to look at it and let me know what you think

)

const currentLinks = useRemoteQueryStep({
entry_point: "product_sales_channel",
Copy link
Member

@adrien2p adrien2p May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: service: Links.productSalesChannel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just saw that it requires a little adaptation of that step but it should be good to have so that we don't rely on the string for the link themselves wdyt?

@fPolic
Copy link
Contributor Author

fPolic commented May 17, 2024

@fPolic I have done a commit proposal, can I get you to look at it and let me know what you think

Looks good @adrien2p, I've added generic link steps as you suggested

// TODO Update sales channel links
return updateProductsStep(input)

const toUpdateInput = transform({ input }, prepareUpdateProductInput)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I don't know if I like, that the steps that were added here are so specific to sales channel management. E.g. as soon as we add another link to products, we will need to revisit all of these. Or create separate steps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to relook into it but your comment is on the transformer, are you referring to the transformer of the next step or the step itself just to be sure

@olivermrbl
Copy link
Contributor

Should we merge this and revisit later?

@adrien2p
Copy link
Member

It is fine to me, @fPolic wdyt?

@fPolic
Copy link
Contributor Author

fPolic commented May 21, 2024

Sounds good!

@olivermrbl olivermrbl merged commit b7df447 into develop May 21, 2024
16 of 17 checks passed
@olivermrbl olivermrbl deleted the feat/product-sales-channel-update-link branch May 21, 2024 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants