Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Sep 8, 2023
2 parents 6b7dbf1 + 26e80e7 commit 710d35d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Model/Resource/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function cleanOldSessions(?Mage_Api_Model_User $user)
Varien_Db_Adapter_Interface::INTERVAL_SECOND
);
$where = [
$readAdapter->quote(Varien_Date::now()) . ' > '. $timeSubtract
$readAdapter->quote(Varien_Date::now()) . ' > ' . $timeSubtract
];
if ($user) {
$where['user_id = ?'] = $user->getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ public function addStoreLabel($storeId)
['store_label' => $adapter->getIfNullSql('al.value', 'main_table.frontend_label')]
);
$this->_addedStoreLabelsFlag = $storeId;
} // check that previous call $storeId matches current call
elseif ($this->_addedStoreLabelsFlag !== $storeId) {
} elseif ($this->_addedStoreLabelsFlag !== $storeId) {
// check that previous call $storeId matches current call
throw new Exception('Cannot call addStoreLabel for different store views on the same collection');
}

Expand Down
51 changes: 15 additions & 36 deletions app/code/core/Mage/GoogleAnalytics/Block/Ga.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function _getPageTrackingCodeAnalytics4($accountId)
//add user_id
if ($this->helper('googleanalytics')->isUserIdEnabled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
$trackingCode.= "
$trackingCode .= "
gtag('set', 'user_id', '{$customer->getId()}');
";
}
Expand Down Expand Up @@ -185,12 +185,9 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
}
}

/**
* This event signifies that some content was shown to the user. Use this event to discover the most popular items viewed.
*
* @link https://developers.google.com/tag-platform/gtagjs/reference/events#view_item
*/
if ($moduleName == 'catalog' && $controllerName == 'product') {
// This event signifies that some content was shown to the user. Use this event to discover the most popular items viewed.
// @see https://developers.google.com/tag-platform/gtagjs/reference/events#view_item
$productViewed = Mage::registry('current_product');
$category = Mage::registry('current_category') ? Mage::registry('current_category')->getName() : false;
$eventData = [];
Expand All @@ -209,14 +206,9 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
}
array_push($eventData['items'], $_item);
$result[] = "gtag('event', 'view_item', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
}

/**
* Log this event when the user has been presented with a list of items of a certain category.
*
* @link https://developers.google.com/tag-platform/gtagjs/reference/events#view_item_list
*/
elseif ($moduleName == 'catalog' && $controllerName == 'category') {
} elseif ($moduleName == 'catalog' && $controllerName == 'category') {
// Log this event when the user has been presented with a list of items of a certain category.
// @see https://developers.google.com/tag-platform/gtagjs/reference/events#view_item_list
$layer = Mage::getSingleton('catalog/layer');
$category = $layer->getCurrentCategory();
$productCollection = clone $layer->getProductCollection();
Expand All @@ -231,7 +223,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
$eventData = [];
$eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
$eventData['value'] = 0.00;
$eventData['item_list_id'] = 'category_'.$category->getUrlKey();
$eventData['item_list_id'] = 'category_' . $category->getUrlKey();
$eventData['item_list_name'] = $category->getName();
$eventData['items'] = [];

Expand All @@ -255,14 +247,9 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
}
$eventData['value'] = $helper->formatPrice($eventData['value']);
$result[] = "gtag('event', 'view_item_list', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
}

/**
* This event signifies that a user viewed his cart.
*
* @link https://developers.google.com/tag-platform/gtagjs/reference/events#view_cart
*/
elseif ($moduleName == 'checkout' && $controllerName == 'cart') {
} elseif ($moduleName == 'checkout' && $controllerName == 'cart') {
// This event signifies that a user viewed his cart.
// @see https://developers.google.com/tag-platform/gtagjs/reference/events#view_cart
$productCollection = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
$eventData = [];
$eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
Expand Down Expand Up @@ -292,14 +279,9 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
}
$eventData['value'] = $helper->formatPrice($eventData['value']);
$result[] = "gtag('event', 'view_cart', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
}

/**
* This event signifies that a user has begun a checkout.
*
* @link https://developers.google.com/tag-platform/gtagjs/reference/events#begin_checkout
*/
elseif ($moduleName == static::CHECKOUT_MODULE_NAME && $controllerName == static::CHECKOUT_CONTROLLER_NAME) {
} elseif ($moduleName == static::CHECKOUT_MODULE_NAME && $controllerName == static::CHECKOUT_CONTROLLER_NAME) {
// This event signifies that a user has begun a checkout.
// @see https://developers.google.com/tag-platform/gtagjs/reference/events#begin_checkout
$productCollection = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
if ($productCollection) {
$eventData = [];
Expand Down Expand Up @@ -332,11 +314,8 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
}
}

/**
* This event signifies when one or more items is purchased by a user.
*
* @link https://developers.google.com/tag-platform/gtagjs/reference/events?hl=it#purchase
*/
// This event signifies when one or more items is purchased by a user.
// @see https://developers.google.com/tag-platform/gtagjs/reference/events?hl=it#purchase
$orderIds = $this->getOrderIds();
if (!empty($orderIds) && is_array($orderIds)) {
$collection = Mage::getResourceModel('sales/order_collection')
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Data/Collection/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function getSelectCountSql()
$bindParams = array_map(function ($token) {
return ltrim($token, ':');
}, array_keys($this->_bindParams));
$bindPattern = '/:('.implode('|', $bindParams).')/';
$bindPattern = '/:(' . implode('|', $bindParams) . ')/';
$joinUsingBind = array_filter($leftJoins, function ($table) use ($bindPattern) {
return !empty($table['joinCondition']) && preg_match($bindPattern, $table['joinCondition']);
});
Expand Down

0 comments on commit 710d35d

Please sign in to comment.