feat(products,types,pricing): allow scoping products by collection_id + pricing by currency_code (#4965)
* chore: allow scoping products by collection_id * chore: scope money amounts by currency code + change category_ids to category_id * chore: add an extra product to test without collection --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
1 parent
b71776738c
commit
66bd9a835c
11 files changed
+438
-140
No files matched your search
@@ -72,17 +72,17 @@ export default class ProductService<TEntity extends Product = Product> {
|
||||
config: FindConfig<ProductTypes.ProductDTO> = {},
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
): Promise<TEntity[]> {
|
||||
if (filters.category_ids) {
|
||||
if (Array.isArray(filters.category_ids)) {
|
||||
if (filters.category_id) {
|
||||
if (Array.isArray(filters.category_id)) {
|
||||
filters.categories = {
|
||||
id: { $in: filters.category_ids },
|
||||
id: { $in: filters.category_id },
|
||||
}
|
||||
} else {
|
||||
filters.categories = {
|
||||
id: filters.category_ids,
|
||||
id: filters.category_id,
|
||||
}
|
||||
}
|
||||
delete filters.category_ids
|
||||
delete filters.category_id
|
||||
}
|
||||
|
||||
const queryOptions = ModulesSdkUtils.buildQuery<Product>(filters, config)
|
||||
@@ -98,17 +98,17 @@ export default class ProductService<TEntity extends Product = Product> {
|
||||
config: FindConfig<ProductTypes.ProductDTO> = {},
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
): Promise<[TEntity[], number]> {
|
||||
if (filters.category_ids) {
|
||||
if (Array.isArray(filters.category_ids)) {
|
||||
if (filters.category_id) {
|
||||
if (Array.isArray(filters.category_id)) {
|
||||
filters.categories = {
|
||||
id: { $in: filters.category_ids },
|
||||
id: { $in: filters.category_id },
|
||||
}
|
||||
} else {
|
||||
filters.categories = {
|
||||
id: filters.category_ids,
|
||||
id: filters.category_id,
|
||||
}
|
||||
}
|
||||
delete filters.category_ids
|
||||
delete filters.category_id
|
||||
}
|
||||
|
||||
const queryOptions = ModulesSdkUtils.buildQuery<Product>(filters, config)
|
||||
|
||||
Reference in new issue
Block a user