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 faff3a9 commit dd09e20
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions app/code/community/Ebizmarts/MailChimp/Model/ProcessWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ function processWebhookData():void {
if ($data) {
switch ($webhookRequest->getType()) {
case 'subscribe':
$this->_subscribe($data);
try {
$this->getMailchimpTagsModel()->processMergeFields($data, true);
} catch (Exception $e) {
Mage::logException($e);
}
break;
case 'unsubscribe':
$this->_unsubscribe($data);
Expand All @@ -54,7 +58,7 @@ function processWebhookData():void {
$this->_updateEmail($data);
break;
case 'profile':
$this->_profile($data);
$this->getMailchimpTagsModel()->processMergeFields($data);
}
}

Expand Down Expand Up @@ -90,33 +94,11 @@ private function _clean(array $data):void {
*/
private function getMailchimpTagsModel():Tags {return $this->_tags;}

/**
* 2024-05-02 Dmitrii Fediuk https://upwork.com/fl/mage2pro
* "Refactor `Ebizmarts_MailChimp_Model_ProcessWebhook`": https://github.com/cabinetsbay/site/issues/590
* @used-by self::processWebhookData()
* @throws Mage_Core_Exception
*/
private function _profile(array $d):void {$this->getMailchimpTagsModel()->processMergeFields($d);}

/**
* @param $webhookRequest
*/
private function _saveProcessedWebhook($webhookRequest):void {$webhookRequest->setProcessed(1)->save();}

/**
* Subscribe email to Magento list, store aware
*
* @param array $data
* @return void
*/
private function _subscribe(array $data):void {
try {
$this->getMailchimpTagsModel()->processMergeFields($data, true);
} catch (Exception $e) {
Mage::logException($e);
}
}

/**
* Update customer email <upemail>
*
Expand Down

0 comments on commit dd09e20

Please sign in to comment.