Skip to content

Commit

Permalink
https://github.com/thehcginstitute-com/m1/issues/590
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed May 2, 2024
1 parent d72055d commit b1cc81a
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,22 @@ function getSubscriber():Sub {return $this->_subscriber;}
* @param bool $subscribe
* @throws Mage_Core_Exception
*/
function processMergeFields($data, $subscribe = false):void
{
function processMergeFields($data, $subscribe = false):void {
$helper = $this->getMailchimpHelper();
$email = $data['email'];
$listId = $data['list_id'];

$STATUS_SUBSCRIBED = Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED;
$storeId = $helper->getMagentoStoreIdsByListId($listId)[0];

$this->_mailChimpTags = $helper->getMapFields($storeId);
$this->_mailChimpTags = $this->unserializeMapFields($this->_mailChimpTags);

$customer = $helper->loadListCustomer($listId, $email);

if ($customer) {
$this->setCustomer($customer);
$this->_setMailchimpTagsToCustomer($data);
}

$subscriber = $helper->loadListSubscriber($listId, $email);
$fname = $this->_getFName($data);
$lname = $this->_getLName($data);

if ($subscriber->getId()) {
if ($subscriber->getStatus() != $STATUS_SUBSCRIBED && $subscribe) {
$subscriber->setStatus($STATUS_SUBSCRIBED);
Expand All @@ -159,19 +152,16 @@ function processMergeFields($data, $subscribe = false):void
$this->_addSubscriberData($subscriber, $fname, $lname, $email, $listId);
}
}

$subscriber->save();
$this->setSubscriber($subscriber);

if (isset($data['merges']['GROUPINGS'])) {
$interestGroupHandle = $this->_getInterestGroupHandleModel();

if ($this->getSubscriber() === null) {
$interestGroupHandle->setCustomer($this->getCustomer());
} else {
}
else {
$interestGroupHandle->setSubscriber($this->getSubscriber());
}

$interestGroupHandle->setGroupings($data['merges']['GROUPINGS'])
->setListId($listId)
->processGroupsData();
Expand Down

0 comments on commit b1cc81a

Please sign in to comment.