@@ -555,24 +555,13 @@ protected function _updateCustomerSubscription($customerId, $subscribe)
555
555
}
556
556
557
557
$ sendInformationEmail = false ;
558
- $ status = self ::STATUS_SUBSCRIBED ;
559
- $ isConfirmNeed = $ this ->_scopeConfig ->getValue (
560
- self ::XML_PATH_CONFIRMATION_FLAG ,
561
- \Magento \Store \Model \ScopeInterface::SCOPE_STORE
562
- ) == 1 ? true : false ;
563
- if ($ subscribe ) {
564
- if (AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED
565
- == $ this ->customerAccountManagement ->getConfirmationStatus ($ customerId )
566
- ) {
567
- $ status = self ::STATUS_UNCONFIRMED ;
568
- } elseif ($ isConfirmNeed ) {
569
- $ status = self ::STATUS_NOT_ACTIVE ;
570
- }
571
- } elseif (($ this ->getStatus () == self ::STATUS_UNCONFIRMED ) && ($ customerData ->getConfirmation () === null )) {
572
- $ status = self ::STATUS_SUBSCRIBED ;
558
+ $ isConfirmNeed = 1 === (int )$ this ->_scopeConfig ->getValue (
559
+ self ::XML_PATH_CONFIRMATION_FLAG ,
560
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE
561
+ );
562
+ $ status = $ this ->getSubscriptionStatus ($ subscribe , $ isConfirmNeed , $ customerId );
563
+ if ($ status == self ::STATUS_SUBSCRIBED && $ customerData ->getConfirmation () === null ) {
573
564
$ sendInformationEmail = true ;
574
- } else {
575
- $ status = self ::STATUS_UNSUBSCRIBED ;
576
565
}
577
566
/**
578
567
* If subscription status has been changed then send email to the customer
@@ -619,6 +608,34 @@ protected function _updateCustomerSubscription($customerId, $subscribe)
619
608
return $ this ;
620
609
}
621
610
611
+ /**
612
+ * Get subscription status
613
+ *
614
+ * @param bool $subscribe
615
+ * @param bool $isConfirmNeed
616
+ * @param string $customerId
617
+ * @return int
618
+ */
619
+ private function getSubscriptionStatus ($ subscribe , $ isConfirmNeed , $ customerId )
620
+ {
621
+ $ status = self ::STATUS_SUBSCRIBED ;
622
+ if ($ subscribe ) {
623
+ if (AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED
624
+ == $ this ->customerAccountManagement ->getConfirmationStatus ($ customerId )
625
+ ) {
626
+ $ status = self ::STATUS_UNCONFIRMED ;
627
+ } elseif ($ isConfirmNeed ) {
628
+ $ status = self ::STATUS_NOT_ACTIVE ;
629
+ }
630
+ } elseif (($ this ->getStatus () == self ::STATUS_UNCONFIRMED )) {
631
+ $ status = self ::STATUS_SUBSCRIBED ;
632
+ } else {
633
+ $ status = self ::STATUS_UNSUBSCRIBED ;
634
+ }
635
+
636
+ return $ status ;
637
+ }
638
+
622
639
/**
623
640
* Confirms subscriber newsletter
624
641
*
0 commit comments