File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed
app/code/Magento/Customer
Controller/Adminhtml/Index Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -154,23 +154,25 @@ public function initForm()
154
154
[
155
155
'label ' => __ ('Subscribed to Newsletter ' ),
156
156
'name ' => 'subscription ' ,
157
- 'data-form-part ' => $ this ->getData ('target_form ' )
157
+ 'data-form-part ' => $ this ->getData ('target_form ' ),
158
+ 'onchange ' => 'this.value = this.checked; '
158
159
]
159
160
);
160
161
161
162
if ($ this ->customerAccountManagement ->isReadOnly ($ customerId )) {
162
163
$ form ->getElement ('subscription ' )->setReadonly (true , true );
163
164
}
164
-
165
- $ form ->getElement ('subscription ' )->setIsChecked ($ subscriber ->isSubscribed ());
165
+ $ isSubscribed = $ subscriber ->isSubscribed ();
166
+ $ form ->setValues (['subscription ' => $ isSubscribed ? 'true ' : 'false ' ]);
167
+ $ form ->getElement ('subscription ' )->setIsChecked ($ isSubscribed );
166
168
167
169
$ changedDate = $ this ->getStatusChangedDate ();
168
170
if ($ changedDate ) {
169
171
$ fieldset ->addField (
170
172
'change_status_date ' ,
171
173
'label ' ,
172
174
[
173
- 'label ' => $ subscriber -> isSubscribed () ? __ ('Last Date Subscribed ' ) : __ ('Last Date Unsubscribed ' ),
175
+ 'label ' => $ isSubscribed ? __ ('Last Date Subscribed ' ) : __ ('Last Date Unsubscribed ' ),
174
176
'value ' => $ changedDate ,
175
177
'bold ' => true
176
178
]
Original file line number Diff line number Diff line change @@ -236,14 +236,16 @@ public function execute()
236
236
$ customerId = $ customer ->getId ();
237
237
}
238
238
239
- $ isSubscribed = false ;
239
+ $ isSubscribed = null ;
240
240
if ($ this ->_authorization ->isAllowed (null )) {
241
- $ isSubscribed = $ this ->getRequest ()->getPost ('subscription ' ) !== null ;
241
+ $ isSubscribed = $ this ->getRequest ()->getPost ('subscription ' );
242
242
}
243
- if ($ isSubscribed ) {
244
- $ this ->_subscriberFactory ->create ()->subscribeCustomerById ($ customerId );
245
- } else {
246
- $ this ->_subscriberFactory ->create ()->unsubscribeCustomerById ($ customerId );
243
+ if ($ isSubscribed !== null ) {
244
+ if ($ isSubscribed !== 'false ' ) {
245
+ $ this ->_subscriberFactory ->create ()->subscribeCustomerById ($ customerId );
246
+ } else {
247
+ $ this ->_subscriberFactory ->create ()->unsubscribeCustomerById ($ customerId );
248
+ }
247
249
}
248
250
249
251
// After save
You can’t perform that action at this time.
0 commit comments