diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index ea522b1cc..067c54fc1 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -106,7 +106,7 @@ class Category extends BaseCategory public function preDelete(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::BEFORE_DELETECATEGORY, new CategoryEvent($this)); - + $this->reorderBeforeDelete(); return true; } diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index d143f8a8f..4b32e7591 100755 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -94,7 +94,7 @@ class Folder extends BaseFolder public function preDelete(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFOLDER, new FolderEvent($this)); - + $this->reorderBeforeDelete(); return true; } diff --git a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php index 642d07402..d299fd3fc 100644 --- a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php +++ b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php @@ -198,4 +198,11 @@ trait PositionManagementTrait { } } } + + protected function reorderBeforeDelete() + { + $this->createQuery() + ->filterByParent($this->getParent()) + ->update(array('Position' => '(position-1)')); + } } \ No newline at end of file