Implemented transfer of features to ICML catalog
This commit is contained in:
Ivan Chaplygin 2023-09-01 10:39:37 +03:00
parent a307b1b4f0
commit 0b11bad72a
2 changed files with 21 additions and 2 deletions

View file

@ -208,7 +208,7 @@ class RetailcrmCatalog
}
$offers = Product::getProductAttributesIds($product['id_product']);
$features = Product::getFeaturesStatic($product['id_product']);
$features = Product::getFrontFeaturesStatic($id_lang, $product['id_product']);
if (!empty($offers)) {
$offersCount += count($offers);

21
retailcrm/lib/RetailcrmIcml.php Normal file → Executable file
View file

@ -189,6 +189,7 @@ class RetailcrmIcml
$this->setOffersProperties($offer);
$this->setOffersParams($offer);
$this->setOffersCombinations($offer);
$this->setOffersFeatures($offer);
$this->writer->endElement(); // end </offer>
}
@ -213,7 +214,6 @@ class RetailcrmIcml
private function setOffersParams($offer)
{
RetailcrmLogger::writeCaller('inventories', print_r($offer, true));
foreach ($offer as $key => $value) {
if (!array_key_exists($key, $this->params)) {
continue;
@ -251,6 +251,25 @@ class RetailcrmIcml
}
}
private function setOffersFeatures($offer)
{
foreach ($offer['features'] as $feature) {
if (
empty($feature['id_feature'])
|| empty($feature['name'])
|| $feature['value'] === null
) {
continue;
}
$this->writer->startElement('param');
$this->writer->writeAttribute('code', 'feature_' . $feature['id_feature']);
$this->writer->writeAttribute('name' , $feature['name']);
$this->writer->text($feature['value']);
$this->writer->endElement();
}
}
private function writeEnd()
{
$this->writer->endElement(); // end </yml_catalog>