本文整理汇总了PHP中Magento\Customer\Helper\Session\CurrentCustomer::getCustomer方法的典型用法代码示例。如果您正苦于以下问题:PHP CurrentCustomer::getCustomer方法的具体用法?PHP CurrentCustomer::getCustomer怎么用?PHP CurrentCustomer::getCustomer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Customer\Helper\Session\CurrentCustomer
的用法示例。
在下文中一共展示了CurrentCustomer::getCustomer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCustomer
/**
* Returns the Magento Customer Model for this block
*
* @return \Magento\Customer\Api\Data\CustomerInterface|null
*/
public function getCustomer()
{
try {
return $this->currentCustomer->getCustomer();
} catch (NoSuchEntityException $e) {
return null;
}
}
示例2: getSectionData
/**
* {@inheritdoc}
*/
public function getSectionData()
{
if (!$this->currentCustomer->getCustomerId()) {
return [];
}
$customer = $this->currentCustomer->getCustomer();
return ['fullname' => $this->customerViewHelper->getCustomerName($customer), 'firstname' => $customer->getFirstname()];
}
示例3: testGetCustomerLoadCustomerFromService
/**
* test get customer method, method returns customer from service
*/
public function testGetCustomerLoadCustomerFromService()
{
$this->moduleManagerMock->expects($this->once())->method('isEnabled')->with($this->equalTo('Magento_PageCache'))->will($this->returnValue(false));
$this->customerSessionMock->expects($this->once())->method('getId')->will($this->returnValue($this->customerId));
$this->customerRepositoryMock->expects($this->once())->method('getById')->with($this->equalTo($this->customerId))->will($this->returnValue($this->customerDataMock));
$this->assertEquals($this->customerDataMock, $this->currentCustomer->getCustomer());
}
示例4: getCustomer
/**
* Retrieve the Customer Data using the customer Id from the customer session.
*
* @return Customer
*/
public function getCustomer()
{
return $this->currentCustomer->getCustomer();
}