groupRepository = $groupRepository; $this->customerSession = $customerSession; $this->taxHelper = $taxHelper; $this->moduleManager = $moduleManager; $this->cacheConfig = $cacheConfig; $this->addressManager = $addressManager; } /** * @param Observer $observer * @return void * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function execute(Observer $observer) { if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->taxHelper->isCatalogPriceDisplayAffectedByTax() ) { /** @var \Magento\Customer\Model\Data\Customer $customer */ $customer = $observer->getData('customer'); $customerGroupId = $customer->getGroupId(); $customerGroup = $this->groupRepository->getById($customerGroupId); $customerTaxClassId = $customerGroup->getTaxClassId(); $this->customerSession->setCustomerTaxClassId($customerTaxClassId); $addresses = $customer->getAddresses(); if (isset($addresses)) { $this->addressManager->setDefaultAddressAfterLogIn($addresses); } } } }