From 16add4a13de99ff0076b56b52c72739ac4a0c158 Mon Sep 17 00:00:00 2001 From: Pieter Doms Date: Wed, 3 Apr 2024 20:56:20 +0200 Subject: [PATCH] fix(core): Fix deleted product option groups can't be deleted again (#2706) --- .../src/service/services/product.service.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/core/src/service/services/product.service.ts b/packages/core/src/service/services/product.service.ts index 4772d87fcd..adc5d4f922 100644 --- a/packages/core/src/service/services/product.service.ts +++ b/packages/core/src/service/services/product.service.ts @@ -289,14 +289,16 @@ export class ProductService { return variantResult; } for (const optionGroup of product.optionGroups) { - const groupResult = await this.productOptionGroupService.deleteGroupAndOptionsFromProduct( - ctx, - optionGroup.id, - productId, - ); - if (groupResult.result === DeletionResult.NOT_DELETED) { - await this.connection.rollBackTransaction(ctx); - return groupResult; + if (!optionGroup.deletedAt) { + const groupResult = await this.productOptionGroupService.deleteGroupAndOptionsFromProduct( + ctx, + optionGroup.id, + productId, + ); + if (groupResult.result === DeletionResult.NOT_DELETED) { + await this.connection.rollBackTransaction(ctx); + return groupResult; + } } } return {