diff --git a/vendor/magento/module-shared-catalog/Plugin/Customer/Model/SessionPlugin.php b/vendor/magento/module-shared-catalog/Plugin/Customer/Model/SessionPlugin.php index 025510fd05..698b76978c 100644 --- a/vendor/magento/module-shared-catalog/Plugin/Customer/Model/SessionPlugin.php +++ b/vendor/magento/module-shared-catalog/Plugin/Customer/Model/SessionPlugin.php @@ -6,6 +6,7 @@ namespace Magento\SharedCatalog\Plugin\Customer\Model; use Magento\Customer\Model\Session; +use Magento\Framework\Exception\NoSuchEntityException; /** * Plugin assign company customer group id to customers after shared catalog was changed. @@ -21,13 +22,17 @@ class SessionPlugin */ public function afterGetCustomerGroupId(Session $subject, $groupId) { - if ($subject->getCustomerData()) { - if ($groupId != $subject->getCustomerData()->getGroupId()) { - $customerGroupId = $subject->getCustomerData()->getGroupId(); - $subject->setCustomerGroupId($customerGroupId); - return $customerGroupId; + try { + if ($subject->getCustomerData()) { + if ($groupId != $subject->getCustomerData()->getGroupId()) { + $customerGroupId = $subject->getCustomerData()->getGroupId(); + $subject->setCustomerGroupId($customerGroupId); + return $customerGroupId; + } } + return $groupId; + } catch (NoSuchEntityException $e) { + return $groupId; } - return $groupId; } }