|
| 1 | +diff --git a/vendor/magento/module-company/Model/CompanyContext.php b/vendor/magento/module-company/Model/CompanyContext.php |
| 2 | +index 6702e91d2483..e94ac986cf40 100644 |
| 3 | +--- a/vendor/magento/module-company/Model/CompanyContext.php |
| 4 | ++++ b/vendor/magento/module-company/Model/CompanyContext.php |
| 5 | +@@ -6,6 +6,8 @@ |
| 6 | + |
| 7 | + namespace Magento\Company\Model; |
| 8 | + |
| 9 | ++use Magento\Customer\Model\CustomerRegistry; |
| 10 | ++use Magento\Framework\App\ObjectManager; |
| 11 | + use Magento\Framework\Exception\NoSuchEntityException; |
| 12 | + |
| 13 | + /** |
| 14 | +@@ -51,6 +53,11 @@ class CompanyContext |
| 15 | + */ |
| 16 | + private $httpContext; |
| 17 | + |
| 18 | ++ /** |
| 19 | ++ * @var CustomerRegistry |
| 20 | ++ */ |
| 21 | ++ private CustomerRegistry $customerRegistry; |
| 22 | ++ |
| 23 | + /** |
| 24 | + * CompanyContext constructor. |
| 25 | + * |
| 26 | +@@ -60,6 +67,7 @@ class CompanyContext |
| 27 | + * @param \Magento\Company\Model\CompanyUserPermission $companyUserPermission |
| 28 | + * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository |
| 29 | + * @param \Magento\Framework\App\Http\Context $httpContext |
| 30 | ++ * @param CustomerRegistry $customerRegistry |
| 31 | + */ |
| 32 | + public function __construct( |
| 33 | + \Magento\Company\Api\StatusServiceInterface $moduleConfig, |
| 34 | +@@ -67,7 +75,8 @@ public function __construct( |
| 35 | + \Magento\Company\Api\AuthorizationInterface $authorization, |
| 36 | + \Magento\Company\Model\CompanyUserPermission $companyUserPermission, |
| 37 | + \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, |
| 38 | +- \Magento\Framework\App\Http\Context $httpContext |
| 39 | ++ \Magento\Framework\App\Http\Context $httpContext, |
| 40 | ++ CustomerRegistry $customerRegistry = null |
| 41 | + ) { |
| 42 | + $this->moduleConfig = $moduleConfig; |
| 43 | + $this->userContext = $userContext; |
| 44 | +@@ -75,6 +84,8 @@ public function __construct( |
| 45 | + $this->companyUserPermission = $companyUserPermission; |
| 46 | + $this->customerRepository = $customerRepository; |
| 47 | + $this->httpContext = $httpContext; |
| 48 | ++ $this->customerRegistry = $customerRegistry ?: ObjectManager::getInstance() |
| 49 | ++ ->get(CustomerRegistry::class); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | +@@ -144,7 +155,6 @@ public function isCurrentUserCompanyUser() |
| 54 | + * Retrieves customer group of the user. |
| 55 | + * |
| 56 | + * @return int |
| 57 | +- * @throws \Magento\Framework\Exception\LocalizedException |
| 58 | + */ |
| 59 | + public function getCustomerGroupId() |
| 60 | + { |
| 61 | +@@ -152,7 +162,7 @@ public function getCustomerGroupId() |
| 62 | + $customerId = $this->getCustomerId(); |
| 63 | + if ($customerId) { |
| 64 | + try { |
| 65 | +- $customer = $this->customerRepository->getById($customerId); |
| 66 | ++ $customer = $this->customerRegistry->retrieve($customerId); |
| 67 | + $this->customerGroupId = $customer->getGroupId(); |
| 68 | + } catch (NoSuchEntityException $e) { |
| 69 | + } |
| 70 | +diff --git a/vendor/magento/module-shared-catalog/Plugin/Customer/Model/SessionPlugin.php b/vendor/magento/module-shared-catalog/Plugin/Customer/Model/SessionPlugin.php |
| 71 | +index 698b76978c80..749cdcd34701 100644 |
| 72 | +--- a/vendor/magento/module-shared-catalog/Plugin/Customer/Model/SessionPlugin.php |
| 73 | ++++ b/vendor/magento/module-shared-catalog/Plugin/Customer/Model/SessionPlugin.php |
| 74 | +@@ -23,16 +23,17 @@ class SessionPlugin |
| 75 | + public function afterGetCustomerGroupId(Session $subject, $groupId) |
| 76 | + { |
| 77 | + try { |
| 78 | +- if ($subject->getCustomerData()) { |
| 79 | +- if ($groupId != $subject->getCustomerData()->getGroupId()) { |
| 80 | +- $customerGroupId = $subject->getCustomerData()->getGroupId(); |
| 81 | +- $subject->setCustomerGroupId($customerGroupId); |
| 82 | +- return $customerGroupId; |
| 83 | +- } |
| 84 | ++ $customer = $subject->getCustomer(); |
| 85 | ++ if ($customer->getGroupId() && ($groupId != $customer->getGroupId())) { |
| 86 | ++ $customerGroupId = $customer->getGroupId(); |
| 87 | ++ $subject->setCustomerGroupId($customerGroupId); |
| 88 | ++ |
| 89 | ++ return $customerGroupId; |
| 90 | + } |
| 91 | +- return $groupId; |
| 92 | +- } catch (NoSuchEntityException $e) { |
| 93 | ++ } catch (NoSuchEntityException $exception) { |
| 94 | + return $groupId; |
| 95 | + } |
| 96 | ++ |
| 97 | ++ return $groupId; |
| 98 | + } |
| 99 | + } |
0 commit comments