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 c97cb78709
commit fdb68d6b95

View File

@@ -269,7 +269,14 @@ class Product extends BaseAction implements EventSubscriberInterface
$product = $event->getProduct(); $product = $event->getProduct();
// Delete all product feature relations // 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 // Delete all product attributes sale elements
ProductSaleElementsQuery::create()->filterByProduct($product)->delete($con); ProductSaleElementsQuery::create()->filterByProduct($product)->delete($con);