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:
@@ -71,6 +71,7 @@ class ProductPricesExport extends ExportHandler
|
|||||||
"currency_CODE" => "currency",
|
"currency_CODE" => "currency",
|
||||||
"product_TITLE" => "title",
|
"product_TITLE" => "title",
|
||||||
"attribute_av_i18n_ATTRIBUTES" => "attributes",
|
"attribute_av_i18n_ATTRIBUTES" => "attributes",
|
||||||
|
"product_sale_elements_PROMO" => "promo",
|
||||||
];
|
];
|
||||||
|
|
||||||
$locale = $this->real_escape($lang->getLocale());
|
$locale = $this->real_escape($lang->getLocale());
|
||||||
@@ -92,6 +93,7 @@ class ProductPricesExport extends ExportHandler
|
|||||||
->endUse()
|
->endUse()
|
||||||
->addAsColumn("product_sale_elements_REF", ProductSaleElementsTableMap::REF)
|
->addAsColumn("product_sale_elements_REF", ProductSaleElementsTableMap::REF)
|
||||||
->addAsColumn("product_sale_elements_EAN_CODE", ProductSaleElementsTableMap::EAN_CODE)
|
->addAsColumn("product_sale_elements_EAN_CODE", ProductSaleElementsTableMap::EAN_CODE)
|
||||||
|
->addAsColumn("product_sale_elements_PROMO", ProductSaleElementsTableMap::PROMO)
|
||||||
->endUse()
|
->endUse()
|
||||||
->useAttributeAvQuery()
|
->useAttributeAvQuery()
|
||||||
->useAttributeAvI18nQuery(null, Criteria::INNER_JOIN)
|
->useAttributeAvI18nQuery(null, Criteria::INNER_JOIN)
|
||||||
@@ -104,6 +106,7 @@ class ProductPricesExport extends ExportHandler
|
|||||||
->select([
|
->select([
|
||||||
"product_sale_elements_REF",
|
"product_sale_elements_REF",
|
||||||
"product_sale_elements_EAN_CODE",
|
"product_sale_elements_EAN_CODE",
|
||||||
|
"product_sale_elements_PROMO",
|
||||||
"price_PRICE",
|
"price_PRICE",
|
||||||
"price_PROMO_PRICE",
|
"price_PROMO_PRICE",
|
||||||
"currency_CODE",
|
"currency_CODE",
|
||||||
|
|||||||
@@ -109,6 +109,14 @@ class ProductPricesImport extends ImportHandler
|
|||||||
$price->setPromoPrice($row["promo_price"]);
|
$price->setPromoPrice($row["promo_price"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($row["promo"])) {
|
||||||
|
$price
|
||||||
|
->getProductSaleElements()
|
||||||
|
->setPromo((int)$row["promo"])
|
||||||
|
->save()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
$price->save();
|
$price->save();
|
||||||
$this->importedRows++;
|
$this->importedRows++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class ProductPricesExportTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$data = $export->buildFormatterData(Lang::getDefaultLanguage());
|
$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();
|
$rawData = $data->getData();
|
||||||
|
|
||||||
@@ -62,6 +62,7 @@ class ProductPricesExportTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertNotNull($pse);
|
$this->assertNotNull($pse);
|
||||||
$this->assertEquals($pse->getEanCode(),$row["ean"]);
|
$this->assertEquals($pse->getEanCode(),$row["ean"]);
|
||||||
|
$this->assertEquals($pse->getPromo(),$row["promo"]);
|
||||||
|
|
||||||
$currency = CurrencyQuery::create()->findOneByCode($row["currency"]);
|
$currency = CurrencyQuery::create()->findOneByCode($row["currency"]);
|
||||||
$this->assertNotNull($currency);
|
$this->assertNotNull($currency);
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class ProductPricesImportTest extends ControllerTestBase
|
|||||||
*/
|
*/
|
||||||
while ($pse->getPricesByCurrency($currency)->getPrice() === $entry["price"] = rand(0, 1000));
|
while ($pse->getPricesByCurrency($currency)->getPrice() === $entry["price"] = rand(0, 1000));
|
||||||
while ($pse->getPricesByCurrency($currency)->getPromoPrice() === $entry["promo_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;
|
$data[$pse->getId()] = $entry;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user