@@ -132,28 +132,34 @@ public function loadByCustomerData(\Magento\Customer\Api\Data\CustomerInterface
132
132
{
133
133
$ storeIds = $ this ->storeManager ->getWebsite ($ customer ->getWebsiteId ())->getStoreIds ();
134
134
135
- $ select = $ this ->connection
136
- ->select ()
137
- ->from ($ this ->getMainTable ())
138
- ->where ('customer_id = ? ' , $ customer ->getId ())
139
- ->where ('store_id IN (?) ' , $ storeIds );
140
-
141
- $ result = $ this ->connection ->fetchRow ($ select );
142
-
143
- if ($ result ) {
144
- return $ result ;
135
+ if ($ customer ->getId ()) {
136
+ $ select = $ this ->connection
137
+ ->select ()
138
+ ->from ($ this ->getMainTable ())
139
+ ->where ('customer_id = ? ' , $ customer ->getId ())
140
+ ->where ('store_id IN (?) ' , $ storeIds )
141
+ ->limit (1 );
142
+
143
+ $ result = $ this ->connection ->fetchRow ($ select );
144
+
145
+ if ($ result ) {
146
+ return $ result ;
147
+ }
145
148
}
146
149
147
- $ select = $ this ->connection
148
- ->select ()
149
- ->from ($ this ->getMainTable ())
150
- ->where ('subscriber_email = ? ' , $ customer ->getEmail ())
151
- ->where ('store_id IN (?) ' , $ storeIds );
150
+ if ($ customer ->getEmail ()) {
151
+ $ select = $ this ->connection
152
+ ->select ()
153
+ ->from ($ this ->getMainTable ())
154
+ ->where ('subscriber_email = ? ' , $ customer ->getEmail ())
155
+ ->where ('store_id IN (?) ' , $ storeIds )
156
+ ->limit (1 );
152
157
153
- $ result = $ this ->connection ->fetchRow ($ select );
158
+ $ result = $ this ->connection ->fetchRow ($ select );
154
159
155
- if ($ result ) {
156
- return $ result ;
160
+ if ($ result ) {
161
+ return $ result ;
162
+ }
157
163
}
158
164
159
165
return [];
0 commit comments