@@ -49,7 +49,7 @@ public function __construct(
49
49
\Magento \Customer \Model \Session $ customerSession ,
50
50
\Magento \Store \Model \StoreManagerInterface $ storeManager
51
51
) {
52
-
52
+
53
53
$ this ->_helper = $ helper ;
54
54
$ this ->_customer = $ customer ;
55
55
$ this ->_customerSession = $ customerSession ;
@@ -64,9 +64,9 @@ public function __construct(
64
64
*/
65
65
public function beforeUnsubscribeCustomerById (
66
66
\Magento \Newsletter \Model \Subscriber $ subscriber ,
67
- $ customerId
67
+ $ customerId
68
68
) {
69
- $ storeId = $ this ->getStoreIdFromSubscriber ( $ subscriber );
69
+ $ storeId = $ this ->_storeManager -> getStore ()-> getId ( );
70
70
if ($ this ->_helper ->isMailChimpEnabled ($ storeId )) {
71
71
if (!$ this ->_helper ->getConfigValue (\Ebizmarts \MailChimp \Helper \Data::XML_MAGENTO_MAIL , $ storeId )) {
72
72
$ subscriber ->setImportMode (true );
@@ -99,10 +99,9 @@ public function beforeUnsubscribeCustomerById(
99
99
*/
100
100
public function beforeSubscribeCustomerById (
101
101
\Magento \Newsletter \Model \Subscriber $ subscriber ,
102
- $ customerId
102
+ $ customerId
103
103
) {
104
-
105
- $ storeId = $ this ->getStoreIdFromSubscriber ($ subscriber );
104
+ $ storeId = $ this ->_storeManager ->getStore ()->getId ();
106
105
if ($ this ->_helper ->isMailChimpEnabled ($ storeId )) {
107
106
$ subscriber ->loadByCustomerId ($ customerId );
108
107
if (!$ subscriber ->isSubscribed ()) {
@@ -152,15 +151,16 @@ public function beforeSubscribeCustomerById(
152
151
*/
153
152
public function beforeSubscribe (
154
153
\Magento \Newsletter \Model \Subscriber $ subscriber ,
155
- $ email
154
+ $ email
156
155
) {
157
-
158
- $ storeId = $ this ->getStoreIdFromSubscriber ($ subscriber );
156
+ $ storeId = $ this ->_storeManager ->getStore ()->getId ();
159
157
if ($ this ->_helper ->isMailChimpEnabled ($ storeId )) {
160
158
if (!$ this ->_helper ->getConfigValue (\Ebizmarts \MailChimp \Helper \Data::XML_MAGENTO_MAIL , $ storeId )) {
161
159
$ subscriber ->setImportMode (true );
162
160
}
163
- $ storeId = $ this ->_storeManager ->getStore ()->getId ();
161
+ if ($ this ->_customerSession ->getPhone ()) {
162
+ $ subscriber ->setPhone ($ this ->_customerSession ->getPhone ());
163
+ }
164
164
165
165
if ($ this ->_helper ->isMailChimpEnabled ($ storeId )) {
166
166
$ api = $ this ->_helper ->getApi ($ storeId );
@@ -201,7 +201,7 @@ public function beforeSubscribe(
201
201
public function beforeUnsubscribe (
202
202
\Magento \Newsletter \Model \Subscriber $ subscriber
203
203
) {
204
- $ storeId = $ this ->getStoreIdFromSubscriber ( $ subscriber );
204
+ $ storeId = $ this ->_storeManager -> getStore ()-> getId ( );
205
205
if ($ this ->_helper ->isMailChimpEnabled ($ storeId )) {
206
206
if (!$ this ->_helper ->getConfigValue (\Ebizmarts \MailChimp \Helper \Data::XML_MAGENTO_MAIL , $ storeId )) {
207
207
$ subscriber ->setImportMode (true );
@@ -228,8 +228,7 @@ public function beforeUnsubscribe(
228
228
public function afterDelete (
229
229
\Magento \Newsletter \Model \Subscriber $ subscriber
230
230
) {
231
-
232
- $ storeId = $ this ->getStoreIdFromSubscriber ($ subscriber );
231
+ $ storeId = $ this ->_storeManager ->getStore ()->getId ();
233
232
if ($ this ->_helper ->isMailChimpEnabled ($ storeId )) {
234
233
$ api = $ this ->_helper ->getApi ($ storeId );
235
234
if ($ subscriber ->isSubscribed ()) {
@@ -252,13 +251,4 @@ public function afterDelete(
252
251
}
253
252
return null ;
254
253
}
255
-
256
- /**
257
- * @param \Magento\Newsletter\Model\Subscriber $subscriber
258
- * @return int
259
- */
260
- protected function getStoreIdFromSubscriber (\Magento \Newsletter \Model \Subscriber $ subscriber )
261
- {
262
- return $ subscriber ->getStoreId ();
263
- }
264
254
}
0 commit comments