61 private $emailNotification;
77 \Psr\Log\LoggerInterface
$logger 84 parent::__construct($context);
93 private function getEmailNotification()
96 return \Magento\Framework\App\ObjectManager::getInstance()->get(
97 EmailNotificationInterface::class
100 return $this->emailNotification;
110 $resultJson = $this->resultJsonFactory->create();
112 $postItems = $this->
getRequest()->getParam(
'items', []);
113 if (!($this->
getRequest()->getParam(
'isAjax') && count($postItems))) {
114 return $resultJson->setData([
115 'messages' => [
__(
'Please correct the data sent.')],
130 $this->getEmailNotification()->credentialsChanged($this->
getCustomer(), $currentCustomer->getEmail());
133 return $resultJson->setData([
148 $addressKeys = preg_grep(
149 '/^(' . AttributeRepository::BILLING_ADDRESS_PREFIX .
'\w+)/',
153 $result = array_intersect_key(
$data, array_flip($addressKeys));
154 if ($isCustomerData ===
null) {
156 if (strpos($key, AttributeRepository::BILLING_ADDRESS_PREFIX) !==
false) {
158 $result[str_replace(AttributeRepository::BILLING_ADDRESS_PREFIX,
'', $key)] =
$value;
175 $this->customerMapper->toFlatArray($customer),
178 $this->dataObjectHelper->populateWithArray(
181 \
Magento\Customer\Api\Data\CustomerInterface::class
191 protected function updateDefaultBilling(array
$data)
197 $this->dataObjectHelper->populateWithArray(
200 \
Magento\Customer\Api\Data\AddressInterface::class
216 $this->customerRepository->save(
$customer);
217 }
catch (\
Magento\Framework\Exception\InputException $e) {
219 $this->logger->critical($e);
222 $this->logger->critical($e);
223 }
catch (\Exception $e) {
225 $this->logger->critical($e);
237 foreach ([
'firstname',
'lastname'] as $requiredField) {
238 if (empty(
$data[$requiredField])) {
239 $data[$requiredField] = $this->
getCustomer()->{
'get' . ucfirst($requiredField)}();
254 $messages[] = $error->getText();
299 return '[Customer ID: ' . $this->getCustomer()->getId() .
'] ' .
__($errorText);
processAddressData(array $data)
setCustomer(CustomerInterface $customer)
updateCustomer(array $data)
__construct(Action\Context $context, CustomerRepositoryInterface $customerRepository, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Customer\Model\Customer\Mapper $customerMapper, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Psr\Log\LoggerInterface $logger)
saveCustomer(CustomerInterface $customer)
getData(array $data, $isCustomerData=null)
getErrorWithCustomerId($errorText)