Add Support for BogxProductConfigurator (Shopware6)

This commit is contained in:
Andreas Palm 2024-03-08 22:45:18 +01:00
parent 42701becb1
commit 5b33e09021

View File

@ -3349,6 +3349,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
$productPriceType => $lineItem['attributes']['price']['unitPrice'],
'steuersatz' => $lineItem['attributes']['price']['calculatedTaxes'][0]['taxRate'],
];
$this->parseBogxData($lineItem, $product);
$cart['articlelist'][] = $product;
}
@ -3817,4 +3818,42 @@ class Shopimporter_Shopware6 extends ShopimporterBase
$this->updateArticleCacheToSync($articleIds);
}
protected function parseBogxData(array $lineItem, array &$product) : void
{
if (!isset($lineItem['attributes']['payload']['bogxProductConfigurator']))
return;
$bogxdata = $lineItem['attributes']['payload']['bogxProductConfigurator'];
file_put_contents("/var/www/bogx", print_r($bogxdata, true));
$textlines = [];
if (isset($bogxdata['ordercode']))
$textlines[] = "Order-Code: ${bogxdata['ordercode']}";
else
$textlines[] = "Produkt-Nr: ${bogxdata['articleordernumber']}";
foreach ($bogxdata['optionsGroups'] as $bogxposition) {
$dt = $bogxposition['datatype'];
if (is_array($bogxposition['valueID']) && is_array($bogxposition['title']))
{
foreach ($bogxposition['valueID'] as $valueID) {
$bogxTitle = $bogxposition['title'][$valueID];
if ($dt == 'checkbox_quantity')
$bogxTitle = $bogxposition['label'][$valueID]." ".$bogxTitle;
$textlines[] = sprintf("%s: %s", $bogxposition['groupname'], $bogxTitle);
}
}
else
{
if (is_array($bogxposition['title']))
$bogxTitle = join(' ', $bogxposition['title']);
else
$bogxTitle = $bogxposition['title'];
$textlines[] = sprintf("%s: %s", $bogxposition['groupname'], $bogxTitle);
}
}
$product['options'] .= join("\n", $textlines);
}
}