mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +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(
|
return $this->request(
|
||||||
'POST',
|
'POST',
|
||||||
|
@ -8,6 +8,8 @@ class PriceData
|
|||||||
{
|
{
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $startingQuantity;
|
protected $startingQuantity;
|
||||||
|
/** @var int|null */
|
||||||
|
protected $endingQuantity;
|
||||||
/** @var float */
|
/** @var float */
|
||||||
protected $net;
|
protected $net;
|
||||||
/** @var float */
|
/** @var float */
|
||||||
@ -26,13 +28,14 @@ class PriceData
|
|||||||
* @param $currency
|
* @param $currency
|
||||||
* @param $groupName
|
* @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->startingQuantity = $startingQuantity;
|
||||||
$this->net = $net;
|
$this->net = $net;
|
||||||
$this->gross = $gross;
|
$this->gross = $gross;
|
||||||
$this->currency = $currency;
|
$this->currency = $currency;
|
||||||
$this->groupName = $groupName;
|
$this->groupName = $groupName;
|
||||||
|
$this->endingQuantity = $endingQuantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,6 +98,25 @@ class PriceData
|
|||||||
return $this;
|
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
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -2972,14 +2972,21 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
* @return PriceData[]
|
* @return PriceData[]
|
||||||
*/
|
*/
|
||||||
protected function getPricesFromArray($priceArray): array{
|
protected function getPricesFromArray($priceArray): array{
|
||||||
return array_map(static function($price){
|
$c = count($priceArray);
|
||||||
return new PriceData(
|
$result = [];
|
||||||
(int)$price['ab_menge'],
|
for ($i = 0; $i < $c; $i++) {
|
||||||
(float)$price['preis'],
|
$end = null;
|
||||||
(float)$price['bruttopreis'],
|
if ($i+1 < $c && ($priceArray[$i+1]['gruppeextern'] ?? '') == ($priceArray[$i]['gruppeextern'] ?? ''))
|
||||||
$price['waehrung'],
|
$end = (int)$priceArray[$i+1]['ab_menge'] - 1;
|
||||||
$price['gruppeextern'] ?? '') ;
|
$result[] = new PriceData(
|
||||||
},$priceArray);
|
(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