-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat: add and remove products to/from collection in bulk endpoints #1032
Conversation
…eProducts on collections that uses these bulk operations
packages/medusa/src/api/routes/admin/collections/update-products.ts
Outdated
Show resolved
Hide resolved
packages/medusa/src/api/routes/admin/collections/update-products.ts
Outdated
Show resolved
Hide resolved
packages/medusa/src/api/routes/admin/collections/update-products.ts
Outdated
Show resolved
Hide resolved
packages/medusa/src/api/routes/admin/collections/update-products.ts
Outdated
Show resolved
Hide resolved
): Promise<Product[]> { | ||
await this.createQueryBuilder() | ||
.update(Product) | ||
.set({ collection_id: undefined }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be more correct to do collection_id: null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TS will complain that collection_id can only be off type string or undefined. Alternativly I could change .update(Product)
to .update("product")
to avoid using the TS type and thereby avoid the warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh makes sense - I think we then have to make sure that the type of collection_id
becomes string | null
.
Generally, if we have @Column({ nullable: true })
in a model we need to allow null
as a type on that column; we haven't done this previously as we weren't using TS so completely fine to add that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor fixes
packages/medusa/src/api/routes/admin/collections/add-products.ts
Outdated
Show resolved
Hide resolved
…edusajs#1032) * adds bulk add/remove products to/from collection. Adds endpoint updateProducts on collections that uses these bulk operations * fix integration tests and test description * undo change to swap * made requested changes * added removeProducts endpoint * made requested changes * fix: set collection_id null * updated collection_id to type string | undefined
…1032) * adds bulk add/remove products to/from collection. Adds endpoint updateProducts on collections that uses these bulk operations * fix integration tests and test description * undo change to swap * made requested changes * added removeProducts endpoint * made requested changes * fix: set collection_id null * updated collection_id to type string | undefined
…edusajs#1032) * adds bulk add/remove products to/from collection. Adds endpoint updateProducts on collections that uses these bulk operations * fix integration tests and test description * undo change to swap * made requested changes * added removeProducts endpoint * made requested changes * fix: set collection_id null * updated collection_id to type string | undefined
…edusajs#1032) * adds bulk add/remove products to/from collection. Adds endpoint updateProducts on collections that uses these bulk operations * fix integration tests and test description * undo change to swap * made requested changes * added removeProducts endpoint * made requested changes * fix: set collection_id null * updated collection_id to type string | undefined
What
POST admin/collections/<id>/products/batch
, that allows users to add products associated with the given Product Collection in bulk.DELETE admin/collections/<id>/products/batch
, that allows users to remove products associated with the given Product Collection in bulk.Why
How
addProducts
andremoveProducts
methods in the ProductCollectionService.Testing