From 5b33e09021feb00acf2f9487a908c8ab511bb0ae Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Fri, 8 Mar 2024 22:45:18 +0100 Subject: [PATCH] Add Support for BogxProductConfigurator (Shopware6) --- www/pages/shopimporter_shopware6.php | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/www/pages/shopimporter_shopware6.php b/www/pages/shopimporter_shopware6.php index 87f8ed0c..c42ad46d 100644 --- a/www/pages/shopimporter_shopware6.php +++ b/www/pages/shopimporter_shopware6.php @@ -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); + } }