Skip to content

Commit

Permalink
- ignore Subscriber events when status was not changed
Browse files Browse the repository at this point in the history
- use customer id from subscriber entity instead of session
  • Loading branch information
bnayalivne committed Feb 5, 2018
1 parent 8f3025d commit fbcf45f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Observer/TriggerSubscribeUpdateObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public function execute(\Magento\Framework\Event\Observer $observer){
*/
$subscriber = $observer->getEvent()->getSubscriber();

if(!$subscriber->isStatusChanged()) {
return $this;
}

if(!$this->_coreRegistry->registry('subscriber_object_data_observer'))
$this->_coreRegistry->register('subscriber_object_data_observer', 1);

Expand All @@ -100,11 +104,7 @@ public function execute(\Magento\Framework\Event\Observer $observer){
return $this;
}

$customerId = $this->session->getCustomerId();
if(empty($customerId)){
$customerId = $this->_coreRegistry->registry('remarkety_customer_id');
}
$data = $this->_prepareCustomerSubscribtionUpdateData($subscriber, $this->remoteAddress->getRemoteAddress(), $customerId);
$data = $this->_prepareCustomerSubscribtionUpdateData($subscriber, $this->remoteAddress->getRemoteAddress());
$this->makeRequest($eventType, $data, $subscriber->getStoreId());

if($this->_store->getId() != 0){
Expand Down

0 comments on commit fbcf45f

Please sign in to comment.