Skip to content

Commit f3d15ea

Browse files
authored
ENGCOM-5985: [Customer] Rename dob to date_of_birth #911 #919
2 parents 6f1a6f7 + 84870f6 commit f3d15ea

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

app/code/Magento/CustomerGraphQl/Model/Customer/ExtractCustomerData.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,16 @@ public function execute(CustomerInterface $customer): array
101101
}
102102
}
103103
$customerData = array_merge($customerData, $customAttributes);
104-
//Field is deprecated and should not be exposed on storefront.
104+
//Fields are deprecated and should not be exposed on storefront.
105105
$customerData['group_id'] = null;
106-
$customerData['model'] = $customer;
107106
$customerData['id'] = null;
108107

108+
$customerData['model'] = $customer;
109+
110+
//'dob' is deprecated, 'date_of_birth' is used instead.
111+
if (!empty($customerData['dob'])) {
112+
$customerData['date_of_birth'] = $customerData['dob'];
113+
}
109114
return $customerData;
110115
}
111116
}

app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ public function resolve(
7070
if (!$this->newsLetterConfig->isActive(ScopeInterface::SCOPE_STORE)) {
7171
$args['input']['is_subscribed'] = false;
7272
}
73-
73+
if (isset($args['input']['date_of_birth'])) {
74+
$args['input']['dob'] = $args['input']['date_of_birth'];
75+
}
7476
$customer = $this->createCustomerAccount->execute(
7577
$args['input'],
7678
$context->getExtensionAttributes()->getStore()

app/code/Magento/CustomerGraphQl/Model/Resolver/UpdateCustomer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public function resolve(
7070
if (empty($args['input']) || !is_array($args['input'])) {
7171
throw new GraphQlInputException(__('"input" value should be specified'));
7272
}
73+
if (isset($args['input']['date_of_birth'])) {
74+
$args['input']['dob'] = $args['input']['date_of_birth'];
75+
}
7376

7477
$customer = $this->getCustomer->execute($context);
7578
$this->updateCustomerAccount->execute(

app/code/Magento/CustomerGraphQl/etc/schema.graphqls

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ input CustomerInput {
6161
lastname: String @doc(description: "The customer's family name")
6262
suffix: String @doc(description: "A value such as Sr., Jr., or III")
6363
email: String @doc(description: "The customer's email address. Required")
64-
dob: String @doc(description: "The customer's date of birth")
64+
dob: String @doc(description: "Deprecated: Use `date_of_birth` instead")
65+
date_of_birth: String @doc(description: "The customer's date of birth")
6566
taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers)")
6667
gender: Int @doc(description: "The customer's gender(Male - 1, Female - 2)")
6768
password: String @doc(description: "The customer's password")
@@ -87,7 +88,8 @@ type Customer @doc(description: "Customer defines the customer name and address
8788
email: String @doc(description: "The customer's email address. Required")
8889
default_billing: String @doc(description: "The ID assigned to the billing address")
8990
default_shipping: String @doc(description: "The ID assigned to the shipping address")
90-
dob: String @doc(description: "The customer's date of birth")
91+
dob: String @doc(description: "The customer's date of birth") @deprecated(reason: "Use `date_of_birth` instead")
92+
date_of_birth: String @doc(description: "The customer's date of birth")
9193
taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers)")
9294
id: Int @doc(description: "The ID assigned to the customer") @deprecated(reason: "id is not needed as part of Customer because on server side it can be identified based on customer token used for authentication. There is no need to know customer ID on the client side.")
9395
is_subscribed: Boolean @doc(description: "Indicates whether the customer is subscribed to the company's newsletter") @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\IsSubscribed")

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testUpdateCustomer()
6969
middlename: "{$newMiddlename}"
7070
lastname: "{$newLastname}"
7171
suffix: "{$newSuffix}"
72-
dob: "{$newDob}"
72+
date_of_birth: "{$newDob}"
7373
taxvat: "{$newTaxVat}"
7474
email: "{$newEmail}"
7575
password: "{$currentPassword}"
@@ -82,7 +82,7 @@ public function testUpdateCustomer()
8282
middlename
8383
lastname
8484
suffix
85-
dob
85+
date_of_birth
8686
taxvat
8787
email
8888
gender
@@ -102,7 +102,7 @@ public function testUpdateCustomer()
102102
$this->assertEquals($newMiddlename, $response['updateCustomer']['customer']['middlename']);
103103
$this->assertEquals($newLastname, $response['updateCustomer']['customer']['lastname']);
104104
$this->assertEquals($newSuffix, $response['updateCustomer']['customer']['suffix']);
105-
$this->assertEquals($newDob, $response['updateCustomer']['customer']['dob']);
105+
$this->assertEquals($newDob, $response['updateCustomer']['customer']['date_of_birth']);
106106
$this->assertEquals($newTaxVat, $response['updateCustomer']['customer']['taxvat']);
107107
$this->assertEquals($newEmail, $response['updateCustomer']['customer']['email']);
108108
$this->assertEquals($newGender, $response['updateCustomer']['customer']['gender']);

0 commit comments

Comments
 (0)