From 9eb958a1a6e6cd689265405c31e46bdb59d480c3 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sat, 7 Oct 2023 23:23:17 +0200 Subject: [PATCH] Shopware6: apply taxId on variants as well and small bug fixes (maybe for PHP8.1) --- www/pages/shopimporter_shopware6.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/www/pages/shopimporter_shopware6.php b/www/pages/shopimporter_shopware6.php index 3d639e1b..d69101bc 100644 --- a/www/pages/shopimporter_shopware6.php +++ b/www/pages/shopimporter_shopware6.php @@ -2725,7 +2725,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase } foreach ($internalPropertyGroupValues as $internalPropertyGroupValue => $valueNotNeeded) { - if (!array_key_exists($internalPropertyGroupValue, $internalGroupPropertiesToShopwareId[$propertyGroupName])) { + if (!array_key_exists($internalPropertyGroupValue, $internalGroupPropertiesToShopwareId[$propertyGroupName] ?? [])) { $newOptionData = [ 'name' => (string)$internalPropertyGroupValue ]; @@ -2798,6 +2798,13 @@ class Shopimporter_Shopware6 extends ShopimporterBase $isCloseOut = true; } + if ($variant['umsatzsteuer'] == 'normal' && !empty($this->normalTaxId)) + $taxId = $this->normalTaxId; + else if ($variant['umsatzsteuer'] == 'ermäßigt' && !empty($this->reducedTaxId)) + $taxId = $this->reducedTaxId; + else + $taxId = $this->getTaxIdByRate($variant['steuersatz']); + $variantProductData = [ 'active' => $active, 'isCloseout' => $isCloseOut, @@ -2820,7 +2827,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase ], 'stock' => (int)$stock, 'ean' => null, - 'taxId' => $this->getTaxIdByRate($variant['steuersatz']), + 'taxId' => $taxId, ]; if(!empty($weight)){ $variantProductData['weight'] = $weight; @@ -2837,7 +2844,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase foreach ($internalVariantMatrixData as $expression) { if (!in_array( $internalGroupPropertiesToShopwareId[$expression['name']][$expression['values']], - $existingCombinationsByNumber[$productNumber]['options'], + $existingCombinationsByNumber[$productNumber]['options'] ?? [], false)) { $renewVariant = true; } else {