/** * Returns current customer according to session and context * * @return \Magento\Customer\Service\V1\Data\Customer */ public function getCustomer() { if ($this->moduleManager->isEnabled('Magento_PageCache') && !$this->request->isAjax() && $this->view->isLayoutLoaded() && $this->layout->isCacheable()) { return $this->getDepersonalizedCustomer(); } else { return $this->getCustomerFromService(); } }