mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
parent
6b7599ec64
commit
05e332ce76
@ -1,3 +1,6 @@
|
||||
## v3.5.8
|
||||
* Реализована передача характеристик товара в ICML каталог
|
||||
|
||||
## v3.5.7
|
||||
* Изменены минимально поддерживаемые версии PrestaShop и PHP
|
||||
|
||||
|
3
retailcrm/lib/RetailcrmCatalog.php
Normal file → Executable file
3
retailcrm/lib/RetailcrmCatalog.php
Normal file → Executable file
@ -208,6 +208,7 @@ class RetailcrmCatalog
|
||||
}
|
||||
|
||||
$offers = Product::getProductAttributesIds($product['id_product']);
|
||||
$features = Product::getFrontFeaturesStatic($id_lang, $product['id_product']);
|
||||
|
||||
if (!empty($offers)) {
|
||||
$offersCount += count($offers);
|
||||
@ -290,6 +291,7 @@ class RetailcrmCatalog
|
||||
'weight' => $weight,
|
||||
'dimensions' => $dimensions,
|
||||
'vatRate' => $product['rate'],
|
||||
'features' => $features,
|
||||
];
|
||||
|
||||
if (!empty($combinations)) {
|
||||
@ -347,6 +349,7 @@ class RetailcrmCatalog
|
||||
'weight' => $weight,
|
||||
'dimensions' => $dimensions,
|
||||
'vatRate' => $product['rate'],
|
||||
'features' => $features,
|
||||
],
|
||||
[
|
||||
'product' => $product,
|
||||
|
30
retailcrm/lib/RetailcrmIcml.php
Normal file → Executable file
30
retailcrm/lib/RetailcrmIcml.php
Normal file → Executable file
@ -189,6 +189,7 @@ class RetailcrmIcml
|
||||
$this->setOffersProperties($offer);
|
||||
$this->setOffersParams($offer);
|
||||
$this->setOffersCombinations($offer);
|
||||
$this->setOffersFeatures($offer);
|
||||
|
||||
$this->writer->endElement(); // end </offer>
|
||||
}
|
||||
@ -250,6 +251,35 @@ class RetailcrmIcml
|
||||
}
|
||||
}
|
||||
|
||||
private function setOffersFeatures($offer)
|
||||
{
|
||||
$lastFeaturesNumberCode = [];
|
||||
|
||||
foreach ($offer['features'] as $feature) {
|
||||
if (
|
||||
empty($feature['id_feature'])
|
||||
|| empty($feature['name'])
|
||||
|| null === $feature['value']
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$numberCode = 1;
|
||||
|
||||
if (isset($lastFeaturesNumberCode[$feature['id_feature']])) {
|
||||
$numberCode = 1 + $lastFeaturesNumberCode[$feature['id_feature']];
|
||||
}
|
||||
|
||||
$this->writer->startElement('param');
|
||||
$this->writer->writeAttribute('code', 'feature_' . $feature['id_feature'] . '_' . $numberCode);
|
||||
$this->writer->writeAttribute('name', $feature['name']);
|
||||
$this->writer->text($feature['value']);
|
||||
$this->writer->endElement();
|
||||
|
||||
$lastFeaturesNumberCode[$feature['id_feature']] = $numberCode;
|
||||
}
|
||||
}
|
||||
|
||||
private function writeEnd()
|
||||
{
|
||||
$this->writer->endElement(); // end </yml_catalog>
|
||||
|
2
retailcrm/retailcrm.php
Normal file → Executable file
2
retailcrm/retailcrm.php
Normal file → Executable file
@ -48,7 +48,7 @@ require_once dirname(__FILE__) . '/bootstrap.php';
|
||||
|
||||
class RetailCRM extends Module
|
||||
{
|
||||
const VERSION = '3.5.7';
|
||||
const VERSION = '3.5.8';
|
||||
|
||||
const API_URL = 'RETAILCRM_ADDRESS';
|
||||
const API_KEY = 'RETAILCRM_API_TOKEN';
|
||||
|
@ -126,9 +126,47 @@ class RetailcrmCatalogTest extends RetailcrmTestCase
|
||||
public function testIcmlGenerate()
|
||||
{
|
||||
$icml = new RetailcrmIcml(Configuration::get('PS_SHOP_NAME'), _PS_ROOT_DIR_ . '/retailcrm.xml');
|
||||
$icml->generate($this->data[0], $this->data[1]);
|
||||
$offers = [];
|
||||
|
||||
foreach ($this->data[1] as $offer) {
|
||||
$offer['features'] = $this->getFeaturesData();
|
||||
$offers[] = $offer;
|
||||
}
|
||||
|
||||
$icml->generate($this->data[0], $offers);
|
||||
$this->assertFileExists(_PS_ROOT_DIR_ . '/retailcrm.xml');
|
||||
$xml = simplexml_load_file(_PS_ROOT_DIR_ . '/retailcrm.xml');
|
||||
$this->assertNotFalse($xml);
|
||||
}
|
||||
|
||||
private function getFeaturesData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'id_feature' => 1,
|
||||
'name' => 'test',
|
||||
'value' => 'value1',
|
||||
],
|
||||
[
|
||||
'id_feature' => 1,
|
||||
'name' => 'test',
|
||||
'value' => 'value2',
|
||||
],
|
||||
[
|
||||
'id_feature' => 1,
|
||||
'name' => 'test',
|
||||
'value' => 'value3',
|
||||
],
|
||||
[
|
||||
'id_feature' => 2,
|
||||
'name' => 'test',
|
||||
'value' => 'value1',
|
||||
],
|
||||
[
|
||||
'id_feature' => 2,
|
||||
'name' => 'test',
|
||||
'value' => 'value2',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user