From e426b878196876e6a112085063ce8212562f52e3 Mon Sep 17 00:00:00 2001 From: Vincent Lopes-Vicente Date: Fri, 20 Dec 2019 14:38:39 +0100 Subject: [PATCH] Fix when purchase price is null --- Config/module.xml | 2 +- LoopExtend/BaseCustomerFamilyLoopExtend.php | 4 ++++ Service/CustomerFamilyService.php | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Config/module.xml b/Config/module.xml index 8a3a5fd..4292d18 100755 --- a/Config/module.xml +++ b/Config/module.xml @@ -7,7 +7,7 @@ Famille de clients et prix d'achat - 1.5.1 + 1.5.2 Guillaume Barral / Etienne Perriere gbarral@openstudio.fr / eperriere@openstudio.fr diff --git a/LoopExtend/BaseCustomerFamilyLoopExtend.php b/LoopExtend/BaseCustomerFamilyLoopExtend.php index eca0f2e..67cb3ab 100644 --- a/LoopExtend/BaseCustomerFamilyLoopExtend.php +++ b/LoopExtend/BaseCustomerFamilyLoopExtend.php @@ -19,6 +19,10 @@ public function getCustomerFamily() { $currentCustomer = $this->securityContext->getCustomerUser(); + if (null === $currentCustomer) { + return null; + } + $customerFamily = CustomerFamilyQuery::create() ->useCustomerCustomerFamilyQuery() ->filterByCustomerId($currentCustomer->getId()) diff --git a/Service/CustomerFamilyService.php b/Service/CustomerFamilyService.php index a1c30df..e387fa9 100644 --- a/Service/CustomerFamilyService.php +++ b/Service/CustomerFamilyService.php @@ -96,12 +96,12 @@ public function getPseProductPrice($pseId, $currencyId) public function getPurchasePrice($pseId, $currencyId) { $mode = CustomerFamily::getConfigValue('customer_family_price_mode', 0); - if($mode == 1){ + if ($mode == 1) { $pseProductPrice = $this->getPseProductPrice($pseId, $currencyId); - return $pseProductPrice->getPrice(); + return $pseProductPrice !== null ? $pseProductPrice->getPrice() : null; } $pseProductPurchasePrice = $this->getPseProductPurchasePrice($pseId, $currencyId); - return $pseProductPurchasePrice->getPurchasePrice(); + return $pseProductPurchasePrice !== null ? $pseProductPurchasePrice->getPurchasePrice() : null; } /**