diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/UpdateCustomerAccount.php b/app/code/Magento/CustomerGraphQl/Model/Customer/UpdateCustomerAccount.php index 59353fb713af0..5b3eaaf92bb42 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/UpdateCustomerAccount.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/UpdateCustomerAccount.php @@ -7,9 +7,11 @@ namespace Magento\CustomerGraphQl\Model\Customer; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\GraphQl\Exception\GraphQlAlreadyExistsException; use Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException; use Magento\Framework\GraphQl\Exception\GraphQlInputException; +use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; use Magento\Store\Model\StoreManagerInterface; use Magento\Customer\Api\Data\CustomerInterface; use Magento\Framework\Api\DataObjectHelper; @@ -89,8 +91,7 @@ public function __construct( * @throws GraphQlAlreadyExistsException * @throws GraphQlAuthenticationException * @throws GraphQlInputException - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException + * @throws GraphQlNoSuchEntityException */ public function execute(CustomerInterface $customer, array $data): void { @@ -106,7 +107,12 @@ public function execute(CustomerInterface $customer, array $data): void $filteredData = array_diff_key($data, array_flip($this->restrictedKeys)); $this->dataObjectHelper->populateWithArray($customer, $filteredData, CustomerInterface::class); - $customer->setStoreId($this->storeManager->getStore()->getId()); + try { + $customer->setStoreId($this->storeManager->getStore()->getId()); + } catch (NoSuchEntityException $exception) { + throw new GraphQlNoSuchEntityException(__($exception->getMessage()), $exception); + } + $this->saveCustomer->execute($customer); diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/ValidateCustomerData.php b/app/code/Magento/CustomerGraphQl/Model/Customer/ValidateCustomerData.php index b9cf243374057..1e4b653c13de3 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/ValidateCustomerData.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/ValidateCustomerData.php @@ -47,7 +47,7 @@ public function execute(array $customerData, $addRequiredAttributes = false): vo $errorInput = []; foreach ($attributes as $attributeInfo) { - if ($attributeInfo->getIsRequired() && empty($customerData[$attributeInfo->getAttributeCode()])) { + if ($attributeInfo->getIsRequired() && $customerData[$attributeInfo->getAttributeCode()] == '') { $errorInput[] = $attributeInfo->getDefaultFrontendLabel(); } }