Skip to content

Instantly share code, notes, and snippets.

@amacgregor
Created January 13, 2015 13:56
Show Gist options
  • Save amacgregor/497d247b9d34b47e487a to your computer and use it in GitHub Desktop.
Save amacgregor/497d247b9d34b47e487a to your computer and use it in GitHub Desktop.
/**
* Retrieve Customer instance
*
* @return \Magento\Customer\Api\Data\CustomerInterface
*/
public function getCustomer()
{
if (is_null($this->_customer)) {
$params = $this->urlDecoder->decode($this->_getRequest()->getParam('data'));
$data = explode(',', $params);
$customerId = abs(intval($data[0]));
if ($customerId && ($customerId == $this->_customerSession->getCustomerId())) {
$this->_customer = $this->_customerRepository->getById($customerId);
} else {
$this->_customer = $this->_customerBuilder->create();
}
}
return $this->_customer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment