diff --git a/classes/Modules/Shopware6/Client/Shopware6Client.php b/classes/Modules/Shopware6/Client/Shopware6Client.php index a7b3eed3..5b9eb20d 100644 --- a/classes/Modules/Shopware6/Client/Shopware6Client.php +++ b/classes/Modules/Shopware6/Client/Shopware6Client.php @@ -129,6 +129,8 @@ final class Shopware6Client ], ], ]; + if ($priceData->getEndingQuantity() > 0) + $data['quantityEnd'] = $priceData->getEndingQuantity(); return $this->request( 'POST', diff --git a/classes/Modules/Shopware6/Data/PriceData.php b/classes/Modules/Shopware6/Data/PriceData.php index 5e997bfd..3a2e2719 100644 --- a/classes/Modules/Shopware6/Data/PriceData.php +++ b/classes/Modules/Shopware6/Data/PriceData.php @@ -8,6 +8,8 @@ class PriceData { /** @var int */ protected $startingQuantity; + /** @var int|null */ + protected $endingQuantity; /** @var float */ protected $net; /** @var float */ @@ -26,13 +28,14 @@ class PriceData * @param $currency * @param $groupName */ - public function __construct(int $startingQuantity, float $net, float $gross, string $currency, string $groupName) + public function __construct(int $startingQuantity, float $net, float $gross, string $currency, string $groupName, int $endingQuantity = null) { $this->startingQuantity = $startingQuantity; $this->net = $net; $this->gross = $gross; $this->currency = $currency; $this->groupName = $groupName; + $this->endingQuantity = $endingQuantity; } /** @@ -95,6 +98,25 @@ class PriceData return $this; } + /** + * @return int|null + */ + public function getEndingQuantity(): int|null + { + return $this->endingQuantity; + } + + /** + * @param int $endingQuantity + * @return PriceData + */ + public function setEndingQuantity(int $endingQuantity): PriceData + { + $this->endingQuantity = $endingQuantity; + + return $this; + } + /** * @return float */ diff --git a/www/pages/shopimporter_shopware6.php b/www/pages/shopimporter_shopware6.php index 8496872a..61872a2e 100644 --- a/www/pages/shopimporter_shopware6.php +++ b/www/pages/shopimporter_shopware6.php @@ -2972,14 +2972,21 @@ class Shopimporter_Shopware6 extends ShopimporterBase * @return PriceData[] */ protected function getPricesFromArray($priceArray): array{ - return array_map(static function($price){ - return new PriceData( - (int)$price['ab_menge'], - (float)$price['preis'], - (float)$price['bruttopreis'], - $price['waehrung'], - $price['gruppeextern'] ?? '') ; - },$priceArray); + $c = count($priceArray); + $result = []; + for ($i = 0; $i < $c; $i++) { + $end = null; + if ($i+1 < $c && ($priceArray[$i+1]['gruppeextern'] ?? '') == ($priceArray[$i]['gruppeextern'] ?? '')) + $end = (int)$priceArray[$i+1]['ab_menge'] - 1; + $result[] = new PriceData( + (int)$priceArray[$i]['ab_menge'], + (float)$priceArray[$i]['preis'], + (float)$priceArray[$i]['bruttopreis'], + $priceArray[$i]['waehrung'], + $priceArray[$i]['gruppeextern'] ?? '', + $end); + } + return $result; } /**