mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-04-11 12:50:55 +00:00
parent
0b11bad72a
commit
0cbd954071
2 changed files with 49 additions and 2 deletions
|
@ -253,6 +253,8 @@ class RetailcrmIcml
|
|||
|
||||
private function setOffersFeatures($offer)
|
||||
{
|
||||
$lastFeaturesNumberCode = [];
|
||||
|
||||
foreach ($offer['features'] as $feature) {
|
||||
if (
|
||||
empty($feature['id_feature'])
|
||||
|
@ -262,11 +264,19 @@ class RetailcrmIcml
|
|||
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']);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,9 +126,46 @@ 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…
Add table
Reference in a new issue