diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index 067c54fc1..8b8b53e4f 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -115,6 +115,8 @@ class Category extends BaseCategory */ public function postDelete(ConnectionInterface $con = null) { + $this->markRewritenUrlObsolete(); + $this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY, new CategoryEvent($this)); } } \ No newline at end of file diff --git a/core/lib/Thelia/Model/Content.php b/core/lib/Thelia/Model/Content.php index 6417c8b56..3a002e6d1 100755 --- a/core/lib/Thelia/Model/Content.php +++ b/core/lib/Thelia/Model/Content.php @@ -148,6 +148,8 @@ class Content extends BaseContent public function postDelete(ConnectionInterface $con = null) { + $this->markRewritenUrlObsolete(); + $this->dispatchEvent(TheliaEvents::AFTER_DELETECONTENT, new ContentEvent($this)); } } diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index 4b32e7591..9249c94e2 100755 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -100,6 +100,8 @@ class Folder extends BaseFolder public function postDelete(ConnectionInterface $con = null) { + $this->markRewritenUrlObsolete(); + $this->dispatchEvent(TheliaEvents::AFTER_DELETEFOLDER, new FolderEvent($this)); } } diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index 3855c46c1..12b98c890 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -263,12 +263,8 @@ class Product extends BaseProduct */ public function postDelete(ConnectionInterface $con = null) { - RewritingUrlQuery::create() - ->filterByView($this->getRewrittenUrlViewName()) - ->filterByViewId($this->getId()) - ->update(array( - "View" => ConfigQuery::getObsoleteRewrittenUrlView() - )); + $this->markRewritenUrlObsolete(); + $this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this)); } } diff --git a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php index d16ceaf5f..bcbbb9afd 100644 --- a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php +++ b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php @@ -29,6 +29,7 @@ use Thelia\Exception\UrlRewritingException; use Thelia\Model\RewritingUrlQuery; use Thelia\Model\RewritingUrl; use Thelia\Tools\URL; +use Thelia\Model\ConfigQuery; /** * A trait for managing Rewritten URLs from model classes */ @@ -136,6 +137,18 @@ trait UrlRewritingTrait { return $url; } + /** + * Mark the current URL as obseolete + */ + public function markRewritenUrlObsolete() { + RewritingUrlQuery::create() + ->filterByView($this->getRewrittenUrlViewName()) + ->filterByViewId($this->getId()) + ->update(array( + "View" => ConfigQuery::getObsoleteRewrittenUrlView() + )); + } + /** * Set the rewritten URL for the given locale *