diff --git a/core/lib/Thelia/Config/Resources/export.xml b/core/lib/Thelia/Config/Resources/export.xml
index 890f11199..0b7da011a 100644
--- a/core/lib/Thelia/Config/Resources/export.xml
+++ b/core/lib/Thelia/Config/Resources/export.xml
@@ -9,6 +9,10 @@
Customers
Clients
+
+ Products
+ Produits
+
@@ -22,5 +26,16 @@
Export the last name, first name and email address of the customers and the newsletter subscribers
+
+
+
+ Prix des produits
+ Expotez le prix de vos produits
+
+
+ Product prices
+ Export the prices of the products
+
+
diff --git a/core/lib/Thelia/Controller/Admin/ImportController.php b/core/lib/Thelia/Controller/Admin/ImportController.php
index f4fa11f28..2846d6854 100644
--- a/core/lib/Thelia/Controller/Admin/ImportController.php
+++ b/core/lib/Thelia/Controller/Admin/ImportController.php
@@ -106,11 +106,14 @@ class ImportController extends BaseAdminController
*/
$archiveBuilder = $archiveBuilder->loadArchive($file->getPathname());
- $content = $this->getFileContentInArchive(
+ $contentAndFormat = $this->getFileContentInArchive(
$archiveBuilder,
$formatterManager,
$tools["types"]
);
+
+ $formatter = $contentAndFormat["formatter"];
+ $content = $contentAndFormat["content"];
} elseif ($formatter !== null) {
/**
* If the file isn't an archive
@@ -195,7 +198,10 @@ class ImportController extends BaseAdminController
);
}
- return $content;
+ return array(
+ "formatter" => $formatter,
+ "content" => $content,
+ );
}
public function retrieveFormatTools(
@@ -302,7 +308,7 @@ class ImportController extends BaseAdminController
}
return $this->getTranslator()->trans(
- "Import successfully done, %numb row(s) have been imported",
+ "Import successfully done, %numb row(s) have been changed",
[
"%numb" => $handler->getImportedRows(),
]
diff --git a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php
index f00c14193..5d1613c72 100644
--- a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php
+++ b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php
@@ -365,12 +365,7 @@ class XmlFileLoader extends FileLoader
if (!class_exists($class)) {
throw new \ErrorException(
- Translator::getInstance()->trans(
- "The class \"%class\" doesn't exist",
- [
- "%class" => $class
- ]
- )
+ "The class \"$class\" doesn't exist"
);
}
@@ -378,13 +373,7 @@ class XmlFileLoader extends FileLoader
if (!$classInstance instanceof ExportHandler) {
throw new \ErrorException(
- Translator::getInstance()->trans(
- "The class \"%class\" must extend %baseClass",
- [
- "%class" => $class,
- "%baseClass" => "Thelia\\ImportExport\\Export\\ExportHandler",
- ]
- )
+ "The class \"$class\" must extend Thelia\\ImportExport\\Export\\ExportHandler"
);
}
@@ -392,12 +381,7 @@ class XmlFileLoader extends FileLoader
if (null === $category) {
throw new \ErrorException(
- Translator::getInstance()->trans(
- "The export category \"%category\" doesn't exist",
- [
- "%category" => $categoryRef
- ]
- )
+ "The export category \"$categoryRef\" doesn't exist"
);
}
@@ -518,12 +502,7 @@ class XmlFileLoader extends FileLoader
if (!class_exists($class)) {
throw new \ErrorException(
- Translator::getInstance()->trans(
- "The class \"%class\" doesn't exist",
- [
- "%class" => $class
- ]
- )
+ "The class \"$class\" doesn't exist"
);
}
@@ -531,13 +510,7 @@ class XmlFileLoader extends FileLoader
if (!$classInstance instanceof ImportHandler) {
throw new \ErrorException(
- Translator::getInstance()->trans(
- "The class \"%class\" must extend %baseClass",
- [
- "%class" => $class,
- "%baseClass" => "Thelia\\ImportImport\\ImportHandler",
- ]
- )
+ "The class \"$class\" must extend Thelia\\ImportImport\\ImportHandler"
);
}
@@ -545,12 +518,7 @@ class XmlFileLoader extends FileLoader
if (null === $category) {
throw new \ErrorException(
- Translator::getInstance()->trans(
- "The import category \"%category\" doesn't exist",
- [
- "%category" => $categoryRef
- ]
- )
+ "The import category \"$categoryRef\" doesn't exist"
);
}
diff --git a/core/lib/Thelia/Core/DependencyInjection/Loader/schema/dic/config/thelia-1.0.xsd b/core/lib/Thelia/Core/DependencyInjection/Loader/schema/dic/config/thelia-1.0.xsd
index 91817058e..5dfb98aea 100644
--- a/core/lib/Thelia/Core/DependencyInjection/Loader/schema/dic/config/thelia-1.0.xsd
+++ b/core/lib/Thelia/Core/DependencyInjection/Loader/schema/dic/config/thelia-1.0.xsd
@@ -227,7 +227,7 @@
-
+
@@ -274,7 +274,7 @@
-
+
diff --git a/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php b/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php
new file mode 100644
index 000000000..03a248d5d
--- /dev/null
+++ b/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php
@@ -0,0 +1,87 @@
+
+ */
+class ProductPricesExport extends ExportHandler
+{
+ /**
+ * @return string|array
+ *
+ * Define all the type of formatters that this can handle
+ * return a string if it handle a single type ( specific exports ),
+ * or an array if multiple.
+ *
+ * Thelia types are defined in \Thelia\Core\FileFormat\FormatType
+ *
+ * example:
+ * return array(
+ * FormatType::TABLE,
+ * FormatType::UNBOUNDED,
+ * );
+ */
+ public function getHandledTypes()
+ {
+ return array(
+ FormatType::TABLE,
+ FormatType::UNBOUNDED,
+ );
+ }
+
+ /**
+ * @return \Thelia\Core\FileFormat\Formatting\FormatterData
+ *
+ * The method builds the FormatterData for the formatter
+ */
+ public function buildFormatterData()
+ {
+ $aliases = [
+ ProductSaleElementsTableMap::REF => "ref",
+ "price_PRICE" => "price",
+ "price_PROMO_PRICE" => "promo_price",
+ "currency_CODE" => "currency",
+ ];
+
+ $query = ProductSaleElementsQuery::create()
+ ->useProductPriceQuery()
+ ->useCurrencyQuery()
+ ->addAsColumn("currency_CODE", CurrencyTableMap::CODE)
+ ->endUse()
+ ->addAsColumn("price_PRICE", ProductPriceTableMap::PRICE)
+ ->addAsColumn("price_PROMO_PRICE", ProductPriceTableMap::PROMO_PRICE)
+ ->endUse()
+ ->select([
+ ProductSaleElementsTableMap::REF,
+ "price_PRICE",
+ "price_PROMO_PRICE",
+ "currency_CODE",
+ ])
+ ;
+
+ $data = new FormatterData($aliases);
+
+ return $data->loadModelCriteria($query);
+ }
+
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Tests/Controller/ImportControllerTest.php b/core/lib/Thelia/Tests/Controller/ImportControllerTest.php
index ff645b6a2..d6ae59ed8 100644
--- a/core/lib/Thelia/Tests/Controller/ImportControllerTest.php
+++ b/core/lib/Thelia/Tests/Controller/ImportControllerTest.php
@@ -83,7 +83,13 @@ class ImportControllerTrait extends ControllerTestBase
[$formatter->getHandledType()]
);
- $this->assertEquals("foo", $content);
+ $this->assertEquals(
+ [
+ "content" => "foo",
+ "formatter" => $formatter
+ ],
+ $content
+ );
}
/**