From 1270cf6954c9196aa06d47f8c2f31594a86e8025 Mon Sep 17 00:00:00 2001 From: Benjamin Perche Date: Tue, 22 Jul 2014 15:29:17 +0200 Subject: [PATCH] =?UTF-8?q?Add=20promo=20import=20and=20export=20in=20pric?= =?UTF-8?q?es=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia?= =?UTF-8?q?/ImportExport/Export/Type/ProductPricesExport.php=20=09modifi?= =?UTF-8?q?=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/ImportExport/?= =?UTF-8?q?Import/Type/ProductPricesImport.php=20=09modifi=C3=A9:=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20core/lib/Thelia/Tests/ImportExport/Export/Pro?= =?UTF-8?q?ductPricesExportTest.php=20=09modifi=C3=A9:=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20core/lib/Thelia/Tests/ImportExport/Import/ProductPrice?= =?UTF-8?q?sImportTest.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImportExport/Export/Type/ProductPricesExport.php | 3 +++ .../ImportExport/Import/Type/ProductPricesImport.php | 8 ++++++++ .../Tests/ImportExport/Export/ProductPricesExportTest.php | 3 ++- .../Tests/ImportExport/Import/ProductPricesImportTest.php | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php b/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php index d7329f3a2..d212aa4a7 100644 --- a/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php +++ b/core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php @@ -71,6 +71,7 @@ class ProductPricesExport extends ExportHandler "currency_CODE" => "currency", "product_TITLE" => "title", "attribute_av_i18n_ATTRIBUTES" => "attributes", + "product_sale_elements_PROMO" => "promo", ]; $locale = $this->real_escape($lang->getLocale()); @@ -92,6 +93,7 @@ class ProductPricesExport extends ExportHandler ->endUse() ->addAsColumn("product_sale_elements_REF", ProductSaleElementsTableMap::REF) ->addAsColumn("product_sale_elements_EAN_CODE", ProductSaleElementsTableMap::EAN_CODE) + ->addAsColumn("product_sale_elements_PROMO", ProductSaleElementsTableMap::PROMO) ->endUse() ->useAttributeAvQuery() ->useAttributeAvI18nQuery(null, Criteria::INNER_JOIN) @@ -104,6 +106,7 @@ class ProductPricesExport extends ExportHandler ->select([ "product_sale_elements_REF", "product_sale_elements_EAN_CODE", + "product_sale_elements_PROMO", "price_PRICE", "price_PROMO_PRICE", "currency_CODE", diff --git a/core/lib/Thelia/ImportExport/Import/Type/ProductPricesImport.php b/core/lib/Thelia/ImportExport/Import/Type/ProductPricesImport.php index f3c2f8dcc..3568f40bc 100644 --- a/core/lib/Thelia/ImportExport/Import/Type/ProductPricesImport.php +++ b/core/lib/Thelia/ImportExport/Import/Type/ProductPricesImport.php @@ -109,6 +109,14 @@ class ProductPricesImport extends ImportHandler $price->setPromoPrice($row["promo_price"]); } + if (isset($row["promo"])) { + $price + ->getProductSaleElements() + ->setPromo((int)$row["promo"]) + ->save() + ; + } + $price->save(); $this->importedRows++; } diff --git a/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php b/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php index fa74938f0..910a8b96a 100644 --- a/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php +++ b/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php @@ -33,7 +33,7 @@ class ProductPricesExportTest extends \PHPUnit_Framework_TestCase $data = $export->buildFormatterData(Lang::getDefaultLanguage()); - $keys = ["attributes","currency","ean","price","promo_price","ref","title"]; + $keys = ["attributes","currency","ean","price","promo","promo_price","ref","title"]; $rawData = $data->getData(); @@ -62,6 +62,7 @@ class ProductPricesExportTest extends \PHPUnit_Framework_TestCase $this->assertNotNull($pse); $this->assertEquals($pse->getEanCode(),$row["ean"]); + $this->assertEquals($pse->getPromo(),$row["promo"]); $currency = CurrencyQuery::create()->findOneByCode($row["currency"]); $this->assertNotNull($currency); diff --git a/core/lib/Thelia/Tests/ImportExport/Import/ProductPricesImportTest.php b/core/lib/Thelia/Tests/ImportExport/Import/ProductPricesImportTest.php index f1a2fb071..e62e0450e 100644 --- a/core/lib/Thelia/Tests/ImportExport/Import/ProductPricesImportTest.php +++ b/core/lib/Thelia/Tests/ImportExport/Import/ProductPricesImportTest.php @@ -78,6 +78,7 @@ class ProductPricesImportTest extends ControllerTestBase */ while ($pse->getPricesByCurrency($currency)->getPrice() === $entry["price"] = rand(0, 1000)); while ($pse->getPricesByCurrency($currency)->getPromoPrice() === $entry["promo_price"] = rand(0, 1000)); + while ($pse->getPromo() === $entry["promo_price"] = rand(0, 1000)); $data[$pse->getId()] = $entry;