Use now the dispatcher to delete feature_product when we change the template of a product

This commit is contained in:
Guillaume Barral
2014-07-23 16:08:19 +02:00
parent 2c6b36f7c7
commit daf451f7b8

View File

@@ -269,7 +269,14 @@ class Product extends BaseAction implements EventSubscriberInterface
$product = $event->getProduct();
// Delete all product feature relations
FeatureProductQuery::create()->filterByProduct($product)->delete($con);
if(null != $feature_products = FeatureProductQuery::create()->findByProductId($product->getId())){
/** @var \Thelia\Model\FeatureProduct $feature_product */
foreach($feature_products as $feature_product){
$event_delete = new FeatureProductDeleteEvent($product->getId(), $feature_product->getFeatureId());
$event->getDispatcher()->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event_delete);
}
}
// Delete all product attributes sale elements
ProductSaleElementsQuery::create()->filterByProduct($product)->delete($con);