Skip to content

Commit

Permalink
Merge pull request #23 from gustavorof/feature/serialized-config-issu…
Browse files Browse the repository at this point in the history
…e-22

BP-2694 Fix Serialized config issue
  • Loading branch information
LucianTuriacArnia authored Jun 29, 2023
2 parents 710ff03 + 96e2786 commit 4cdfcc6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
12 changes: 11 additions & 1 deletion Model/AnalyticsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,17 @@ public function get($analyticsId)
$analytics = $this->analyticsFactory->create();
$this->resource->load($analytics, $analyticsId);
if (!$analytics->getId()) {
throw new NoSuchEntityException(__('Analytics with id "%1" does not exist.', $analyticsId));
throw new NoSuchEntityException(__('Analytics data with id "%1" does not exist.', $analyticsId));
}
return $analytics->getDataModel();
}

public function getByQuoteId($quoteId)
{
$analytics = $this->analyticsFactory->create();
$this->resource->load($analytics, $quoteId, 'quote_id');
if (!$analytics->getId()) {
throw new NoSuchEntityException(__('Analytics data with quote_id "%1" does not exist.', $quoteId));
}
return $analytics->getDataModel();
}
Expand Down
10 changes: 9 additions & 1 deletion Model/ConfigProvider/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public function getCookieParamPairs(): array
ScopeInterface::SCOPE_STORES
);

return $configValue ? $this->serialize->unserialize($configValue) : [];
if (is_array($configValue)) {
return $configValue;
}

try {
return $this->serialize->unserialize($configValue);
} catch (\Exception $e) {
return [];
}
}
}
4 changes: 2 additions & 2 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<label>GA Tracking Options</label>
<field id="enable_ga_client_id_tracking" type="select" sortOrder="10" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<label>Enable GA Client ID tracking</label>
<comment/>
<label>Enable GA Client ID tracking</label>
<tooltip>More details on how to use the module can be found on our github repo: https://github.com/buckaroo-it/Magento2_Analytics</tooltip>
</field>
<field id="cookie_param_pair" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Cookie/Param pair</label>
Expand Down

0 comments on commit 4cdfcc6

Please sign in to comment.