From 03c912ce480346fec6b3c65e92e286ae04270385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Reynaud?= <42959493+jeremy-wizaplace@users.noreply.github.com> Date: Tue, 21 Jan 2020 09:29:04 +0100 Subject: [PATCH] WIZ-6009 Fix Wizaplace\SDK\Pim\Product\PriceTier::getPrice (#8706) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * WIZ-6009: Fix -théorique- du bug. Attendre vérif de GFI et valider * WIZ-6009 remove LogicException Co-authored-by: Roupioz <52406581+clementwizaplace@users.noreply.github.com> --- src/Catalog/ProductOffer.php | 15 ++++++++++++++- src/Pim/Product/PriceTier.php | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Catalog/ProductOffer.php b/src/Catalog/ProductOffer.php index 4f87a9ec..2374e10f 100644 --- a/src/Catalog/ProductOffer.php +++ b/src/Catalog/ProductOffer.php @@ -8,6 +8,7 @@ namespace Wizaplace\SDK\Catalog; +use Wizaplace\SDK\Pim\Product\ExtendedPriceTier; use Wizaplace\SDK\Pim\Product\ProductStatus; class ProductOffer @@ -22,7 +23,8 @@ class ProductOffer private $divisions; /** @var ProductStatus|null */ private $status; - + /** @var array */ + private $priceTiers; /** * ProductOffer constructor. * @@ -38,6 +40,12 @@ public function __construct(array $data) if (isset($data['status']) && in_array($data['status'], ProductStatus::toArray())) { $this->status = new ProductStatus($data['status']); } + + if (\array_key_exists('priceTiers', $data) && \is_array($data['priceTiers'])) { + foreach ($data['priceTiers'] as $priceTier) { + $this->addPriceTier($priceTier); + } + } } public function getProductId(): int @@ -64,4 +72,9 @@ public function getStatus(): ?ProductStatus { return $this->status; } + + public function addPriceTier(array $priceTier): void + { + $this->priceTiers[] = new ExtendedPriceTier($priceTier); + } } diff --git a/src/Pim/Product/PriceTier.php b/src/Pim/Product/PriceTier.php index 3911a5c6..aea6495e 100644 --- a/src/Pim/Product/PriceTier.php +++ b/src/Pim/Product/PriceTier.php @@ -47,8 +47,8 @@ public function setLowerLimit(int $lowerLimit): self return $this; } - /** @return float */ - public function getPrice(): float + /** @return null|float */ + public function getPrice(): ?float { return $this->price; }