mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 06:00:28 +01:00
Shopware6: fix extended Prices
This commit is contained in:
parent
d39f9bb2fe
commit
10c077006d
@ -129,6 +129,8 @@ final class Shopware6Client
|
||||
],
|
||||
],
|
||||
];
|
||||
if ($priceData->getEndingQuantity() > 0)
|
||||
$data['quantityEnd'] = $priceData->getEndingQuantity();
|
||||
|
||||
return $this->request(
|
||||
'POST',
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user