fix(medusa): Free text search for PriceList Products (#1843)
**What** Fixes #1831 and #1336
This commit is contained in:
1 parent
cbdc5b7774
commit
7162972318
4 files changed
+41
-14
No files matched your search
@@ -8,7 +8,6 @@ import {
|
||||
} from "typeorm"
|
||||
import { PriceList } from "../models/price-list"
|
||||
import { CustomFindOptions, ExtendedFindConfig } from "../types/common"
|
||||
import { CustomerGroup } from "../models"
|
||||
import { FilterablePriceListProps } from "../types/price-list"
|
||||
|
||||
export type PriceListFindOptions = CustomFindOptions<
|
||||
@@ -111,10 +110,10 @@ export class PriceListRepository extends Repository<PriceList> {
|
||||
.take(query.take)
|
||||
|
||||
if (groups) {
|
||||
qb.leftJoinAndSelect(
|
||||
"price_list.customer_groups",
|
||||
"group"
|
||||
).andWhere("group.id IN (:...ids)", { ids: groups.value })
|
||||
qb.leftJoinAndSelect("price_list.customer_groups", "group").andWhere(
|
||||
"group.id IN (:...ids)",
|
||||
{ ids: groups.value }
|
||||
)
|
||||
}
|
||||
|
||||
if (query.relations?.length) {
|
||||
|
||||
@@ -105,9 +105,7 @@ export class ProductRepository extends Repository<Product> {
|
||||
return [entities, count]
|
||||
}
|
||||
|
||||
private getGroupedRelations(
|
||||
relations: string[]
|
||||
): {
|
||||
private getGroupedRelations(relations: string[]): {
|
||||
[toplevel: string]: string[]
|
||||
} {
|
||||
const groupedRelations: { [toplevel: string]: string[] } = {}
|
||||
@@ -231,9 +229,8 @@ export class ProductRepository extends Repository<Product> {
|
||||
)
|
||||
|
||||
const entitiesAndRelations = entitiesIdsWithRelations.concat(entities)
|
||||
const entitiesToReturn = this.mergeEntitiesWithRelations(
|
||||
entitiesAndRelations
|
||||
)
|
||||
const entitiesToReturn =
|
||||
this.mergeEntitiesWithRelations(entitiesAndRelations)
|
||||
|
||||
return [entitiesToReturn, count]
|
||||
}
|
||||
@@ -279,9 +276,8 @@ export class ProductRepository extends Repository<Product> {
|
||||
)
|
||||
|
||||
const entitiesAndRelations = entitiesIdsWithRelations.concat(entities)
|
||||
const entitiesToReturn = this.mergeEntitiesWithRelations(
|
||||
entitiesAndRelations
|
||||
)
|
||||
const entitiesToReturn =
|
||||
this.mergeEntitiesWithRelations(entitiesAndRelations)
|
||||
|
||||
return entitiesToReturn
|
||||
}
|
||||
@@ -376,6 +372,10 @@ export class ProductRepository extends Repository<Product> {
|
||||
delete where.title
|
||||
}
|
||||
|
||||
if ("price_list_id" in where) {
|
||||
delete where?.price_list_id
|
||||
}
|
||||
|
||||
return {
|
||||
...options,
|
||||
where,
|
||||
|
||||
Reference in new issue
Block a user