Skip to content

Commit

Permalink
close #473
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Nov 15, 2018
1 parent c52c5ae commit 645a10d
Showing 1 changed file with 39 additions and 28 deletions.
67 changes: 39 additions & 28 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,17 +354,21 @@ public function getMapFields($storeId = null)
if (!$this->_mapFields) {
$customerAtt = $this->getCustomerAtts();
$data = $this->getConfigValue(self::XML_MERGEVARS, $storeId);
$data = $this->unserialize($data);
if (is_array($data)) {
foreach ($data as $customerFieldId => $mailchimpName) {
$this->_mapFields[] = [
'mailchimp' => strtoupper($mailchimpName),
'customer_field' => $customerAtt[$customerFieldId]['attCode'],
'isDate' => $customerAtt[$customerFieldId]['isDate'],
'isAddress' => $customerAtt[$customerFieldId]['isAddress'],
'options' => $customerAtt[$customerFieldId]['options']
];
try {
$data = $this->unserialize($data);

This comment has been minimized.

if (is_array($data)) {
foreach ($data as $customerFieldId => $mailchimpName) {
$this->_mapFields[] = [
'mailchimp' => strtoupper($mailchimpName),
'customer_field' => $customerAtt[$customerFieldId]['attCode'],
'isDate' => $customerAtt[$customerFieldId]['isDate'],
'isAddress' => $customerAtt[$customerFieldId]['isAddress'],
'options' => $customerAtt[$customerFieldId]['options']
];
}
}
} catch(\Exception $e) {
$this->log($e->getMessage());
}
}
return $this->_mapFields;
Expand Down Expand Up @@ -1025,30 +1029,37 @@ public function getSubscriberInterest($subscriberId, $storeId, $interest = null)

$interestGroup = $this->_interestGroupFactory->create();
$interestGroup->getBySubscriberIdStoreId($subscriberId, $storeId);
$groups = $this->unserialize($interestGroup->getGroupdata());
if (isset($groups['group'])) {
foreach ($groups['group'] as $key => $value) {
if (isset($interest[$key])) {
if (is_array($value)) {
foreach ($value as $groupId) {
foreach ($interest[$key]['category'] as $gkey => $gvalue) {
if ($gvalue['id'] == $groupId) {
$interest[$key]['category'][$gkey]['checked'] = true;
} elseif (!isset($interest[$key]['category'][$gkey]['checked'])) {
$interest[$key]['category'][$gkey]['checked'] = false;
$serialized = $interestGroup->getGroupdata();
if($serialized) {
try {
$groups = $this->unserialize($serialized);

This comment has been minimized.

if (isset($groups['group'])) {
foreach ($groups['group'] as $key => $value) {
if (isset($interest[$key])) {
if (is_array($value)) {
foreach ($value as $groupId) {
foreach ($interest[$key]['category'] as $gkey => $gvalue) {
if ($gvalue['id'] == $groupId) {
$interest[$key]['category'][$gkey]['checked'] = true;
} elseif (!isset($interest[$key]['category'][$gkey]['checked'])) {
$interest[$key]['category'][$gkey]['checked'] = false;
}
}
}
}
}
} else {
foreach ($interest[$key]['category'] as $gkey => $gvalue) {
if ($gvalue['id'] == $value) {
$interest[$key]['category'][$gkey]['checked'] = true;
} else {
$interest[$key]['category'][$gkey]['checked'] = false;
foreach ($interest[$key]['category'] as $gkey => $gvalue) {
if ($gvalue['id'] == $value) {
$interest[$key]['category'][$gkey]['checked'] = true;
} else {
$interest[$key]['category'][$gkey]['checked'] = false;
}
}
}
}
}
}
} catch(\Exception $e) {
$this->log($e->getMessage());
}
}
return $interest;
Expand Down

0 comments on commit 645a10d

Please sign in to comment.