File tree 5 files changed +35
-7
lines changed
app/code/Magento/Newsletter
dev/tests/integration/testsuite/Magento
Customer/Controller/Adminhtml
5 files changed +35
-7
lines changed Original file line number Diff line number Diff line change @@ -118,17 +118,37 @@ public function loadByEmail($subscriberEmail)
118
118
*/
119
119
public function loadByCustomerData (\Magento \Customer \Api \Data \CustomerInterface $ customer )
120
120
{
121
- $ select = $ this ->connection ->select ()->from ($ this ->getMainTable ())->where ('customer_id=:customer_id ' );
122
-
123
- $ result = $ this ->connection ->fetchRow ($ select , ['customer_id ' => $ customer ->getId ()]);
121
+ $ select = $ this ->connection
122
+ ->select ()
123
+ ->from ($ this ->getMainTable ())
124
+ ->where ('customer_id=:customer_id and store_id=:store_id ' );
125
+
126
+ $ result = $ this ->connection
127
+ ->fetchRow (
128
+ $ select ,
129
+ [
130
+ 'customer_id ' => $ customer ->getId (),
131
+ 'store_id ' => $ customer ->getStoreId ()
132
+ ]
133
+ );
124
134
125
135
if ($ result ) {
126
136
return $ result ;
127
137
}
128
138
129
- $ select = $ this ->connection ->select ()->from ($ this ->getMainTable ())->where ('subscriber_email=:subscriber_email ' );
130
-
131
- $ result = $ this ->connection ->fetchRow ($ select , ['subscriber_email ' => $ customer ->getEmail ()]);
139
+ $ select = $ this ->connection
140
+ ->select ()
141
+ ->from ($ this ->getMainTable ())
142
+ ->where ('subscriber_email=:subscriber_email and store_id=:store_id ' );
143
+
144
+ $ result = $ this ->connection
145
+ ->fetchRow (
146
+ $ select ,
147
+ [
148
+ 'subscriber_email ' => $ customer ->getEmail (),
149
+ 'store_id ' => $ customer ->getStoreId ()
150
+ ]
151
+ );
132
152
133
153
if ($ result ) {
134
154
return $ result ;
Original file line number Diff line number Diff line change @@ -349,6 +349,7 @@ public function loadByCustomerId($customerId)
349
349
{
350
350
try {
351
351
$ customerData = $ this ->customerRepository ->getById ($ customerId );
352
+ $ customerData ->setStoreId ($ this ->_storeManager ->getStore ()->getId ());
352
353
$ data = $ this ->getResource ()->loadByCustomerData ($ customerData );
353
354
$ this ->addData ($ data );
354
355
if (!empty ($ data ) && $ customerData ->getId () && !$ this ->getCustomerId ()) {
Original file line number Diff line number Diff line change @@ -187,6 +187,12 @@ public function testUpdateSubscription()
187
187
$ customerDataMock ->expects ($ this ->once ())->method ('getStoreId ' )->willReturn ('store_id ' );
188
188
$ customerDataMock ->expects ($ this ->once ())->method ('getEmail ' )->willReturn ('email ' );
189
189
190
+ $ storeModel = $ this ->getMockBuilder (\Magento \Store \Model \Store::class)
191
+ ->disableOriginalConstructor ()
192
+ ->setMethods (['getId ' ])
193
+ ->getMock ();
194
+ $ this ->storeManager ->expects ($ this ->any ())->method ('getStore ' )->willReturn ($ storeModel );
195
+
190
196
$ this ->assertEquals ($ this ->subscriber , $ this ->subscriber ->updateSubscription ($ customerId ));
191
197
}
192
198
Original file line number Diff line number Diff line change @@ -347,6 +347,7 @@ public function testSaveActionExistingCustomerUnsubscribeNewsletter()
347
347
348
348
'firstname ' => 'test firstname ' ,
349
349
'lastname ' => 'test lastname ' ,
350
+ 'sendemail_store_id ' => 1
350
351
],
351
352
'subscription ' => '0 '
352
353
];
Original file line number Diff line number Diff line change 28
28
29
29
$ subscriber = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()
30
30
->create (\Magento \Newsletter \Model \Subscriber::class);
31
- $ subscriber ->setStoreId ($ otherStore )
31
+ $ subscriber ->setStoreId ($ currentStore )
32
32
// Intentionally setting ID to 0 instead of 2 to test fallback mechanism in Subscriber model
33
33
->setCustomerId (0 )
34
34
->
setSubscriberEmail (
'[email protected] ' )
You can’t perform that action at this time.
0 commit comments