Skip to content

Commit

Permalink
Allowed customization of the checkout page identifiers for the Mage_G…
Browse files Browse the repository at this point in the history
…oogleAnalytics module (OpenMage#3363)
  • Loading branch information
fballiano authored Jul 4, 2023
1 parent 748b79d commit 1b032ac
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/code/core/Mage/GoogleAnalytics/Block/Ga.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
class Mage_GoogleAnalytics_Block_Ga extends Mage_Core_Block_Template
{
protected const CHECKOUT_MODULE_NAME = "checkout";
protected const CHECKOUT_CONTROLLER_NAME = "onepage";

/**
* Render regular page tracking javascript code
* The custom "page name" may be set from layout or somewhere else. It must start from slash.
Expand Down Expand Up @@ -304,7 +307,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
*
* @link https://developers.google.com/tag-platform/gtagjs/reference/events#begin_checkout
*/
elseif ($moduleName == 'checkout' && $controllerName == 'onepage') {
elseif ($moduleName == static::CHECKOUT_MODULE_NAME && $controllerName == static::CHECKOUT_CONTROLLER_NAME) {
$productCollection = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();
if ($productCollection) {
$eventData = [];
Expand Down Expand Up @@ -342,7 +345,7 @@ protected function _getEnhancedEcommerceDataForAnalytics4()
$orderIds = $this->getOrderIds();
if (!empty($orderIds) && is_array($orderIds)) {
$collection = Mage::getResourceModel('sales/order_collection')
->addFieldToFilter('entity_id', ['in' => $orderIds]);
->addFieldToFilter('entity_id', ['in' => $orderIds]);
/** @var Mage_Sales_Model_Order $order */
foreach ($collection as $order) {
$orderData = [
Expand Down

0 comments on commit 1b032ac

Please sign in to comment.