diff --git a/.gitattributes b/.gitattributes index fd1abc1..5fab7a4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -179,6 +179,8 @@ copy_this/modules/d3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics copy_this/modules/d3/d3_googleanalytics/core/smarty/plugins/function.d3getArticleFromOrderArticle.php -text copy_this/modules/d3/d3_googleanalytics/menu.xml -text copy_this/modules/d3/d3_googleanalytics/metadata.php -text +copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php -text +copy_this/modules/d3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php -text copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php -text copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_order_googleanalytics.php -text copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_thankyou_googleanalytics.php -text diff --git a/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl b/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl index 8909f5a..db12d4b 100644 --- a/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl +++ b/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl @@ -7,7 +7,7 @@ gts.push(["badge_position", "BOTTOM_RIGHT"]); gts.push(["locale", "[{$sD3CurrentGTSLang}]"]); [{if $oD3GASettings->getValue('sD3GATSShoppingActive')}] -[{*gts.push(["google_base_offer_id", ""]);*}] + gts.push(["google_base_offer_id", "[{$sD3GATSProdId}]"]); gts.push(["google_base_subaccount_id", "[{$oD3GASettings->getValue('sD3GATSShoppingAccountId')}]"]); gts.push(["google_base_country", "[{$oD3GASettings->getValue('sD3GATSShoppingCountry')|upper}]"]); gts.push(["google_base_language", "[{$oD3GASettings->getValue('sD3GATSShoppingLanguage')|lower}]"]); diff --git a/copy_this/modules/d3/d3_googleanalytics/metadata.php b/copy_this/modules/d3/d3_googleanalytics/metadata.php index 625a023..999948a 100644 --- a/copy_this/modules/d3/d3_googleanalytics/metadata.php +++ b/copy_this/modules/d3/d3_googleanalytics/metadata.php @@ -67,6 +67,10 @@ $aModule = array( 'd3_cfg_googleanalyticslog_list' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalyticslog_list.php', 'd3_googleanalytics_update' => 'd3/d3_googleanalytics/setup/d3_googleanalytics_update.php', + 'd3_google_remarketing_articlelister' => + 'd3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php', + 'd3_google_trustedstore_articlelister' => + 'd3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php', ), 'templates' => array( 'd3_googleanalytics.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/d3_googleanalytics.tpl', diff --git a/copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php new file mode 100644 index 0000000..09ad536 --- /dev/null +++ b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php @@ -0,0 +1,160 @@ + + * @link http://www.oxidmodule.com + */ + +class d3_google_remarketing_articlelister +{ + public $sD3GARemarketingSKUField = 'oxartnum'; + + public $blD3GARemarketingUseBrutto = true; + + /** + * @param details $oView + * + * @return array + */ + public function getDetailsProdList($oView) + { + $aArticleList = array(); + $aArticleList[] = $oView->getProduct(); + return $this->_getProductList($aArticleList); + } + + /** + * @param alist $oView + * + * @return array + */ + public function getAlistProdList($oView) + { + $oArticleList = $oView->getArticleList(); + return $this->_getProductList($oArticleList); + } + + /** + * @param search $oView + * + * @return array + */ + public function getSearchProdList($oView) + { + $oArticleList = $oView->getArticleList(); + return $this->_getProductList($oArticleList); + } + + /** + * @param vendorlist $oView + * + * @return array + */ + public function getVendorlistProdList($oView) + { + $oArticleList = $oView->getArticleList(); + return $this->_getProductList($oArticleList); + } + + /** + * @param manufacturerlist $oView + * + * @return array + */ + public function getManufacturerlistProdList($oView) + { + $oArticleList = $oView->getArticleList(); + return $this->_getProductList($oArticleList); + } + + /** + * @param basket $oView + * + * @return array + */ + public function getBasketProdList($oView) + { + $aArticleList = $oView->getBasketArticles(); + return $this->_getProductList($aArticleList); + } + + /** + * @param order $oView + * + * @return array + */ + public function getOrderProdList($oView) + { + $aArticleList = $oView->getBasketArticles(); + return $this->_getProductList($aArticleList); + } + + /** + * @param compare $oView + * + * @return array + */ + public function getCompareProdList($oView) + { + $aArticleList = $oView->getCompArtList(); + return $this->_getProductList($aArticleList); + } + + /** + * don't change method name, it was dynamically generated + * @param account_noticelist $oView + * + * @return array + */ + public function getAccount_noticelistProdList($oView) + { + $aArticleList = $oView->getNoticeProductList(); + return $this->_getProductList($aArticleList); + } + + /** + * don't change method name, it was dynamically generated + * @param account_wishlist $oView + * + * @return array + */ + public function getAccount_wishlistProdList($oView) + { + $aArticleList = $oView->getWishProductList(); + return $this->_getProductList($aArticleList); + } + + /** + * @param $aArticleList + * + * @return array + */ + protected function _getProductList($aArticleList) + { + $aArticleIds = array(); + $dPrice = 0; + + /** @var oxarticle $oArticle */ + if (isset($aArticleList)) { + foreach ($aArticleList as $oArticle) { + $aArticleIds[] = $oArticle->getFieldData($this->sD3GARemarketingSKUField); + if ($this->blD3GARemarketingUseBrutto) { + $dPrice += $oArticle->getPrice()->getBruttoPrice(); + } else { + $dPrice += $oArticle->getPrice()->getNettoPrice(); + } + } + } + + return array('aArtIdList' => $aArticleIds, 'dPrice' => $dPrice); + } +} diff --git a/copy_this/modules/d3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php new file mode 100644 index 0000000..65b8b62 --- /dev/null +++ b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_trustedstore_articlelister.php @@ -0,0 +1,132 @@ + + * @link http://www.oxidmodule.com + */ + +class d3_google_trustedstore_articlelister +{ + private $_sModId = 'd3_googleanalytics'; + + /** + * @param details $oView + * + * @return array + */ + public function getDetailsProdList($oView) + { + $aArticleList = array(); + $aArticleList[] = $oView->getProduct(); + return $this->_getProductList($aArticleList); + } + + /** + * @param alist $oView + * + * @return array + */ + public function getAlistProdList($oView) + { + $oArticleList = $oView->getArticleList(); + return $this->_getProductList($oArticleList); + } + + /** + * @param search $oView + * + * @return array + */ + public function getSearchProdList($oView) + { + $oArticleList = $oView->getArticleList(); + return $this->_getProductList($oArticleList); + } + + /** + * @param vendorlist $oView + * + * @return array + */ + public function getVendorlistProdList($oView) + { + $oArticleList = $oView->getArticleList(); + return $this->_getProductList($oArticleList); + } + + /** + * @param manufacturerlist $oView + * + * @return array + */ + public function getManufacturerlistProdList($oView) + { + $oArticleList = $oView->getArticleList(); + return $this->_getProductList($oArticleList); + } + + /** + * @param compare $oView + * + * @return array + */ + public function getCompareProdList($oView) + { + $aArticleList = $oView->getCompArtList(); + return $this->_getProductList($aArticleList); + } + + /** + * don't change method name, it was dynamically generated + * @param account_noticelist $oView + * + * @return array + */ + public function getAccount_noticelistProdList($oView) + { + $aArticleList = $oView->getNoticeProductList(); + return $this->_getProductList($aArticleList); + } + + /** + * don't change method name, it was dynamically generated + * @param account_wishlist $oView + * + * @return array + */ + public function getAccount_wishlistProdList($oView) + { + $aArticleList = $oView->getWishProductList(); + return $this->_getProductList($aArticleList); + } + + /** + * @param $aArticleList + * + * @return array + */ + protected function _getProductList($aArticleList) + { + $aArticleIds = array(); + + /** @var oxarticle $oArticle */ + if (isset($aArticleList)) { + foreach ($aArticleList as $oArticle) { + $aArticleIds[] = $oArticle->getFieldData( + d3_cfg_mod::get($this->_sModId)->getValue('sD3GATSShoppingArtId') + ); + } + } + + return array('aArtIdList' => $aArticleIds); + } +} diff --git a/copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php b/copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php index 6a8059f..3ae7db2 100644 --- a/copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php +++ b/copy_this/modules/d3/d3_googleanalytics/modules/components/d3_oxcmp_utils_googleanalytics.php @@ -33,9 +33,6 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare 'order' => 'purchase', ); - public $sD3GARemarketingSKUField = 'oxartnum'; - public $blD3GARemarketingUseBrutto = true; - /** * @return null */ @@ -55,7 +52,12 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare $oParentView->addTplParam('sAFEGetMoreUrls', $this->afGetMoreUrls()); $oParentView->addTplParam('sD3GASendPageViewParameter', $this->d3getSendPageViewParameters()); $oParentView->addTplParam('sD3CurrentShopUrl', $this->d3GetCreateCurrentShopUrl()); - $oParentView->addTplParam('sD3CurrentGTSLang', $this->d3GetGTSLang()); + + if ($oSet->getValue('sD3GATSActive') && $oSet->getValue('sD3GATSShoppingActive')) { + $aInfos = $this->d3GATSGetProdInfos(); + $oParentView->addTplParam('sD3CurrentGTSLang', $this->d3GetGTSLang()); + $oParentView->addTplParam('sD3GATSProdId', $this->d3GATSGetProdIdList($aInfos['aArtIdList'])); + } if ($oSet->getValue('blD3GASetRemarketing')) { $aInfos = $this->d3GetGAProdInfos(); @@ -299,6 +301,45 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare strtoupper($oCountry->getFieldData('OXISOALPHA2')); } + /** + * @return array + */ + public function d3GATSGetProdInfos() + { + startProfile(__METHOD__); + + $oCurrentView = oxRegistry::getConfig()->getActiveView(); + + $aArticleIds = array(); + + $sMethodName = 'get'.ucfirst($oCurrentView->getClassName())."ProdList"; + $oArticleLister = oxNew('d3_google_trustedstore_articlelister'); + + if (method_exists($oArticleLister, $sMethodName)) { + stopProfile(__METHOD__); + return call_user_func(array($oArticleLister, $sMethodName), $oCurrentView); + } + + stopProfile(__METHOD__); + + return array('aArtIdList' => $aArticleIds); + } + + + /** + * @param array $aArticleIds + * + * @return string + */ + public function d3GATSGetProdIdList($aArticleIds) + { + if (count($aArticleIds)) { + return $aArticleIds[array_keys($aArticleIds)[0]]; + } else { + return ""; + } + } + /** * @return string */ @@ -311,11 +352,12 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare $aArticleIds = array(); $dPrice = 0; - $sMethodName = '_d3GetGA'.$oCurrentView->getClassName()."ProdList"; + $sMethodName = 'get'.ucfirst($oCurrentView->getClassName())."ProdList"; + $oArticleLister = oxNew('d3_google_remarketing_articlelister'); - if (method_exists($this, $sMethodName)) { + if (method_exists($oArticleLister, $sMethodName)) { stopProfile(__METHOD__); - return call_user_func(array($this, $sMethodName), $oCurrentView); + return call_user_func(array($oArticleLister, $sMethodName), $oCurrentView); } stopProfile(__METHOD__); @@ -337,144 +379,6 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare } } - /** - * @param details $oView - * - * @return array - */ - protected function _d3GetGAdetailsProdList($oView) - { - $aArticleList = array(); - $aArticleList[] = $oView->getProduct(); - return $this->_d3GetGAProductList($aArticleList); - } - - /** - * @param alist $oView - * - * @return array - */ - protected function _d3GetGAalistProdList($oView) - { - $oArticleList = $oView->getArticleList(); - return $this->_d3GetGAProductList($oArticleList); - } - - /** - * @param search $oView - * - * @return array - */ - protected function _d3GetGAsearchProdList($oView) - { - $oArticleList = $oView->getArticleList(); - return $this->_d3GetGAProductList($oArticleList); - } - - /** - * @param vendorlist $oView - * - * @return array - */ - protected function _d3GetGAvendorlistProdList($oView) - { - $oArticleList = $oView->getArticleList(); - return $this->_d3GetGAProductList($oArticleList); - } - - /** - * @param manufacturerlist $oView - * - * @return array - */ - protected function _d3GetGAmanufacturerlistProdList($oView) - { - $oArticleList = $oView->getArticleList(); - return $this->_d3GetGAProductList($oArticleList); - } - - /** - * @param basket $oView - * - * @return array - */ - protected function _d3GetGAbasketProdList($oView) - { - $aArticleList = $oView->getBasketArticles(); - return $this->_d3GetGAProductList($aArticleList); - } - - /** - * @param order $oView - * - * @return array - */ - protected function _d3GetGAorderProdList($oView) - { - $aArticleList = $oView->getBasketArticles(); - return $this->_d3GetGAProductList($aArticleList); - } - - /** - * @param compare $oView - * - * @return array - */ - protected function _d3GetGAcompareProdList($oView) - { - $aArticleList = $oView->getCompArtList(); - return $this->_d3GetGAProductList($aArticleList); - } - - /** - * don't change method name, it was dynamically generated - * @param account_noticelist $oView - * - * @return array - */ - protected function _d3GetGAaccount_noticelistProdList($oView) - { - $aArticleList = $oView->getNoticeProductList(); - return $this->_d3GetGAProductList($aArticleList); - } - - /** - * don't change method name, it was dynamically generated - * @param account_wishlist $oView - * - * @return array - */ - protected function _d3GetGAaccount_wishlistProdList($oView) - { - $aArticleList = $oView->getWishProductList(); - return $this->_d3GetGAProductList($aArticleList); - } - - /** - * @param $aArticleList - * - * @return array - */ - protected function _d3GetGAProductList($aArticleList) - { - $aArticleIds = array(); - $dPrice = 0; - - /** @var oxarticle $oArticle */ - if (isset($aArticleList)) { - foreach ($aArticleList as $oArticle) { - $aArticleIds[] = $oArticle->getFieldData($this->sD3GARemarketingSKUField); - if ($this->blD3GARemarketingUseBrutto) { - $dPrice += $oArticle->getPrice()->getBruttoPrice(); - } else { - $dPrice += $oArticle->getPrice()->getNettoPrice(); - } - } - } - - return array('aArtIdList' => $aArticleIds, 'dPrice' => $dPrice); - } - /** * @param $aParameter *