diff --git a/core/lib/Thelia/Config/Resources/export.xml b/core/lib/Thelia/Config/Resources/export.xml
index 9d7bf8949..c8d6152c3 100644
--- a/core/lib/Thelia/Config/Resources/export.xml
+++ b/core/lib/Thelia/Config/Resources/export.xml
@@ -17,6 +17,11 @@
Content
Contenu
+
+
+ Orders
+ Commandes
+
@@ -53,6 +58,17 @@
+
+
+ Prix des produits TTC
+ Expotez le prix TTC de vos produits
+
+
+ Product prices including taxes
+ Export the prices of the products including taxes
+
+
+
Product SEO information
@@ -83,5 +99,20 @@
+
+
+
+ Full orders
+
+ Export your orders.
+
+
+
+ Commandes complètes
+
+ Exportez vos commandes
+
+
+
diff --git a/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php b/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php
index e5b9ed4bb..60ab87f35 100644
--- a/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php
+++ b/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php
@@ -57,8 +57,8 @@ class ProductPricesExport extends ExportHandler
}
/**
- * @param Lang $lang
- * @return FormatterData
+ * @param Lang $lang
+ * @return array|\Propel\Runtime\ActiveQuery\ModelCriteria|\Thelia\Core\Template\Element\BaseLoop
*/
public function buildDataSet(Lang $lang)
{
@@ -86,6 +86,7 @@ class ProductPricesExport extends ExportHandler
\PDO::PARAM_STR
)
->addAsColumn("product_TITLE", ProductI18nTableMap::TITLE)
+ ->addAsColumn("product_ID", ProductTableMap::ID)
->endUse()
->addAsColumn("product_sale_elements_REF", ProductSaleElementsTableMap::REF)
->addAsColumn("product_sale_elements_EAN_CODE", ProductSaleElementsTableMap::EAN_CODE)
@@ -118,6 +119,21 @@ class ProductPricesExport extends ExportHandler
return $query;
}
+ public function getOrder()
+ {
+ return [
+ "product_id",
+ "ref",
+ "title",
+ "attributes",
+ "ean",
+ "price",
+ "promo_price",
+ "currency",
+ "promo",
+ ];
+ }
+
protected function getAliases()
{
return [
diff --git a/core/lib/Thelia/ImportExport/Export/Type/ProductTaxedPricesExport.php b/core/lib/Thelia/ImportExport/Export/Type/ProductTaxedPricesExport.php
new file mode 100644
index 000000000..fe1346dec
--- /dev/null
+++ b/core/lib/Thelia/ImportExport/Export/Type/ProductTaxedPricesExport.php
@@ -0,0 +1,101 @@
+
+ */
+class ProductTaxedPricesExport extends ProductPricesExport
+{
+ public function buildDataSet(Lang $lang)
+ {
+ /** @var \Thelia\Model\AttributeCombinationQuery $query */
+ $query = parent::buildDataSet($lang);
+
+
+ $pseJoin = new Join(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, ProductSaleElementsTableMap::ID);
+ $pseJoin->setRightTableAlias("pse_tax_join");
+
+ $productJoin = new Join(ProductSaleElementsTableMap::ID, ProductTableMap::ID);
+ $productJoin->setRightTableAlias("product_tax_join");
+
+ $taxJoin = new Join("`product_tax_join`.TAX_RULE_ID", TaxRuleTableMap::ID, Criteria::LEFT_JOIN);
+ $taxI18nJoin = new Join(TaxRuleTableMap::ID, TaxRuleI18nTableMap::ID, Criteria::LEFT_JOIN);
+
+ $query
+ ->addJoinObject($pseJoin, "pse_tax_join")
+ ->addJoinObject($productJoin, "product_tax_join")
+ ->addJoinObject($productJoin)
+ ->addJoinObject($taxJoin)
+ ->addJoinObject($taxI18nJoin)
+ ->addAsColumn("product_TAX_TITLE", TaxRuleI18nTableMap::TITLE)
+ ->addAsColumn("tax_ID", TaxRuleTableMap::ID)
+ ->select($query->getSelect() + [
+ "product_TAX_TITLE",
+ "tax_ID",
+ ])
+ ;
+
+ $this->addI18nCondition(
+ $query,
+ TaxRuleI18nTableMap::TABLE_NAME,
+ TaxRuleTableMap::ID,
+ TaxRuleI18nTableMap::ID,
+ TaxRuleI18nTableMap::LOCALE,
+ $lang->getLocale()
+ );
+
+ $dataSet = $query
+ ->keepQuery(true)
+ ->find()
+ ->toArray()
+ ;
+
+ $productSaleElements = ProductSaleElementsQuery::create()
+ ->find()
+ ->toKeyIndex("Ref")
+ ;
+
+ $currencies = CurrencyQuery::create()
+ ->find()
+ ->toKeyIndex("Code")
+ ;
+
+ foreach ($dataSet as &$line) {
+ /** @var \Thelia\Model\ProductSaleElements $pse */
+ $pse = $productSaleElements[$line["product_sale_elements_REF"]];
+
+ $pricesTools = $pse->getPricesByCurrency($currencies[$line["currency_CODE"]]);
+ $line["price_PRICE"] = $pricesTools->getPrice();
+ $line["price_PROMO_PRICE"] = $pricesTools->getPromoPrice();
+ }
+
+ return $dataSet;
+ }
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Tests/ImportExport/Export/ProductTaxedPricesExportTest.php b/core/lib/Thelia/Tests/ImportExport/Export/ProductTaxedPricesExportTest.php
new file mode 100644
index 000000000..d50001d39
--- /dev/null
+++ b/core/lib/Thelia/Tests/ImportExport/Export/ProductTaxedPricesExportTest.php
@@ -0,0 +1,50 @@
+
+ */
+class ProductTaxedPricesExportTest extends \PHPUnit_Framework_TestCase
+{
+ public function testPrices()
+ {
+ $container = new Container();
+ new Translator($container);
+
+ $handler = new ProductTaxedPricesExport($container);
+
+ $lang = Lang::getDefaultLanguage();
+ $data = $handler->buildData($lang)->getData();
+
+ foreach ($data as $line) {
+ $product = ProductSaleElementsQuery::create()->findOneByRef($line["ref"]);
+ $currency = CurrencyQuery::create()->findOneByCode($line["currency"]);
+
+ $this->assertNotNull($product);
+
+ $prices = $product->getPricesByCurrency($currency);
+
+ $this->assertEquals($prices->getPrice(), $line["price"]);
+ $this->assertEquals($prices->getPromoPrice(), $line["promo_price"]);
+ }
+ }
+}
\ No newline at end of file