'Order #'); public function getPlaceholdersData() { if (($id = $this->getTransactionId()) !== null) { $this->setPrimaryKey($id); $this->_setHtmlPlaceholdersData($this->getData()); /** @var App_Doc_Site $doc */ $doc = Zend_Registry::get('doc'); if (Qs_Doc::ANALYTICS_TYPE_GOOGLE_TAG_MANAGER == $doc->getAnalyticsType()) { $this->_setGtmValues(); } } else { $url = Qs_SiteMap::findFirst(null, array('type' => 'ECommerce_Cart_'), array('type' => 'default'), 'url'); Qs_Http::redirect($url); } return parent::getPlaceholdersData(); } protected function _setGtmValues() { $transactionData = $this->getData(); $cartObj = new App_ECommerce_Cart_Obj(); $cartObj->setPrimaryKey($cartObj->getCartIdByTransaction($transactionData['id'])); $products = $cartObj->getList(); $categories = $this->_getGtmProductCategories(Qs_Array::fetchCol($products, 'productCategoryId')); foreach ($products as &$product) { $product['productCategory'] = Qs_Array::get($categories, (string) $product['productCategoryId'], ''); } unset($product); /** @var App_Doc_Site $doc */ $doc = Zend_Registry::get('doc'); $doc->addGtmValues(Qs_Gtm::adGetPurchase($transactionData, $products)); $doc->addGtmValues(Qs_Gtm::gaGetECommerce($transactionData, $products)); $doc->addGtmValues(Qs_Gtm::eeGetMeasuringPurchases($transactionData, $products)); return $this; } protected function _getGtmProductCategories(array $productIds) { $categories = []; if ($productIds) { $select = $this->_db->select(); $select->from($this->_getPair('ProductCategory', 'pc'), ['id', 'title']); $select->where('`pc`.`id` IN (?)', $productIds, Qs_Db::INT_TYPE); $categories = $this->_db->fetchPairs($select); } return $categories; } }