|
|
@@ -14,7 +14,7 @@ import { Translated } from '../../common/types/locale-types';
|
|
|
import { assertFound } from '../../common/utils';
|
|
|
import { ConfigService } from '../../config/config.service';
|
|
|
import { TransactionalConnection } from '../../connection/transactional-connection';
|
|
|
-import { Product, ProductVariant } from '../../entity';
|
|
|
+import { Asset, Product, ProductVariant } from '../../entity';
|
|
|
import { FacetValueTranslation } from '../../entity/facet-value/facet-value-translation.entity';
|
|
|
import { FacetValue } from '../../entity/facet-value/facet-value.entity';
|
|
|
import { Facet } from '../../entity/facet/facet.entity';
|
|
|
@@ -148,15 +148,18 @@ export class FacetValueService {
|
|
|
let message = '';
|
|
|
let result: DeletionResult;
|
|
|
|
|
|
+ const facetValue = await this.connection.getEntityOrThrow(ctx, FacetValue, id);
|
|
|
+ // Create a new facetValue so that the id is still available
|
|
|
+ // after deletion (the .remove() method sets it to undefined)
|
|
|
+ const deletedFacetValue = new FacetValue(facetValue);
|
|
|
+
|
|
|
if (!isInUse) {
|
|
|
- const facetValue = await this.connection.getEntityOrThrow(ctx, FacetValue, id);
|
|
|
await this.connection.getRepository(ctx, FacetValue).remove(facetValue);
|
|
|
- this.eventBus.publish(new FacetValueEvent(ctx, facetValue, 'deleted', id));
|
|
|
+ this.eventBus.publish(new FacetValueEvent(ctx, deletedFacetValue, 'deleted', id));
|
|
|
result = DeletionResult.DELETED;
|
|
|
} else if (force) {
|
|
|
- const facetValue = await this.connection.getEntityOrThrow(ctx, FacetValue, id);
|
|
|
await this.connection.getRepository(ctx, FacetValue).remove(facetValue);
|
|
|
- this.eventBus.publish(new FacetValueEvent(ctx, facetValue, 'deleted', id));
|
|
|
+ this.eventBus.publish(new FacetValueEvent(ctx, deletedFacetValue, 'deleted', id));
|
|
|
message = ctx.translate('message.facet-value-force-deleted', i18nVars);
|
|
|
result = DeletionResult.DELETED;
|
|
|
} else {
|