1313use Magento \Framework \Api \DataObjectHelper ;
1414use Magento \Framework \Exception \LocalizedException ;
1515use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
16+ use Magento \Framework \Reflection \DataObjectProcessor ;
1617use Magento \Store \Model \StoreManagerInterface ;
1718
1819/**
@@ -50,6 +51,11 @@ class CreateCustomerAccount
5051 */
5152 private $ validateCustomerData ;
5253
54+ /**
55+ * @var DataObjectProcessor
56+ */
57+ private $ dataObjectProcessor ;
58+
5359 /**
5460 * CreateCustomerAccount constructor.
5561 *
@@ -58,6 +64,7 @@ class CreateCustomerAccount
5864 * @param StoreManagerInterface $storeManager
5965 * @param AccountManagementInterface $accountManagement
6066 * @param ChangeSubscriptionStatus $changeSubscriptionStatus
67+ * @param DataObjectProcessor $dataObjectProcessor
6168 * @param ValidateCustomerData $validateCustomerData
6269 */
6370 public function __construct (
@@ -66,6 +73,7 @@ public function __construct(
6673 StoreManagerInterface $ storeManager ,
6774 AccountManagementInterface $ accountManagement ,
6875 ChangeSubscriptionStatus $ changeSubscriptionStatus ,
76+ DataObjectProcessor $ dataObjectProcessor ,
6977 ValidateCustomerData $ validateCustomerData
7078 ) {
7179 $ this ->dataObjectHelper = $ dataObjectHelper ;
@@ -74,6 +82,7 @@ public function __construct(
7482 $ this ->storeManager = $ storeManager ;
7583 $ this ->changeSubscriptionStatus = $ changeSubscriptionStatus ;
7684 $ this ->validateCustomerData = $ validateCustomerData ;
85+ $ this ->dataObjectProcessor = $ dataObjectProcessor ;
7786 }
7887
7988 /**
@@ -106,8 +115,16 @@ public function execute(array $data): CustomerInterface
106115 */
107116 private function createAccount (array $ data ): CustomerInterface
108117 {
109- $ this ->validateCustomerData ->execute ($ data , true );
110118 $ customerDataObject = $ this ->customerFactory ->create ();
119+ /**
120+ * Add required attributes for customer entity
121+ */
122+ $ requiredDataAttributes = $ this ->dataObjectProcessor ->buildOutputDataArray (
123+ $ customerDataObject ,
124+ CustomerInterface::class
125+ );
126+ $ data = array_merge ($ requiredDataAttributes , $ data );
127+ $ this ->validateCustomerData ->execute ($ data );
111128 $ this ->dataObjectHelper ->populateWithArray (
112129 $ customerDataObject ,
113130 $ data ,
0 commit comments