diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000000..9a62c0b465f
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,35 @@
+# Make packagist / composer download smaller
+/.ddev export-ignore
+/.github export-ignore
+/dev
+/docs
+
+/.all-contributorsrc
+/.gitattributes export-ignore
+/.gitignore
+/.gitpod.yml
+
+/.php-cs-fixer.dist.php export-ignore
+/.phpcs.ecg.xml.dist export-ignore
+/.phpcs.php.xml.dist export-ignore
+/.phpcs.xml.dist export-ignore
+/.phpmd.dist.xml export-ignore
+/phpstan.dist.baseline.neon export-ignore
+/phpstan.dist.issues.neon export-ignore
+/phpstan.dist.neon export-ignore
+
+# Enforce checkout with linux lf consistent over all platforms
+*.html text eol=lf
+*.css text eol=lf
+*.js text eol=lf
+*.json text eol=lf
+*.php text eol=lf
+*.md text eol=lf
+*.yml text eol=lf
+*.yaml text eol=lf
+*.xml text eol=lf
+*.sh text eol=lf
+*.sql text eol=lf
+*.svg text eol=lf
+*.txt text eol=lf
+*.phtml text eol=lf
\ No newline at end of file
diff --git a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php b/app/code/core/Mage/GoogleAnalytics/Block/Ga.php
index 581214a3543..8ff63df5a15 100644
--- a/app/code/core/Mage/GoogleAnalytics/Block/Ga.php
+++ b/app/code/core/Mage/GoogleAnalytics/Block/Ga.php
@@ -55,6 +55,7 @@ public function getAccount()
* Get a specific page name (may be customized via layout)
*
* @return string
+ * @deprecated
*/
public function getPageName()
{
@@ -72,11 +73,50 @@ protected function _getPageTrackingCode($accountId)
{
/** @var Mage_GoogleAnalytics_Helper_Data $helper */
$helper = $this->helper('googleanalytics');
- if ($helper->isUseUniversalAnalytics()) {
+ if ($helper->isUseAnalytics4()) {
+ return $this->_getPageTrackingCodeAnalytics4($accountId);
+ } elseif ($helper->isUseUniversalAnalytics()) {
return $this->_getPageTrackingCodeUniversal($accountId);
+ } else {
+ return $this->_getPageTrackingCodeAnalytics($accountId);
+ }
+ }
+
+ /**
+ * Render regular page tracking javascript code
+ *
+ * @link https://developers.google.com/tag-platform/gtagjs/reference
+ * @param string $accountId
+ * @return string
+ */
+ protected function _getPageTrackingCodeAnalytics4($accountId)
+ {
+ $trackingCode = "
+gtag('js', new Date());
+";
+ if (!$this->helper('googleanalytics')->isDebugModeEnabled()) {
+ $trackingCode .= "
+gtag('config', '{$this->jsQuoteEscape($accountId)}');
+";
+ } else {
+ $trackingCode .= "
+gtag('config', '{$this->jsQuoteEscape($accountId)}', {'debug_mode':true});
+";
+ }
+
+ //add user_id
+ if ($this->helper('googleanalytics')->isUserIdEnabled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
+ $trackingCode.= "
+gtag('set', 'user_id', '{$customer->getId()}');
+";
}
- return $this->_getPageTrackingCodeAnalytics($accountId);
+ if ($this->helper('googleanalytics')->isDebugModeEnabled()) {
+ $this->helper('googleanalytics')->log($trackingCode);
+ }
+
+ return $trackingCode;
}
/**
@@ -192,8 +232,10 @@ protected function _getOrdersTrackingCodeUniversal()
}
/**
+ * Render information about specified orders and their items
+ *
* @return string
- * @throws Mage_Core_Model_Store_Exception
+ * @throws JsonException
*/
protected function _getOrdersTrackingCodeAnalytics4()
{
@@ -202,62 +244,107 @@ protected function _getOrdersTrackingCodeAnalytics4()
$moduleName = $request->getModuleName();
$controllerName = $request->getControllerName();
- //purchase events
- $orderIds = $this->getOrderIds();
- if (!empty($orderIds) && is_array($orderIds)) {
- $collection = Mage::getResourceModel('sales/order_collection')
- ->addFieldToFilter('entity_id', ['in' => $orderIds]);
- /** @var Mage_Sales_Model_Order $order */
- foreach ($collection as $order) {
- $orderData = [
- 'currency' => $order->getBaseCurrencyCode(),
- 'transaction_id' => $order->getIncrementId(),
- 'value' => number_format($order->getBaseGrandTotal(), 2),
- 'coupon' => strtoupper($order->getCouponCode()),
- 'shipping' => number_format($order->getBaseShippingAmount(), 2),
- 'tax' => number_format($order->getBaseTaxAmount(), 2),
- 'items' => []
+ /**
+ * This event signifies that an item was removed from a cart.
+ *
+ * @link https://developers.google.com/tag-platform/gtagjs/reference/events#remove_from_cart
+ */
+ $removedProducts = Mage::getSingleton('core/session')->getRemovedProductsCart();
+ if ($removedProducts) {
+ foreach ($removedProducts as $removedProduct) {
+ $_removedProduct = Mage::getModel('catalog/product')->load($removedProduct);
+ $eventData = [];
+ $eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
+ $eventData['value'] = number_format($_removedProduct->getFinalPrice(), 2);
+ $eventData['items'] = [];
+ $_item = [
+ 'item_id' => $_removedProduct->getSku(),
+ 'item_name' => $_removedProduct->getName(),
+ 'price' => number_format($_removedProduct->getFinalPrice(), 2),
];
+ if ($_removedProduct->getAttributeText('manufacturer')) {
+ $_item['item_brand'] = $_removedProduct->getAttributeText('manufacturer');
+ }
+ if ($_removedProduct->getCategoryIds()) {
+ $_lastCat = end($_removedProduct->getCategoryIds());
+ $_cat = Mage::getModel('catalog/category')->load($_lastCat);
+ $_item['item_category'] = $_cat->getName();
+ }
+ array_push($eventData['items'], $_item);
+ $result[] = "gtag('event', 'remove_from_cart', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
+ }
+ Mage::getSingleton('core/session')->unsRemovedProductsCart();
+ }
- /** @var Mage_Sales_Model_Order_Item $item */
- foreach ($order->getAllVisibleItems() as $item) {
- $orderData['items'][] = [
- 'item_id' => $item->getSku(),
- 'item_name' => $item->getName(),
- 'quantity' => $item->getQtyOrdered(),
- 'price' => $item->getBasePrice(),
- 'discount' => $item->getBaseDiscountAmount()
- ];
+ /**
+ * This event signifies that an item was added to a cart for purchase.
+ *
+ * @link https://developers.google.com/tag-platform/gtagjs/reference/events#add_to_cart
+ */
+ $addedProducts = Mage::getSingleton('core/session')->getAddedProductsCart();
+ if ($addedProducts) {
+ foreach ($addedProducts as $addedProduct) {
+ $_addedProduct = Mage::getModel('catalog/product')->load($addedProduct);
+ $eventData = [];
+ $eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
+ $eventData['value'] = number_format($_addedProduct->getFinalPrice(), 2);
+ $eventData['items'] = [];
+ $_item = [
+ 'item_id' => $_addedProduct->getSku(),
+ 'item_name' => $_addedProduct->getName(),
+ 'price' => number_format($_addedProduct->getFinalPrice(), 2),
+ ];
+ if ($_addedProduct->getAttributeText('manufacturer')) {
+ $_item['item_brand'] = $_addedProduct->getAttributeText('manufacturer');
}
- $result[] = "gtag('event', 'purchase', " . json_encode($orderData, JSON_THROW_ON_ERROR) . ");";
+ if ($_addedProduct->getCategoryIds()) {
+ $_lastCat = end($_addedProduct->getCategoryIds());
+ $_cat = Mage::getModel('catalog/category')->load($_lastCat);
+ $_item['item_category'] = $_cat->getName();
+ }
+ array_push($eventData['items'], $_item);
+ $result[] = "gtag('event', 'add_to_cart', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
+ Mage::getSingleton('core/session')->unsAddedProductsCart();
}
}
- //Begin advanced eCommerce events
- //product page
+ /**
+ * 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') {
$productViewed = Mage::registry('current_product');
+ $category = Mage::registry('current_category') ? Mage::registry('current_category')->getName() : false;
$eventData = [];
$eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
$eventData['value'] = number_format($productViewed->getFinalPrice(), 2);
$eventData['items'] = [];
- $eventData['items'][] = [
- 'id' => $productViewed->getSku(),
- 'name' => $productViewed->getName(),
+ $_item = [
+ 'item_id' => $productViewed->getSku(),
+ 'item_name' => $productViewed->getName(),
'list_name' => 'Product Detail Page',
- 'brand' => $productViewed->getAttributeText('manufacturer'),
- 'category' => 'Products',
+ 'item_category' => $category,
'price' => number_format($productViewed->getFinalPrice(), 2),
];
-
+ if ($productViewed->getAttributeText('manufacturer')) {
+ $_item['item_brand'] = $productViewed->getAttributeText('manufacturer');
+ }
+ array_push($eventData['items'], $_item);
$result[] = "gtag('event', 'view_item', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
}
- //category page
+ /**
+ * 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') {
$layer = Mage::getSingleton('catalog/layer');
$category = $layer->getCurrentCategory();
$productCollection = clone $layer->getProductCollection();
+ $productCollection->addAttributeToSelect('sku');
+
$toolbarBlock = Mage::app()->getLayout()->getBlock('product_list_toolbar');
$pageSize = $toolbarBlock->getLimit();
$currentPage = $toolbarBlock->getCurrentPage();
@@ -271,61 +358,34 @@ protected function _getOrdersTrackingCodeAnalytics4()
$eventData['item_list_name'] = $category->getName();
$eventData['items'] = [];
- foreach ($productCollection as $productViewed) {
- $eventData['items'][] = [
- 'id' => $productViewed->getSku(),
- 'name' => $productViewed->getName(),
- 'list_name' => 'Product Detail Page',
- 'brand' => $productViewed->getAttributeText('manufacturer'),
- 'category' => 'Products',
+ $index = 1;
+ foreach ($productCollection as $key => $productViewed) {
+ $_item = [
+ 'item_id' => $productViewed->getSku(),
+ 'index' => $index,
+ 'item_name' => $productViewed->getName(),
'price' => number_format($productViewed->getFinalPrice(), 2),
];
+ if ($productViewed->getAttributeText('manufacturer')) {
+ $_item['item_brand'] = $productViewed->getAttributeText('manufacturer');
+ }
+ if ($productViewed->getCategory()->getName()) {
+ $_item['item_category'] = $productViewed->getCategory()->getName();
+ }
+ array_push($eventData['items'], $_item);
+ $index++;
$eventData['value'] += $productViewed->getFinalPrice();
}
$eventData['value'] = number_format($eventData['value'], 2);
$result[] = "gtag('event', 'view_item_list', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
}
- //cart
+ /**
+ * 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') {
- $removedProduct = Mage::getSingleton('core/session')->getRemovedProductCart();
- if ($removedProduct) {
- $_removedProduct = Mage::getModel('catalog/product')->load($removedProduct);
- $eventData = [];
- $eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
- $eventData['value'] = number_format($_removedProduct->getFinalPrice(), 2);
- $eventData['items'] = [];
- $eventData['items'][] = [
- 'id' => $_removedProduct->getSku(),
- 'name' => $_removedProduct->getName(),
- 'list_name' => 'Product Detail Page',
- 'brand' => $_removedProduct->getAttributeText('manufacturer'),
- 'category' => 'Products',
- 'price' => number_format($_removedProduct->getFinalPrice(), 2),
- ];
- $result[] = "gtag('event', 'remove_from_cart', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
- Mage::getSingleton('core/session')->unsRemovedProductCart();
- }
-
- $addedProduct = Mage::getSingleton('core/session')->getAddedProductCart();
- if ($addedProduct) {
- $_addedProduct = Mage::getModel('catalog/product')->load($addedProduct);
- $eventData = [];
- $eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
- $eventData['value'] = number_format($_addedProduct->getFinalPrice(), 2);
- $eventData['items'] = [];
- $eventData['items'][] = [
- 'id' => $_addedProduct->getSku(),
- 'name' => $_addedProduct->getName(),
- 'list_name' => 'Product Detail Page',
- 'brand' => $_addedProduct->getAttributeText('manufacturer'),
- 'category' => 'Products',
- 'price' => number_format($_addedProduct->getFinalPrice(), 2),
- ];
- $result[] = "gtag('event', 'add_to_cart', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
- Mage::getSingleton('core/session')->unsAddedProductCart();
- }
-
$productCollection = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();
$eventData = [];
$eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
@@ -333,41 +393,109 @@ protected function _getOrdersTrackingCodeAnalytics4()
$eventData['items'] = [];
foreach ($productCollection as $productInCart) {
- $eventData['items'][] = [
- 'id' => $productInCart->getSku(),
- 'name' => $productInCart->getName(),
- 'list_name' => 'Product Detail Page',
- 'brand' => $productInCart->getAttributeText('manufacturer'),
- 'category' => 'Products',
- 'price' => number_format($productInCart->getFinalPrice(), 2),
+ $_product = Mage::getModel('catalog/product')->load($productInCart->getProductId());
+ $_item = [
+ 'item_id' => $_product->getSku(),
+ 'item_name' => $_product->getName(),
+ 'price' => number_format($_product->getFinalPrice(), 2),
];
- $eventData['value'] += $productInCart->getFinalPrice();
+ if ($_product->getAttributeText('manufacturer')) {
+ $_item['item_brand'] = $_product->getAttributeText('manufacturer');
+ }
+ if ($_product->getCategoryIds()) {
+ $_lastCat = end($_product->getCategoryIds());
+ $_cat = Mage::getModel('catalog/category')->load($_lastCat);
+ $_item['item_category'] = $_cat->getName();
+ }
+ array_push($eventData['items'], $_item);
+ $eventData['value'] += $_product->getFinalPrice();
}
$eventData['value'] = number_format($eventData['value'], 2);
$result[] = "gtag('event', 'view_cart', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
}
- //begin checkout
+ /**
+ * This event signifies that a user has begun a checkout.
+ *
+ * @link https://developers.google.com/tag-platform/gtagjs/reference/events#begin_checkout
+ */
elseif ($moduleName == 'checkout' && $controllerName == 'onepage') {
$productCollection = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();
- $eventData = [];
- $eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
- $eventData['value'] = 0.00;
- $eventData['items'] = [];
+ if ($productCollection) {
+ $eventData = [];
+ $eventData['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
+ $eventData['value'] = 0.00;
+ $eventData['items'] = [];
+ foreach ($productCollection as $productInCart) {
+ $_product = Mage::getModel('catalog/product')->load($productInCart->getProductId());
+ $_item = [
+ 'item_id' => $_product->getSku(),
+ 'item_name' => $_product->getName(),
+ 'price' => number_format($_product->getFinalPrice(), 2),
+ ];
+ if ($_product->getAttributeText('manufacturer')) {
+ $_item['item_brand'] = $_product->getAttributeText('manufacturer');
+ }
+ if ($_product->getCategoryIds()) {
+ $_lastCat = end($_product->getCategoryIds());
+ $_cat = Mage::getModel('catalog/category')->load($_lastCat);
+ $_item['item_category'] = $_cat->getName();
+ }
+ array_push($eventData['items'], $_item);
+ $eventData['value'] += $_product->getFinalPrice();
+ }
+ $eventData['value'] = number_format($eventData['value'], 2);
+ $result[] = "gtag('event', 'begin_checkout', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
+ }
+ }
- foreach ($productCollection as $productInCart) {
- $eventData['items'][] = [
- 'id' => $productInCart->getSku(),
- 'name' => $productInCart->getName(),
- 'list_name' => 'Product Detail Page',
- 'brand' => $productInCart->getAttributeText('manufacturer'),
- 'category' => 'Products',
- 'price' => number_format($productInCart->getFinalPrice(), 2),
+ /**
+ * 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
+ */
+ $orderIds = $this->getOrderIds();
+ if (!empty($orderIds) && is_array($orderIds)) {
+ $collection = Mage::getResourceModel('sales/order_collection')
+ ->addFieldToFilter('entity_id', ['in' => $orderIds]);
+ /** @var Mage_Sales_Model_Order $order */
+ foreach ($collection as $order) {
+ $orderData = [
+ 'currency' => $order->getBaseCurrencyCode(),
+ 'transaction_id' => $order->getIncrementId(),
+ 'value' => number_format($order->getBaseGrandTotal(), 2),
+ 'coupon' => strtoupper($order->getCouponCode()),
+ 'shipping' => number_format($order->getBaseShippingAmount(), 2),
+ 'tax' => number_format($order->getBaseTaxAmount(), 2),
+ 'items' => []
];
- $eventData['value'] += $productInCart->getFinalPrice();
+
+ /** @var Mage_Sales_Model_Order_Item $item */
+ foreach ($order->getAllVisibleItems() as $item) {
+ $_item = [
+ 'item_id' => $item->getSku(),
+ 'item_name' => $item->getName(),
+ 'quantity' => $item->getQtyOrdered(),
+ 'price' => $item->getBasePrice(),
+ 'discount' => $item->getBaseDiscountAmount()
+ ];
+ $_product = Mage::getModel('catalog/product')->load($item->getProductId());
+ if ($_product->getAttributeText('manufacturer')) {
+ $_item['item_brand'] = $_product->getAttributeText('manufacturer');
+ }
+ if ($_product->getCategoryIds()) {
+ $_lastCat = end($_product->getCategoryIds());
+ $_cat = Mage::getModel('catalog/category')->load($_lastCat);
+ $_item['item_category'] = $_cat->getName();
+ }
+ array_push($orderData['items'], $_item);
+ }
+ $result[] = "gtag('event', 'purchase', " . json_encode($orderData, JSON_THROW_ON_ERROR) . ");";
}
- $eventData['value'] = number_format($eventData['value'], 2);
- $result[] = "gtag('event', 'begin_checkout', " . json_encode($eventData, JSON_THROW_ON_ERROR) . ");";
+ }
+
+ if ($this->helper('googleanalytics')->isDebugModeEnabled() && count($result) > 0) {
+ $this->helper('googleanalytics')->log($result);
}
return implode("\n", $result);
}
diff --git a/app/code/core/Mage/GoogleAnalytics/Helper/Data.php b/app/code/core/Mage/GoogleAnalytics/Helper/Data.php
index 7cb92cf7528..237d2c2b0ff 100644
--- a/app/code/core/Mage/GoogleAnalytics/Helper/Data.php
+++ b/app/code/core/Mage/GoogleAnalytics/Helper/Data.php
@@ -28,6 +28,8 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
public const XML_PATH_TYPE = 'google/analytics/type';
public const XML_PATH_ACCOUNT = 'google/analytics/account';
public const XML_PATH_ANONYMIZATION = 'google/analytics/anonymization';
+ public const XML_PATH_DEBUG = 'google/analytics/debug';
+ public const XML_PATH_USERID = 'google/analytics/user_id';
/**
* @var string google analytics 4
@@ -104,4 +106,37 @@ public function isUseAnalytics4($store = null)
{
return Mage::getStoreConfig(self::XML_PATH_TYPE, $store) == self::TYPE_ANALYTICS4;
}
+
+ /**
+ * Whether GA Debug Mode is enabled (only for development IP)
+ *
+ * @param null $store
+ * @return bool
+ */
+ public function isDebugModeEnabled($store = null)
+ {
+ return Mage::getStoreConfigFlag(self::XML_PATH_DEBUG, $store) && Mage::helper('core')->isDevAllowed();
+ }
+
+ /**
+ * Log debug message
+ *
+ * @param string $message
+ */
+ public function log($message = null)
+ {
+ $filename = sprintf('google%s.log', Mage::getStoreConfig(self::XML_PATH_TYPE));
+ Mage::log($message, Zend_Log::DEBUG, $filename, true);
+ }
+
+ /**
+ * Whether GA IP Anonymization is enabled
+ *
+ * @param null $store
+ * @return bool
+ */
+ public function isUserIdEnabled($store = null)
+ {
+ return Mage::getStoreConfigFlag(self::XML_PATH_USERID, $store);
+ }
}
diff --git a/app/code/core/Mage/GoogleAnalytics/Model/Observer.php b/app/code/core/Mage/GoogleAnalytics/Model/Observer.php
index 667241f6f59..772312819f5 100644
--- a/app/code/core/Mage/GoogleAnalytics/Model/Observer.php
+++ b/app/code/core/Mage/GoogleAnalytics/Model/Observer.php
@@ -59,7 +59,10 @@ public function removeItemFromCartGoogleAnalytics(Varien_Event_Observer $observe
{
$productRemoved = $observer->getEvent()->getQuoteItem()->getProduct();
if ($productRemoved) {
- Mage::getSingleton('core/session')->setRemovedProductCart($productRemoved->getId());
+ $_removedProducts = Mage::getSingleton('core/session')->getRemovedProductsCart() ?: [];
+ $_removedProducts[] = $productRemoved->getId();
+ $_removedProducts = array_unique($_removedProducts);
+ Mage::getSingleton('core/session')->setRemovedProductsCart($_removedProducts);
}
}
@@ -72,7 +75,14 @@ public function addItemToCartGoogleAnalytics(Varien_Event_Observer $observer)
{
$productAdded = $observer->getEvent()->getQuoteItem()->getProduct();
if ($productAdded) {
- Mage::getSingleton('core/session')->setAddedProductCart($productAdded->getId());
+ // Fix double add to cart for configurable products, skip child product
+ if ($productAdded->getParentProductId()) {
+ return;
+ }
+ $_addedProducts = Mage::getSingleton('core/session')->getAddedProductsCart() ?: [];
+ $_addedProducts[] = $productAdded->getParentItem() ? $productAdded->getParentItem()->getId() : $productAdded->getId();
+ $_addedProducts = array_unique($_addedProducts);
+ Mage::getSingleton('core/session')->setAddedProductsCart($_addedProducts);
}
}
}
diff --git a/app/code/core/Mage/GoogleAnalytics/etc/system.xml b/app/code/core/Mage/GoogleAnalytics/etc/system.xml
index 64120809aa6..9631f0fe728 100644
--- a/app/code/core/Mage/GoogleAnalytics/etc/system.xml
+++ b/app/code/core/Mage/GoogleAnalytics/etc/system.xml
@@ -57,6 +57,32 @@
1
1
+
+
+ select
+ adminhtml/system_config_source_yesno
+ 21
+ 1
+ 1
+ 1
+ Enable GA4 User_id tracking for logged in customers.
+
+ analytics4
+
+
+
+
+ select
+ adminhtml/system_config_source_yesno
+ 22
+ 1
+ 1
+ 1
+ Enable GA4 Debug Real Time view for Development IP.
+
+ analytics4
+
+
select
@@ -65,6 +91,9 @@
1
1
1
+
+ universal
+
diff --git a/app/design/frontend/base/default/template/googleanalytics/ga.phtml b/app/design/frontend/base/default/template/googleanalytics/ga.phtml
index 08762b3195b..d0a3fab571b 100644
--- a/app/design/frontend/base/default/template/googleanalytics/ga.phtml
+++ b/app/design/frontend/base/default/template/googleanalytics/ga.phtml
@@ -25,8 +25,7 @@ $_accountId = $_helper->getAccountId();
diff --git a/app/locale/en_US/Mage_GoogleAnalytics.csv b/app/locale/en_US/Mage_GoogleAnalytics.csv
index 1b90846f791..54b35787571 100644
--- a/app/locale/en_US/Mage_GoogleAnalytics.csv
+++ b/app/locale/en_US/Mage_GoogleAnalytics.csv
@@ -6,3 +6,5 @@
"Type","Type"
"Universal Analytics","Universal Analytics"
"Google Analytics 4","Google Analytics 4"
+"Enable GA4 User_id tracking for logged in customers.","Enable GA4 User_id tracking for logged in customers."
+"Enable GA4 Debug Real Time view for Development IP.","Enable GA4 Debug Real Time view for Development IP."
\ No newline at end of file
diff --git a/lib/Varien/Db/Tree.php b/lib/Varien/Db/Tree.php
index eb059930a89..cf381a9af83 100644
--- a/lib/Varien/Db/Tree.php
+++ b/lib/Varien/Db/Tree.php
@@ -65,11 +65,6 @@ public function __construct($config = [])
// convenience variable
$db = $config['db'];
- // use an object from the registry?
- if (is_string($db)) {
- $db = Zend::registry($db);
- }
-
// make sure it's a Zend_Db_Adapter
if (! $db instanceof Zend_Db_Adapter_Abstract) {
throw new Varien_Db_Tree_Exception('db object does not implement Zend_Db_Adapter_Abstract');
@@ -223,7 +218,7 @@ public function clear($data = [])
try {
$this->_db->insert($this->_table, $data);
- } catch (PDOException $e) {
+ } catch (Zend_Db_Adapter_Exception $e) {
echo $e->getMessage();
}
return $this->_db->lastInsertId();
@@ -424,7 +419,7 @@ public function __moveNode($eId, $pId, $aId = 0)
if ($pId == 0) { //move to root
$right_key_near = $this->_db->fetchOne('SELECT MAX(' . $this->_right . ') FROM ' . $this->_table);
- } elseif ($aId != 0 && $pID == $eInfo[$this->_pid]) { // if we have after ID
+ } elseif ($aId != 0 && $pId == $eInfo[$this->_pid]) { // if we have after ID
$right_key_near = $aInfo[$this->_right];
$left_key_near = $aInfo[$this->_left];
} elseif ($aId == 0 && $pId == $eInfo[$this->_pid]) { // if we do not have after ID
diff --git a/lib/Varien/Db/Tree/NodeSet.php b/lib/Varien/Db/Tree/NodeSet.php
index 7266663671a..fb2f4ecf2bf 100644
--- a/lib/Varien/Db/Tree/NodeSet.php
+++ b/lib/Varien/Db/Tree/NodeSet.php
@@ -58,13 +58,10 @@ public function valid(): bool
return isset($this->_nodes[$this->_current]);
}
- #[\ReturnTypeWillChange]
- public function next()
+ public function next(): void
{
- if ($this->_current > $this->_currentNode) {
- return false;
- } else {
- return $this->_current++;
+ if ($this->_current <= $this->_currentNode) {
+ $this->_current++;
}
}
diff --git a/lib/Varien/File/Uploader/Image.php b/lib/Varien/File/Uploader/Image.php
index 609ff0ecf94..5ace5517c1f 100644
--- a/lib/Varien/File/Uploader/Image.php
+++ b/lib/Varien/File/Uploader/Image.php
@@ -23,10 +23,9 @@
*/
class Varien_File_Uploader_Image extends Varien_File_Uploader
{
- public function __construct($file = null)
+ public function __construct()
{
register_shutdown_function([$this, 'destruct']);
- $this->newUploader($file);
}
/**
@@ -351,7 +350,3 @@ public function setBgColor($color = "#000000")
$this->uploader->image_background_color = $color;
}
}
-
-// ft:php
-// fileformat:unix
-// tabstop:4
diff --git a/lib/Varien/Filter/Template.php b/lib/Varien/Filter/Template.php
index 1672705ca1f..b77c61eb28d 100644
--- a/lib/Varien/Filter/Template.php
+++ b/lib/Varien/Filter/Template.php
@@ -128,9 +128,6 @@ public function filter($value)
foreach ($constructions as $index => $construction) {
$replacedValue = '';
$callback = [$this, $directive];
- if (!is_callable($callback)) {
- continue;
- }
try {
$replacedValue = call_user_func($callback, $construction);
} catch (Exception $e) {
diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon
index b4adfac4064..d3b6e7ef024 100644
--- a/phpstan.dist.baseline.neon
+++ b/phpstan.dist.baseline.neon
@@ -4800,41 +4800,6 @@ parameters:
count: 1
path: lib/Varien/Db/Statement/Pdo/Mysql.php
- -
- message: "#^Call to static method registry\\(\\) on an unknown class Zend\\.$#"
- count: 1
- path: lib/Varien/Db/Tree.php
-
- -
- message: "#^Dead catch \\- PDOException is never thrown in the try block\\.$#"
- count: 1
- path: lib/Varien/Db/Tree.php
-
- -
- message: "#^Undefined variable\\: \\$pID$#"
- count: 1
- path: lib/Varien/Db/Tree.php
-
- -
- message: "#^Method Varien_Db_Tree_NodeSet\\:\\:next\\(\\) with return type void returns false but should not return anything\\.$#"
- count: 1
- path: lib/Varien/Db/Tree/NodeSet.php
-
- -
- message: "#^Method Varien_Db_Tree_NodeSet\\:\\:next\\(\\) with return type void returns mixed but should not return anything\\.$#"
- count: 1
- path: lib/Varien/Db/Tree/NodeSet.php
-
- -
- message: "#^Call to an undefined method Varien_File_Uploader_Image\\:\\:newUploader\\(\\)\\.$#"
- count: 1
- path: lib/Varien/File/Uploader/Image.php
-
- -
- message: "#^Call to function is_callable\\(\\) with array\\{\\$this\\(Varien_Filter_Template\\), 'dependDirective'\\|'ifDirective'\\} will always evaluate to true\\.$#"
- count: 1
- path: lib/Varien/Filter/Template.php
-
-
message: "#^Right side of && is always false\\.$#"
count: 1