From daf451f7b85d855b42c598f2888192536eda95b1 Mon Sep 17 00:00:00 2001 From: Guillaume Barral Date: Wed, 23 Jul 2014 16:08:19 +0200 Subject: [PATCH 1/6] Use now the dispatcher to delete feature_product when we change the template of a product --- core/lib/Thelia/Action/Product.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index 2ef61a268..3bd54c22e 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -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); From cea6491d77e62b7daabbad6a895b77a9ce158aee Mon Sep 17 00:00:00 2001 From: Guillaume Barral Date: Fri, 25 Jul 2014 10:33:52 +0200 Subject: [PATCH 2/6] Respect of the good standards --- core/lib/Thelia/Action/Product.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index 3bd54c22e..9cef94218 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -269,12 +269,12 @@ class Product extends BaseAction implements EventSubscriberInterface $product = $event->getProduct(); // Delete all product feature relations - 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()); + if(null !== $featureProducts = FeatureProductQuery::create()->findByProductId($product->getId())){ + /** @var \Thelia\Model\FeatureProduct $featureProduct */ + foreach($featureProducts as $featureProduct){ + $eventDelete = new FeatureProductDeleteEvent($product->getId(), $featureProduct->getFeatureId()); - $event->getDispatcher()->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event_delete); + $event->getDispatcher()->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $eventDelete); } } From d63932fcbdd83839777c50b04a827daaa0fc3b20 Mon Sep 17 00:00:00 2001 From: Guillaume Barral Date: Fri, 25 Jul 2014 16:10:09 +0200 Subject: [PATCH 3/6] Block the smarty interpretation in the elseloop --- .../Core/Template/Smarty/Plugins/TheliaLoop.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index bf3538002..e041b1d15 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -215,12 +215,15 @@ class TheliaLoop extends AbstractSmartyPlugin */ public function theliaElseloop($params, $content, /** @noinspection PhpUnusedParameterInspection */ $template, &$repeat) { - // When encountering close tag, check if loop has results. - if ($repeat === false) { - return $this->checkEmptyLoop($params) ? $content : ''; + //Block the smarty interpretation in the elseloop + if ($content === null) { + if ( ! $this->checkEmptyLoop($params)){ + $repeat = false; + return ''; + } } - return ''; + return $content; } /** From fdb68d6b9520ad9f2c41d6cd7921d4d0dfa3a01b Mon Sep 17 00:00:00 2001 From: Guillaume Barral Date: Wed, 23 Jul 2014 16:08:19 +0200 Subject: [PATCH 4/6] Use now the dispatcher to delete feature_product when we change the template of a product --- core/lib/Thelia/Action/Product.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index 2ef61a268..3bd54c22e 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -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); From 1b2cbe6746bc35e9e8117f56c47f913b1c3bd244 Mon Sep 17 00:00:00 2001 From: Guillaume Barral Date: Fri, 25 Jul 2014 10:33:52 +0200 Subject: [PATCH 5/6] Respect of the good standards --- core/lib/Thelia/Action/Product.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index 3bd54c22e..9cef94218 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -269,12 +269,12 @@ class Product extends BaseAction implements EventSubscriberInterface $product = $event->getProduct(); // Delete all product feature relations - 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()); + if(null !== $featureProducts = FeatureProductQuery::create()->findByProductId($product->getId())){ + /** @var \Thelia\Model\FeatureProduct $featureProduct */ + foreach($featureProducts as $featureProduct){ + $eventDelete = new FeatureProductDeleteEvent($product->getId(), $featureProduct->getFeatureId()); - $event->getDispatcher()->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event_delete); + $event->getDispatcher()->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $eventDelete); } } From a0b78502d601c0f9bc9969c55a38e2f1df63fedc Mon Sep 17 00:00:00 2001 From: Guillaume Barral Date: Fri, 25 Jul 2014 16:10:09 +0200 Subject: [PATCH 6/6] Block the smarty interpretation in the elseloop --- .../Core/Template/Smarty/Plugins/TheliaLoop.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index bf3538002..e041b1d15 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -215,12 +215,15 @@ class TheliaLoop extends AbstractSmartyPlugin */ public function theliaElseloop($params, $content, /** @noinspection PhpUnusedParameterInspection */ $template, &$repeat) { - // When encountering close tag, check if loop has results. - if ($repeat === false) { - return $this->checkEmptyLoop($params) ? $content : ''; + //Block the smarty interpretation in the elseloop + if ($content === null) { + if ( ! $this->checkEmptyLoop($params)){ + $repeat = false; + return ''; + } } - return ''; + return $content; } /**