Browse Source

chore(core): Remove unused product variant subscriber

Michael Bromley 6 years ago
parent
commit
b444a5a41f

+ 0 - 44
packages/core/src/entity/product-variant/product-variant.subscriber.ts

@@ -1,44 +0,0 @@
-import { EntitySubscriberInterface, EventSubscriber, InsertEvent } from 'typeorm';
-
-import { InternalServerError } from '../../common/error/errors';
-
-import { ProductVariantPrice } from './product-variant-price.entity';
-import { ProductVariant } from './product-variant.entity';
-
-/**
- * This subscriber listens for CRUD events on ProductVariants and transparently handles
- */
-@EventSubscriber()
-export class ProductVariantSubscriber implements EntitySubscriberInterface<ProductVariant> {
-    listenTo() {
-        return ProductVariant;
-    }
-
-    /*async afterInsert(event: InsertEvent<ProductVariant>) {
-        const { channelId, taxCategoryId } = event.queryRunner.data;
-        const price = event.entity.price || 0;
-        if (channelId === undefined) {
-            throw new InternalServerError(`error.channel-id-not-set`);
-        }
-        const variantPrice = new ProductVariantPrice({ price, channelId });
-        variantPrice.variant = event.entity;
-        await event.manager.save(variantPrice);
-    }
-
-    async afterUpdate(event: InsertEvent<ProductVariant>) {
-        if (event.entity.price !== undefined && event.queryRunner.data && event.queryRunner.data.channelId) {
-            const variantPrice = await event.connection.getRepository(ProductVariantPrice).findOne({
-                where: {
-                    variant: event.entity.id,
-                    channelId: event.queryRunner.data.channelId,
-                },
-            });
-            if (!variantPrice) {
-                throw new InternalServerError(`error.could-not-find-product-variant-price`);
-            }
-
-            variantPrice.price = event.entity.price || 0;
-            await event.manager.save(variantPrice);
-        }
-    }*/
-}

+ 0 - 3
packages/core/src/entity/subscribers.ts

@@ -2,8 +2,6 @@ import { EntitySubscriberInterface, EventSubscriber, InsertEvent } from 'typeorm
 
 import { CALCULATED_PROPERTIES } from '../common/calculated-decorator';
 
-import { ProductVariantSubscriber } from './product-variant/product-variant.subscriber';
-
 @EventSubscriber()
 export class CalculatedPropertySubscriber implements EntitySubscriberInterface {
     afterLoad(event: any) {
@@ -45,6 +43,5 @@ export class CalculatedPropertySubscriber implements EntitySubscriberInterface {
  * A map of the core TypeORM Subscribers.
  */
 export const coreSubscribersMap = {
-    ProductVariantSubscriber,
     CalculatedPropertySubscriber,
 };