File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
app/code/Magento/CustomerGraphQl/Model/Resolver Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -64,16 +64,18 @@ public function __construct(
64
64
*
65
65
* @param array $address
66
66
* @param AddressInterface $addressObject
67
- * @return null
67
+ * @return array
68
68
*/
69
69
private function curateAddressDefaultValues (array $ address , AddressInterface $ addressObject ) : array
70
70
{
71
71
$ customerModel = $ this ->customerFactory ->create ();
72
72
$ this ->customerResourceModel ->load ($ customerModel , $ addressObject ->getCustomerId ());
73
73
$ address [CustomerInterface::DEFAULT_BILLING ] =
74
- ($ addressObject ->getId () == $ customerModel ->getDefaultBillingAddress ()->getId ()) ? true : false ;
74
+ ($ customerModel ->getDefaultBillingAddress ()
75
+ && $ addressObject ->getId () == $ customerModel ->getDefaultBillingAddress ()->getId ()) ? true : false ;
75
76
$ address [CustomerInterface::DEFAULT_SHIPPING ] =
76
- ($ addressObject ->getId () == $ customerModel ->getDefaultShippingAddress ()->getId ()) ? true : false ;
77
+ ($ customerModel ->getDefaultShippingAddress ()
78
+ && $ addressObject ->getId () == $ customerModel ->getDefaultShippingAddress ()->getId ()) ? true : false ;
77
79
return $ address ;
78
80
}
79
81
Original file line number Diff line number Diff line change @@ -67,6 +67,25 @@ public function getCustomerById(int $customerId) : array
67
67
return $ this ->processCustomer ($ customerObject );
68
68
}
69
69
70
+ /**
71
+ * Curate default shipping and default billing keys
72
+ *
73
+ * @param array $arrayAddress
74
+ * @return array
75
+ */
76
+ private function curateAddressData (array $ arrayAddress ) : array
77
+ {
78
+ foreach ($ arrayAddress as $ key => $ address ) {
79
+ if (!isset ($ address ['default_shipping ' ])) {
80
+ $ arrayAddress [$ key ]['default_shipping ' ] = false ;
81
+ }
82
+ if (!isset ($ address ['default_billing ' ])) {
83
+ $ arrayAddress [$ key ]['default_billing ' ] = false ;
84
+ }
85
+ }
86
+ return $ arrayAddress ;
87
+ }
88
+
70
89
/**
71
90
* Transform single customer data from object to in array format
72
91
*
@@ -80,6 +99,7 @@ private function processCustomer(CustomerInterface $customerObject) : array
80
99
CustomerRepositoryInterface::class,
81
100
'get '
82
101
);
102
+ $ customer ['addresses ' ] = $ this ->curateAddressData ($ customer ['addresses ' ]);
83
103
if (isset ($ customer ['extension_attributes ' ])) {
84
104
$ customer = array_merge ($ customer , $ customer ['extension_attributes ' ]);
85
105
}
You can’t perform that action at this time.
0 commit comments