@@ -94,6 +94,12 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
94
94
*/
95
95
protected $ _customerSession ;
96
96
97
+ /**
98
+ * Date
99
+ * @var \Magento\Framework\Stdlib\DateTime\DateTime
100
+ */
101
+ private $ dateTime ;
102
+
97
103
/**
98
104
* Store manager
99
105
*
@@ -131,6 +137,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
131
137
* @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
132
138
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
133
139
* @param \Magento\Customer\Model\Session $customerSession
140
+ * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
134
141
* @param CustomerRepositoryInterface $customerRepository
135
142
* @param AccountManagementInterface $customerAccountManagement
136
143
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
@@ -147,6 +154,7 @@ public function __construct(
147
154
\Magento \Framework \Mail \Template \TransportBuilder $ transportBuilder ,
148
155
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
149
156
\Magento \Customer \Model \Session $ customerSession ,
157
+ \Magento \Framework \Stdlib \DateTime \DateTime $ dateTime ,
150
158
CustomerRepositoryInterface $ customerRepository ,
151
159
AccountManagementInterface $ customerAccountManagement ,
152
160
\Magento \Framework \Translate \Inline \StateInterface $ inlineTranslation ,
@@ -159,6 +167,7 @@ public function __construct(
159
167
$ this ->_transportBuilder = $ transportBuilder ;
160
168
$ this ->_storeManager = $ storeManager ;
161
169
$ this ->_customerSession = $ customerSession ;
170
+ $ this ->dateTime = $ dateTime ;
162
171
$ this ->customerRepository = $ customerRepository ;
163
172
$ this ->customerAccountManagement = $ customerAccountManagement ;
164
173
$ this ->inlineTranslation = $ inlineTranslation ;
@@ -806,4 +815,18 @@ public function getSubscriberFullName()
806
815
}
807
816
return $ name ;
808
817
}
818
+
819
+ /**
820
+ * Set date of last changed status
821
+ *
822
+ * @return $this
823
+ */
824
+ public function beforeSave ()
825
+ {
826
+ parent ::beforeSave ();
827
+ if ($ this ->dataHasChangedFor ('subscriber_status ' )) {
828
+ $ this ->setChangeStatusAt ($ this ->dateTime ->gmtDate ());
829
+ }
830
+ return $ this ;
831
+ }
809
832
}
0 commit comments