Skip to content

Commit

Permalink
fix the problem and generate listfilter from factory pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
bahram1249 committed Jul 29, 2024
1 parent 5168fc8 commit a467d17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/e-commerce/src/product/product.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ApplyInventoryStatus } from './service/apply-inventory-status.service';
import { ECInventoryStatus } from '@rahino/database/models/ecommerce-eav/ec-inventory-status.entity';
import { EAVEntityType } from '@rahino/database/models/eav/eav-entity-type.entity';
import { ECSlugVersion } from '@rahino/database/models/ecommerce-eav/ec-slug-version.entity';
import { QueryFilterModule } from '@rahino/query-filter';

@Module({
imports: [
Expand Down Expand Up @@ -47,6 +48,7 @@ import { ECSlugVersion } from '@rahino/database/models/ecommerce-eav/ec-slug-ver
ECSlugVersion,
]),
SequelizeModule,
QueryFilterModule,
],
controllers: [ProductController],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ECSlugVersion } from '@rahino/database/models/ecommerce-eav/ec-slug-ver
import { QueryOptionsBuilder } from '@rahino/query-filter/sequelize-query-builder';
import { RedirectException } from '@rahino/ecommerce/util/exception';
import { SlugVersionTypeEnum } from '@rahino/ecommerce/util/enum';
import { ListFilterV2Factory } from '@rahino/query-filter/provider/list-filter-v2.factory';

@Injectable()
export class ProductRepositoryService {
Expand All @@ -25,6 +26,7 @@ export class ProductRepositoryService {
private readonly applyDiscountService: ApplyDiscountService,
private readonly applyInventoryStatus: ApplyInventoryStatus,
private readonly removeEmptyPriceService: RemoveEmptyPriceService,
private listFilterFactory: ListFilterV2Factory,

private readonly config: ConfigService,
) {}
Expand All @@ -47,7 +49,10 @@ export class ProductRepositoryService {
.build(),
);
if (isExistsBefore) {
const oldItem = await this.findById({}, isExistsBefore.entityId);
const oldItem = await this.findById(
await this.listFilterFactory.create(),
isExistsBefore.entityId,
);
if (oldItem) {
throw new RedirectException(
`/product/${oldItem.result.sku}/${oldItem.result.slug}`,
Expand Down

0 comments on commit a467d17

Please sign in to comment.