Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DepersonalizePlugin.php
Go to the documentation of this file.
1 <?php
8 
10 
15 {
20 
24  protected $customerSession;
25 
30 
35 
40 
45  public function __construct(
47  \Magento\Customer\Model\Session $customerSession
48  ) {
49  $this->customerSession = $customerSession;
50  $this->depersonalizeChecker = $depersonalizeChecker;
51  }
52 
59  public function beforeGenerateXml(\Magento\Framework\View\LayoutInterface $subject)
60  {
61  if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) {
62  $this->defaultTaxBillingAddress = $this->customerSession->getDefaultTaxBillingAddress();
63  $this->defaultTaxShippingAddress = $this->customerSession->getDefaultTaxShippingAddress();
64  $this->customerTaxClassId = $this->customerSession->getCustomerTaxClassId();
65  }
66  return [];
67  }
68 
76  public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
77  {
78  if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) {
79  $this->customerSession->setDefaultTaxBillingAddress($this->defaultTaxBillingAddress);
80  $this->customerSession->setDefaultTaxShippingAddress($this->defaultTaxShippingAddress);
81  $this->customerSession->setCustomerTaxClassId($this->customerTaxClassId);
82  }
83  return $result;
84  }
85 }
beforeGenerateXml(\Magento\Framework\View\LayoutInterface $subject)
afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
__construct(DepersonalizeChecker $depersonalizeChecker, \Magento\Customer\Model\Session $customerSession)