diff --git a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php index 5d1613c72..b98cc9204 100644 --- a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php +++ b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php @@ -25,7 +25,6 @@ use Symfony\Component\DependencyInjection\SimpleXMLElement; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Loader\FileLoader; -use Thelia\Core\Translation\Translator; use Thelia\ImportExport\Export\ExportHandler; use Thelia\ImportExport\Import\ImportHandler; use Thelia\Model\Export; diff --git a/core/lib/Thelia/Model/Export.php b/core/lib/Thelia/Model/Export.php index 99bb41133..a5fe33d2b 100644 --- a/core/lib/Thelia/Model/Export.php +++ b/core/lib/Thelia/Model/Export.php @@ -37,11 +37,7 @@ class Export extends BaseExport public function downPosition() { - $max = ExportQuery::create() - ->orderByPosition(Criteria::DESC) - ->select(ExportTableMap::POSITION) - ->findOne() - ; + $max = $this->getMaxPosition(); $count = $this->getExportCategory()->countExports(); @@ -82,11 +78,7 @@ class Export extends BaseExport public function setPositionToLast() { - $max = ExportQuery::create() - ->orderByPosition(Criteria::DESC) - ->select(ExportTableMap::POSITION) - ->findOne() - ; + $max = $this->getMaxPosition(); if (null === $max) { $this->setPosition(1); @@ -180,4 +172,14 @@ class Export extends BaseExport return static::$cache instanceof DocumentsExportInterface; } + + public function getMaxPosition() + { + return ExportQuery::create() + ->filterByExportCategoryId($this->getExportCategoryId()) + ->orderByPosition(Criteria::DESC) + ->select(ExportTableMap::POSITION) + ->findOne() + ; + } } diff --git a/core/lib/Thelia/Model/Import.php b/core/lib/Thelia/Model/Import.php index 61df4a815..250e9cce6 100644 --- a/core/lib/Thelia/Model/Import.php +++ b/core/lib/Thelia/Model/Import.php @@ -36,11 +36,7 @@ class Import extends BaseImport public function downPosition() { - $max = ImportQuery::create() - ->orderByPosition(Criteria::DESC) - ->select(ImportTableMap::POSITION) - ->findOne() - ; + $max = $this->getMaxPosition(); $count = $this->getImportCategory()->countImports(); @@ -81,11 +77,7 @@ class Import extends BaseImport public function setPositionToLast() { - $max = ImportQuery::create() - ->orderByPosition(Criteria::DESC) - ->select(ImportTableMap::POSITION) - ->findOne() - ; + $max = $this->getMaxPosition(); if (null === $max) { $this->setPosition(1); @@ -158,4 +150,13 @@ class Import extends BaseImport parent::delete($con); } + public function getMaxPosition() + { + return ImportQuery::create() + ->filterByImportCategoryId($this->getImportCategoryId()) + ->orderByPosition(Criteria::DESC) + ->select(ImportTableMap::POSITION) + ->findOne() + ; + } }