diff --git a/web/typo3conf/ext/ep_products/ext_localconf.php b/web/typo3conf/ext/ep_products/ext_localconf.php
index b7632434..a9bff748 100644
--- a/web/typo3conf/ext/ep_products/ext_localconf.php
+++ b/web/typo3conf/ext/ep_products/ext_localconf.php
@@ -350,6 +350,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php'][
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'gclid';
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'ref';
+$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'pa';
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'tx_epproducts_searchresult[searchParams]';
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'tx_epproducts_searchresult[filterSettings]';
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'tx_epproducts_product_detail[filterSettings]';
diff --git a/web/typo3conf/ext/ep_theme/Classes/DataProcessing/ContextProcessor.php b/web/typo3conf/ext/ep_theme/Classes/DataProcessing/ContextProcessor.php
index 77f18431..98e7cd12 100644
--- a/web/typo3conf/ext/ep_theme/Classes/DataProcessing/ContextProcessor.php
+++ b/web/typo3conf/ext/ep_theme/Classes/DataProcessing/ContextProcessor.php
@@ -27,7 +27,10 @@ namespace EP\EpTheme\DataProcessing;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
+use EP\EpProducts\Service\ResellerDataService;
use EP\EpProducts\Traits\DbConnectionTrait;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
@@ -59,9 +62,69 @@ class ContextProcessor implements DataProcessorInterface
if ($regionUid > 0) {
$processedData['context']['region'] = $this->getContextRecord($regionUid, 'tx_epproducts_domain_model_region');
}
+ $resellerData = $this->getResellerData();
+ if ($resellerData) {
+ $processedData['context']['paCode'] = $resellerData['paCode'];
+ } elseif ($paCode = $this->getPaCodeFromRequest()) {
+ $processedData['context']['paCode'] = $paCode;
+ } elseif ($cookieData = $this->getCookieData()) {
+ $processedData['context']['paCode'] = $cookieData;
+ }
+
return $processedData;
}
+ /**
+ * @return array|bool
+ * @throws \Doctrine\DBAL\DBALException
+ */
+ private function getResellerData()
+ {
+ /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
+ $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
+ /** @var ResellerDataService $resellerService */
+ $resellerService = $objectManager->get(ResellerDataService::class);
+ return $resellerService->getResellerForCurrentDomain();
+ }
+
+ /**
+ * @return string
+ */
+ private function getPaCodeFromRequest()
+ {
+ $currentUri = GeneralUtility::getIndpEnv('REQUEST_URI');
+ $query = parse_url($currentUri, \PHP_URL_QUERY);
+
+ if (!$query) {
+ return '';
+ }
+
+ parse_str($query, $items);
+
+ if (array_key_exists('pa', $items)) {
+ $paCode = $items['pa'];
+ $expiratonDate = new \DateTime('now');
+ $expiratonDate->add(new \DateInterval('P' . '30D'));
+ setcookie('ep_trk', $paCode, $expiratonDate->getTimestamp(), '/');
+
+ return $paCode;
+ }
+
+ return '';
+ }
+
+ /**
+ * @return string
+ */
+ private function getCookieData()
+ {
+ if ($_COOKIE['ep_trk']) {
+ return $_COOKIE['ep_trk'];
+ }
+
+ return '';
+ }
+
/**
* @param int $uid
* @param string $table
diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js
index ca474cd3..31391dc0 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js
@@ -69,6 +69,7 @@ new Vue({
},
data () {
return {
+ config: {},
maxWindowWidth: 991,
lastScrollPosition: 0,
scrollTopVisible: false,
@@ -86,6 +87,10 @@ new Vue({
}
},
methods: {
+ parseConfig () {
+ const configElement = document.getElementById('appconfig');
+ this.config = JSON.parse(configElement.innerHTML);
+ },
setMobileMode () {
this.mobileMode = $window.outerWidth() < this.maxWindowWidth;
},
@@ -343,9 +348,31 @@ new Vue({
.on('affixed-top.bs.affix', () => {
this.searchbarFixed = false;
});
+ },
+ appendPaCode () {
+ const paCode = this.config.paCode;
+ if (!paCode) {
+ return;
+ }
+ $('a').each(function () {
+ if (this.hostname === location.hostname) {
+ return;
+ }
+ let url = $(this).attr('href');
+ if (!url) {
+ return;
+ }
+ if (url.indexOf('pa=') !== -1) {
+ return;
+ }
+ const separator = url.indexOf('?') === -1 ? '?' : '&';
+ url += separator + 'pa=' + paCode;
+ $(this).attr('href', url);
+ });
}
},
created () {
+ this.parseConfig();
EventBus.$on('ajaxContentLoaded', () => {
Vue.nextTick(() => {
this.initContentsliders();
@@ -398,6 +425,7 @@ new Vue({
this.initDropdownMenuBehavior();
this.initPartnerIdSelect();
this.initFaqFilter();
+ this.appendPaCode();
});
}
});
diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Detail.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Detail.html
index 7e9c1ec6..2b9b3cb2 100644
--- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Detail.html
+++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Detail.html
@@ -19,4 +19,5 @@
+