Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-customer
Helper
Session
CurrentCustomer.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Customer\Helper\Session
;
7
8
use
Magento\Customer\Api\CustomerRepositoryInterface
;
9
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
10
use
Magento\Customer\Model\Session
as
CustomerSession
;
11
use
Magento\Framework\App\RequestInterface
;
12
use
Magento\Framework\App\ViewInterface
;
13
use
Magento\Framework\Module\Manager
as ModuleManager;
14
use
Magento\Framework\View\LayoutInterface
;
15
19
class
CurrentCustomer
20
{
24
protected
$customerSession
;
25
29
protected
$layout
;
30
34
protected
$customerFactory
;
35
39
protected
$customerRepository
;
40
44
protected
$request
;
45
49
protected
$moduleManager
;
50
54
protected
$view
;
55
65
public
function
__construct
(
66
CustomerSession
$customerSession
,
67
LayoutInterface
$layout
,
68
CustomerInterfaceFactory
$customerFactory
,
69
CustomerRepositoryInterface
$customerRepository
,
70
RequestInterface
$request
,
71
ModuleManager
$moduleManager
,
72
ViewInterface
$view
73
) {
74
$this->customerSession =
$customerSession
;
75
$this->layout =
$layout
;
76
$this->customerFactory =
$customerFactory
;
77
$this->customerRepository =
$customerRepository
;
78
$this->request =
$request
;
79
$this->moduleManager =
$moduleManager
;
80
$this->view =
$view
;
81
}
82
88
protected
function
getDepersonalizedCustomer
()
89
{
90
$customer
= $this->customerFactory->create();
91
$customer
->setGroupId($this->customerSession->getCustomerGroupId());
92
return
$customer
;
93
}
94
100
protected
function
getCustomerFromService
()
101
{
102
return
$this->customerRepository->getById($this->customerSession->getId());
103
}
104
110
public
function
getCustomer
()
111
{
112
if
($this->moduleManager->isEnabled(
'Magento_PageCache'
)
113
&& !$this->request->isAjax()
114
&& $this->view->isLayoutLoaded()
115
&& $this->layout->isCacheable()
116
) {
117
return
$this->
getDepersonalizedCustomer
();
118
}
else
{
119
return
$this->
getCustomerFromService
();
120
}
121
}
122
128
public
function
getCustomerId
()
129
{
130
return
$this->customerSession->getId();
131
}
132
139
public
function
setCustomerId
(
$customerId
)
140
{
141
$this->customerSession->setId(
$customerId
);
142
}
143
}
Magento\Customer\Helper\Session\CurrentCustomer\getCustomerFromService
getCustomerFromService()
Definition:
CurrentCustomer.php:100
Magento\Customer\Helper\Session\CurrentCustomer
Definition:
CurrentCustomer.php:19
Magento\Customer\Helper\Session\CurrentCustomer\$customerSession
$customerSession
Definition:
CurrentCustomer.php:24
Magento\Customer\Helper\Session\CurrentCustomer\getDepersonalizedCustomer
getDepersonalizedCustomer()
Definition:
CurrentCustomer.php:88
$customer
$customer
Definition:
customers.php:11
Magento\Customer\Model\Session
Definition:
Storage.php:8
Magento\Customer\Helper\Session\CurrentCustomer\__construct
__construct(CustomerSession $customerSession, LayoutInterface $layout, CustomerInterfaceFactory $customerFactory, CustomerRepositoryInterface $customerRepository, RequestInterface $request, ModuleManager $moduleManager, ViewInterface $view)
Definition:
CurrentCustomer.php:65
Magento\Customer\Helper\Session\CurrentCustomer\getCustomer
getCustomer()
Definition:
CurrentCustomer.php:110
Magento\Customer\Helper\Session\CurrentCustomer\$view
$view
Definition:
CurrentCustomer.php:54
Magento\Framework\App\ViewInterface
Definition:
ViewInterface.php:17
Magento\Customer\Helper\Session\CurrentCustomer\$layout
$layout
Definition:
CurrentCustomer.php:29
Magento\Framework\App\RequestInterface
Definition:
RequestInterface.php:14
$customerId
$customerId
Definition:
quote_with_customer.php:16
Magento\Customer\Helper\Session
Definition:
CurrentCustomer.php:6
Magento\Customer\Api\CustomerRepositoryInterface
Definition:
CustomerRepositoryInterface.php:15
Magento\Customer\Helper\Session\CurrentCustomer\$request
$request
Definition:
CurrentCustomer.php:44
Magento\Framework\View\LayoutInterface
Definition:
LayoutInterface.php:13
Magento\Customer\Helper\Session\CurrentCustomer\getCustomerId
getCustomerId()
Definition:
CurrentCustomer.php:128
Magento\Framework\Module\Manager
Definition:
Manager.php:20
Magento\Customer\Helper\Session\CurrentCustomer\$customerFactory
$customerFactory
Definition:
CurrentCustomer.php:34
Magento\Customer\Helper\Session\CurrentCustomer\setCustomerId
setCustomerId($customerId)
Definition:
CurrentCustomer.php:139
Magento\Customer\Helper\Session\CurrentCustomer\$customerRepository
$customerRepository
Definition:
CurrentCustomer.php:39
Magento\Customer\Helper\Session\CurrentCustomer\$moduleManager
$moduleManager
Definition:
CurrentCustomer.php:49