diff --git a/copy_this/modules/d3/d3_googleanalytics/metadata.php b/copy_this/modules/d3/d3_googleanalytics/metadata.php index ee68a4d..4a58fb2 100644 --- a/copy_this/modules/d3/d3_googleanalytics/metadata.php +++ b/copy_this/modules/d3/d3_googleanalytics/metadata.php @@ -55,26 +55,20 @@ $aModule = array( 'oxutilsview' => 'd3/d3_googleanalytics/modules/core/d3_oxutilsview_googleanalytics', 'thankyou' => 'd3/d3_googleanalytics/modules/controllers/d3_thankyou_googleanalytics', ), - 'files' => array( - 'd3_cfg_googleanalytics' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics.php', - 'd3_cfg_googleanalytics_adwords' => - 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_adwords.php', - 'd3_cfg_googleanalytics_campaigns' => - 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_campaigns.php', - 'd3_cfg_googleanalytics_licence' => - 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_licence.php', - 'd3_cfg_googleanalytics_list' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_list.php', - 'd3_cfg_googleanalytics_main' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_main.php', - 'd3_cfg_googleanalytics_trustedstore' => - 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_trustedstore.php', - 'd3_cfg_googleanalyticslog' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalyticslog.php', - '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', + 'files' => array( + 'd3_cfg_googleanalytics' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics.php', + 'd3_cfg_googleanalytics_adwords' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_adwords.php', + 'd3_cfg_googleanalytics_campaigns' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_campaigns.php', + 'd3_cfg_googleanalytics_licence' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_licence.php', + 'd3_cfg_googleanalytics_list' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_list.php', + 'd3_cfg_googleanalytics_main' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_main.php', + 'd3_cfg_googleanalytics_trustedstore' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalytics_trustedstore.php', + 'd3_cfg_googleanalyticslog' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalyticslog.php', + 'd3_cfg_googleanalyticslog_list' => 'd3/d3_googleanalytics/controllers/admin/d3_cfg_googleanalyticslog_list.php', + 'd3_google_articlelister' => 'd3/d3_googleanalytics/models/d3_google_articlelister.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', + 'd3_googleanalytics_update' => 'd3/d3_googleanalytics/setup/d3_googleanalytics_update.php', ), 'templates' => array( 'd3ga_universal_adwordscode.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_adwordscode.tpl', diff --git a/copy_this/modules/d3/d3_googleanalytics/models/d3_google_articlelister.php b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_articlelister.php new file mode 100644 index 0000000..e1a3312 --- /dev/null +++ b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_articlelister.php @@ -0,0 +1,201 @@ + + * @link http://www.oxidmodule.com + */ + +class d3_google_articlelister +{ + public $aStartListMethodNames = array( + 'getArticleList', + 'getTopArticleList', + 'getNewestArticles', + 'getFirstArticle', + 'getCatOfferArticleList', + ); + + /** + * @param start $oView + * + * @return array + */ + public function getStartProdList($oView) + { + /** @var oxArticleList $oArticleList */ + $oArticleList = oxNew('oxarticlelist'); + + if (is_array($this->aStartListMethodNames) && count($this->aStartListMethodNames)) { + foreach ($this->aStartListMethodNames as $sListName) { + /** @var oxArticleList $oList */ + $mList = call_user_func(array($oView, $sListName)); + + if ($mList instanceof oxArticleList) { + if ($mList->count()) { + foreach ($mList->getArray() as $sID => $oArticle) { + $oArticleList->offsetSet($sID, $oArticle); + } + } + } + } + } + + return $this->_getProductList($oArticleList); + } + + /** + * @param details $oView + * + * @return array + */ + public function getDetailsProdList($oView) + { + $aArticleList = array(); + $aArticleList[] = $oView->getProduct(); + return $this->_getProductList($aArticleList); + } + + /** + * @param oxwArticleDetails $oView + * + * @return array + */ + public function getOxwarticledetailsProdList($oView) + { + $aArticleList = array(); + $aArticleList[] = $oView->getProduct(); + return $this->_getProductList($aArticleList); + } + + /** + * @param alist $oView + * + * @return array + */ + public function getAlistProdList($oView) + { + return $oView->getArticleList(); + } + + /** + * @param search $oView + * + * @return ArticleList + */ + public function getSearchProdList($oView) + { + return $oView->getArticleList(); + } + + /** + * @param vendorlist $oView + * + * @return array + */ + public function getVendorlistProdList($oView) + { + return $oView->getArticleList(); + } + + /** + * @param manufacturerlist $oView + * + * @return array + */ + public function getManufacturerlistProdList($oView) + { + return $oView->getArticleList(); + } + + /** + * @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_remarketing_articlelister.php b/copy_this/modules/d3/d3_googleanalytics/models/d3_google_remarketing_articlelister.php index 4ed8243..68aefb9 100644 --- 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 @@ -1,20 +1,18 @@ + * @copyright (C) D3 Data Development (Inh. Thomas Dartsch) + * @author D3 Data Development - Daniel Seifert * @link http://www.oxidmodule.com */ -class d3_google_remarketing_articlelister +class d3_google_remarketing_articlelister extends d3_google_articlelister { public $sD3GARemarketingSKUField = 'oxartnum'; @@ -98,7 +96,7 @@ class d3_google_remarketing_articlelister */ public function getSearchProdList($oView) { - $oArticleList = $oView->getArticleList(); + $oArticleList = parent::getSearchProdList($oView); return $this->_getProductList($oArticleList); } 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 index 4b36e39..432e2ee 100644 --- 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 @@ -1,20 +1,21 @@ + * @copyright (C) D3 Data Development (Inh. Thomas Dartsch) + * @author D3 Data Development - Daniel Seifert * @link http://www.oxidmodule.com */ -class d3_google_trustedstore_articlelister +class d3_google_trustedstore_articlelister extends d3_google_articlelister { private $_sModId = 'd3_googleanalytics'; @@ -96,7 +97,7 @@ class d3_google_trustedstore_articlelister */ public function getSearchProdList($oView) { - $oArticleList = $oView->getArticleList(); + $oArticleList = parent::getSearchProdList($oView); return $this->_getProductList($oArticleList); } 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 a1ddafe..9e8720e 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 @@ -5,6 +5,7 @@ use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception; use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException; use Doctrine\DBAL\DBALException; use OxidEsales\Eshop\Application\Controller\FrontendController; +use OxidEsales\Eshop\Application\Model\ArticleList; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Exception\StandardException; @@ -89,6 +90,8 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare $oParentView->addTplParam('sD3CurrentGTSLang', $this->d3GetGTSLang()); } + $this->setECommerceParams(); + if ($oSet->getValue('sD3GATSActive') && $oSet->getValue('sD3GATSShoppingActive')) { $aInfos = $this->d3GATSGetProdInfos(); $oParentView->addTplParam('sD3GATSProdId', $this->d3GATSGetProdIdList($aInfos['aArtIdList'])); @@ -109,6 +112,57 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare return $ret; } + /** + * @throws DBALException + * @throws DatabaseConnectionException + * @throws DatabaseErrorException + */ + public function setECommerceParams() + { + /** @var $oParentView FrontendController */ + $oParentView = $this->getParent(); + + $oSet = d3_cfg_mod::get($this->_d3getModId()); + + if ($oSet->getValue('blD3GASendECommerce')) { + $oParentView->addTplParam('blIsImpressionViewList', false); + + if ($this->isImpressionViewList()) { + $oParentView->addTplParam('blIsImpressionViewList', true); + $oParentView->addTplParam('aD3GAProdInfos', $this->d3GAGetProdInfos()); + $oParentView->addTplParam('sImpressionListType', $this->d3GAGetImpressionListType()); + } + } + + } + + public function isImpressionViewList() + { +// ToDo: has to be completed + $impressionViews = ['search', 'start', 'alist', 'vendorlist', 'manufacturerlist']; + $oCurrentView = Registry::getConfig()->getActiveView(); + + return in_array($oCurrentView->getClassKey(), $impressionViews); + } + + public function d3GAGetImpressionListType() + { + $oCurrentView = Registry::getConfig()->getActiveView(); +// ToDo: has to be completed + switch ($oCurrentView->getClassKey()) { + case 'search': + return "Search Results"; + case 'start': + return "Start Page Results"; + case 'alist': + return "Category Results"; + case 'vendorlist': + return "Vendor List Results"; + case 'manufacturerlist': + return "Manufacturer List Results"; + } + } + /** * @return string */ @@ -354,11 +408,11 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare { startProfile(__METHOD__); - $oCurrentView = oxRegistry::getConfig()->getActiveView(); + $oCurrentView = Registry::getConfig()->getActiveView(); $aArticleIds = array(); - $sMethodName = 'get'.ucfirst($oCurrentView->getClassName())."ProdList"; + $sMethodName = 'get'.ucfirst($oCurrentView->getClassKey())."ProdList"; $oArticleLister = oxNew('d3_google_trustedstore_articlelister'); if (method_exists($oArticleLister, $sMethodName)) { @@ -371,6 +425,30 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare return array('aArtIdList' => $aArticleIds); } + /** + * @return ArticleList + */ + public function d3GAGetProdInfos() + { + startProfile(__METHOD__); + + $oCurrentView = Registry::getConfig()->getActiveView(); + + $aArticleIds = array(); + + $sMethodName = 'get'.ucfirst($oCurrentView->getClassKey())."ProdList"; + $oArticleLister = oxNew('d3_google_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 * diff --git a/copy_this/modules/d3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl b/copy_this/modules/d3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl index 8c57229..8360f55 100644 --- a/copy_this/modules/d3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl +++ b/copy_this/modules/d3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl @@ -301,6 +301,26 @@ +
+
+ + + [{oxmultilang ident="D3_GOOGLEANALYTICS_ECOMMERCE"}] + + +
+
+ +
+
+ + getValue('blD3GASendECommerce')}]checked[{/if}] name="value[blD3GASendECommerce]"> + [{oxinputhelp ident="D3_GOOGLEANALYTICS_ECOMMERCE_SENDDATA_DESC"}] +
+
+
+
+

@@ -325,16 +345,6 @@ [{oxmultilang ident="D3_GOOGLEANALYTICS_ECOMMERCE"}] -
-
- -
-
- - getValue('blD3GASendECommerce')}]checked[{/if}] name="value[blD3GASendECommerce]"> - [{oxinputhelp ident="D3_GOOGLEANALYTICS_ECOMMERCE_SENDDATA_DESC"}] -
-
diff --git a/copy_this/modules/d3/d3_googleanalytics/views/tpl/widget/d3ga_gtag.tpl b/copy_this/modules/d3/d3_googleanalytics/views/tpl/widget/d3ga_gtag.tpl index 0b2e221..0870b60 100644 --- a/copy_this/modules/d3/d3_googleanalytics/views/tpl/widget/d3ga_gtag.tpl +++ b/copy_this/modules/d3/d3_googleanalytics/views/tpl/widget/d3ga_gtag.tpl @@ -4,8 +4,8 @@ [{if $oD3GASettings->getValue('blD3GAUseOptOut')}] [{block name="d3ga_optoutscript"}]