15 private $addressRepository;
20 private $customerSession;
66 \
Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
67 \
Magento\Customer\Model\Session $customerSession
75 $this->customerSession = $customerSession;
88 $shippingAssignment =
$observer->getShippingAssignment();
92 $address = $shippingAssignment->getShipping()->getAddress();
97 if (
$customer->getDisableAutoGroupChange()
102 $customerCountryCode =
$address->getCountryId();
103 $customerVatNumber =
$address->getVatId();
106 if (empty($customerCountryCode) && empty($customerVatNumber) &&
$customer->getDefaultShipping()) {
114 if (empty($customerVatNumber) ||
false == $this->customerVat->isCountryInEU($customerCountryCode)) {
117 )->getId() : $this->groupManagement->getNotLoggedInGroup()->getId();
120 $groupId = $this->customerVat->getCustomerGroupIdBasedOnVatNumber(
121 $customerCountryCode,
128 $address->setPrevQuoteCustomerGroupId(
$quote->getCustomerGroupId());
130 $this->customerSession->setCustomerGroupId(
$groupId);
__construct(\Magento\Customer\Helper\Address $customerAddressHelper, \Magento\Customer\Model\Vat $customerVat, VatValidator $vatValidator, \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory, \Magento\Customer\Api\GroupManagementInterface $groupManagement, \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, \Magento\Customer\Model\Session $customerSession)
execute(Observer $observer)