From bafe34d238b9eb2eaf674a3ac05bf1485097019f Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 2 Oct 2013 09:46:47 +0200 Subject: [PATCH] fix reorder position on folder and category removal --- .../Model/Tools/PositionManagementTrait.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php index d299fd3fc..edbbad62b 100644 --- a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php +++ b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php @@ -201,8 +201,17 @@ trait PositionManagementTrait { protected function reorderBeforeDelete() { - $this->createQuery() - ->filterByParent($this->getParent()) - ->update(array('Position' => '(position-1)')); + // Find DATABASE_NAME constant + $mapClassName = self::TABLE_MAP; + + $sql = sprintf("UPDATE `%s` SET position=(position-1) WHERE parent=:parent AND position>:position", $mapClassName::TABLE_NAME); + + $con = Propel::getConnection($mapClassName::DATABASE_NAME); + $statement = $con->prepare($sql); + + $statement->execute(array( + ':parent' => $this->getParent(), + ':position' => $this->getPosition() + )); } } \ No newline at end of file