-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[Bug]: Order Workflow Doesn't Support Creating Multiple Orders #10054
Comments
Also, for importing orders, would it be possible to have an |
@AlexAntonides Can you please share some code or a repo that we can use to reproduce the issue? Feel free to reply here with reproduction and we will re-open the issue and provide the needed help 🙂 |
@AlexAntonides man? |
@thetutlage, thank you for responding. I wasn't entirely sure whether to include a code snippet, considering the workflow in itself only supports a single entity ( However, if you create a route which tries to create multiple orders,
you'll receive a typescript error that |
Hello @AlexAntonides 👋 Okay, so we discussed this internally and decided that |
Fixed the naming issue in this PR https://github.com/medusajs/medusa/pull/10134/files. The plural name is deprecated |
Hi @thetutlage, thank you for addressing this. |
Have you tried running the order create steps in parallel? I have no idea if this would actually work or if there are limitations to them, but this is what I would try next https://docs.medusajs.com/learn/advanced-development/workflows/parallel-steps#main |
@ghardin1314 thanks for your help. I've tried this before, const orders: CreateOrderDTO[] / = ** workflow input **/
const requests = transform(
{ orders },
(data) => data.orders.map((order) => createOrderWorkflow.runAsStep({ input: order })),
)
const result = parallelize(
...requests
) and it doesn't seem to work, because the internal representation assumes I'm merging one action here. error: Error in loading config: Cannot merge less than two actions
error: Error: Cannot merge less than two actions
at OrchestratorBuilder.mergeActions (/node_modules/@medusajs/orchestration/dist/transaction/orchestrator-builder.js:172:19)
at Object.<anonymous> (/node_modules/@medusajs/workflows-sdk/dist/utils/composer/parallelize.js:52:19)
at parallelizeBinder (/node_modules/@medusajs/workflows-sdk/dist/utils/composer/create-workflow.js:107:36)
at parallelize (/node_modules/@medusajs/workflows-sdk/dist/utils/composer/parallelize.js:50:12) |
@AlexAntonides you can always add a custom endpoint that takes a list of orders, and then you can do something like this:
Or, to not overload the server, you can create batches of 5 and run those in parallel. Closing the ticket as batch creation is not something we'll be adding anytime soon, and there is a simple implementation to support it for those who need it. |
Is that feature implemented in other medusa alternatives? |
@SalahAdDin, I'm not entirely sure what you mean, but I'm trying to create a module that allows us to migrate the products/orders of another e-commerce platform into MedusaJS, because we don't want to lose our data. |
Package.json file
Node.js version
v20.17.0
Database and its version
PostgreSQL v10.4
Operating system name and version
macOS Sequoia 15.1
Browser name
No response
What happended?
I'm creating a system that is capable of bulk importing data from another datasource into my MedusaJS app. I'm currently busy with importing orders, and I have noticed that the
createOrdersWorkflow
only supports creating a single order rather than multiple orders, similarly to other workflows.Expected behavior
Similarly to other workflows, I expect the order workflow to be able to create multiple orders, especially since the workflow is plural (createOrder-s-workflow).
Actual behavior
Only accepts a single order.
Link to reproduction repo
The text was updated successfully, but these errors were encountered: