public function deleteTemplateAttribute(TemplateDeleteAttributeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        // Detete the removed attribute in all products which are using this template
        $pseToDelete = ProductSaleElementsQuery::create()
            ->useProductQuery()
                ->filterByTemplateId($event->getTemplate()->getId())
            ->endUse()
            ->useAttributeCombinationQuery()
                ->filterByAttributeId($event->getAttributeId())
            ->endUse()
            ->select([ ProductSaleElementsTableMap::COL_ID ])
            ->find();
    
        $currencyId = CurrencyModel::getDefaultCurrency()->getId();
        
        foreach ($pseToDelete->getData() as $pseId) {
            $dispatcher->dispatch(
                TheliaEvents::PRODUCT_DELETE_PRODUCT_SALE_ELEMENT,
                new ProductSaleElementDeleteEvent(
                    $pseId,
                    $currencyId
                )
            );
        }
    }
public function deleteTemplateAttribute(TemplateDeleteAttributeEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        // Detete the removed attribute in all products which are using this template
        $pseToDelete = ProductSaleElementsQuery::create()
            ->useProductQuery()
                ->filterByTemplateId($event->getTemplate()->getId())
            ->endUse()
            ->useAttributeCombinationQuery()
                ->filterByAttributeId($event->getAttributeId())
            ->endUse()
            ->select([ ProductSaleElementsTableMap::COL_ID ])
            ->find();
    
        $currencyId = CurrencyModel::getDefaultCurrency()->getId();
        
        foreach ($pseToDelete->getData() as $pseId) {
            $dispatcher->dispatch(
                TheliaEvents::PRODUCT_DELETE_PRODUCT_SALE_ELEMENT,
                new ProductSaleElementDeleteEvent(
                    $pseId,
                    $currencyId
                )
            );
        }
    }
public function deleteTemplateAttribute ( TemplateDeleteAttributeEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { // Detete the removed attribute in all products which are using this template $ pseToDelete = ProductSaleElementsQuery :: create ( ) -> useProductQuery ( ) -> filterByTemplateId ( $ event -> getTemplate ( ) -> getId ( ) ) -> endUse ( ) -> useAttributeCombinationQuery ( ) -> filterByAttributeId ( $ event -> getAttributeId ( ) ) -> endUse ( ) -> select ( [ ProductSaleElementsTableMap :: COL_ID ] ) -> find ( ) ; $ currencyId = CurrencyModel :: getDefaultCurrency ( ) -> getId ( ) ; foreach ( $ pseToDelete -> getData ( ) as $ pseId ) { $ dispatcher -> dispatch ( TheliaEvents :: PRODUCT_DELETE_PRODUCT_SALE_ELEMENT , new ProductSaleElementDeleteEvent ( $ pseId , $ currencyId ) ) ; } }
When an attribute is removed from a template, the conbinations and PSE of products which are using this template
should be updated.

@param TemplateDeleteAttributeEvent $event
@param string $eventName
@param EventDispatcherInterface $dispatcher
When an attribute is removed from a template the conbinations and PSE of products which are using this template should be updated .