Add promo import and export in prices

modifié:         core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php
	modifié:         core/lib/Thelia/ImportExport/Import/Type/ProductPricesImport.php
	modifié:         core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php
	modifié:         core/lib/Thelia/Tests/ImportExport/Import/ProductPricesImportTest.php
This commit is contained in:
Benjamin Perche
2014-07-22 15:29:17 +02:00
parent db876e4e81
commit 1270cf6954
4 changed files with 14 additions and 1 deletions

View File

@@ -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",

View File

@@ -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++;
}

View File

@@ -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);

View File

@@ -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;