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 Jun 27, 2023
2 parents 7d8e8b3 + 752debd commit f157bc4
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 293 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:

- name: Get changed files
id: changed-files-specific
uses: tj-actions/changed-files@v36
uses: tj-actions/changed-files@v37
with:
files: |
composer.*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: bash ./run_unit_tests.sh

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1.40
uses: EnricoMi/publish-unit-test-result-action@v2.7
if: always()
continue-on-error: true
with:
Expand Down
4 changes: 0 additions & 4 deletions app/code/core/Mage/Checkout/controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ public function addAction()
}
} catch (Exception $e) {
$this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
Mage::logException($e);
$this->_goBack();
}
}
Expand Down Expand Up @@ -299,7 +298,6 @@ public function addgroupAction()
}
} catch (Exception $e) {
$this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
Mage::logException($e);
$this->_goBack();
}
}
Expand Down Expand Up @@ -418,7 +416,6 @@ public function updateItemOptionsAction()
}
} catch (Exception $e) {
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
Mage::logException($e);
$this->_goBack();
}
$this->_redirect('*/*');
Expand Down Expand Up @@ -480,7 +477,6 @@ protected function _updateShoppingCart()
$this->_getSession()->addError(Mage::helper('core')->escapeHtml($e->getMessage()));
} catch (Exception $e) {
$this->_getSession()->addException($e, $this->__('Cannot update shopping cart.'));
Mage::logException($e);
}
}

Expand Down
215 changes: 7 additions & 208 deletions app/code/core/Mage/GoogleAnalytics/Block/Ga.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,6 @@
*/
class Mage_GoogleAnalytics_Block_Ga extends Mage_Core_Block_Template
{
/**
* @deprecated after 1.4.1.1
* @see self::_getOrdersTrackingCode()
* @return string
*/
public function getQuoteOrdersHtml()
{
return '';
}

/**
* @deprecated after 1.4.1.1
* self::_getOrdersTrackingCode()
* @return string
*/
public function getOrderHtml()
{
return '';
}

/**
* @deprecated after 1.4.1.1
* @see _toHtml()
* @return string
*/
public function getAccount()
{
return '';
}

/**
* Get a specific page name (may be customized via layout)
*
* @return string
* @deprecated
*/
public function getPageName()
{
return $this->_getData('page_name') ?? '';
}

/**
* Render regular page tracking javascript code
* The custom "page name" may be set from layout or somewhere else. It must start from slash.
Expand All @@ -75,11 +34,9 @@ protected function _getPageTrackingCode($accountId)
$helper = $this->helper('googleanalytics');
if ($helper->isUseAnalytics4()) {
return $this->_getPageTrackingCodeAnalytics4($accountId);
} elseif ($helper->isUseUniversalAnalytics()) {
return $this->_getPageTrackingCodeUniversal($accountId);
} else {
return $this->_getPageTrackingCodeAnalytics($accountId);
}

return '';
}

/**
Expand Down Expand Up @@ -125,14 +82,11 @@ protected function _getPageTrackingCodeAnalytics4($accountId)
*
* @param string $accountId
* @return string
* @deprecated
*/
protected function _getPageTrackingCodeUniversal($accountId)
{
return "
ga('create', '{$this->jsQuoteEscape($accountId)}', 'auto');
" . $this->_getAnonymizationCode() . "
ga('send', 'pageview');
";
return '';
}

/**
Expand All @@ -143,19 +97,11 @@ protected function _getPageTrackingCodeUniversal($accountId)
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gaq.html
* @param string $accountId
* @return string
* @deprecated
*/
protected function _getPageTrackingCodeAnalytics($accountId)
{
$pageName = trim($this->getPageName());
$optPageURL = '';
if ($pageName && preg_match('/^\/.*/i', $pageName)) {
$optPageURL = ", '{$this->jsQuoteEscape($pageName)}'";
}
return "
_gaq.push(['_setAccount', '{$this->jsQuoteEscape($accountId)}']);
" . $this->_getAnonymizationCode() . "
_gaq.push(['_trackPageview'{$optPageURL}]);
";
return '';
}

/**
Expand All @@ -170,65 +116,9 @@ protected function _getOrdersTrackingCode()
$helper = $this->helper('googleanalytics');
if ($helper->isUseAnalytics4()) {
return $this->_getOrdersTrackingCodeAnalytics4();
} elseif ($helper->isUseUniversalAnalytics()) {
return $this->_getOrdersTrackingCodeUniversal();
}

return $this->_getOrdersTrackingCodeAnalytics();
}

/**
* Render information about specified orders and their items
*
* @return string
* @throws Mage_Core_Model_Store_Exception
*/
protected function _getOrdersTrackingCodeUniversal()
{
$orderIds = $this->getOrderIds();
if (empty($orderIds) || !is_array($orderIds)) {
return;
}
$collection = Mage::getResourceModel('sales/order_collection')
->addFieldToFilter('entity_id', ['in' => $orderIds]);
$result = [];
$result[] = "ga('require', 'ecommerce')";
foreach ($collection as $order) {
$result[] = sprintf(
"ga('ecommerce:addTransaction', {
'id': '%s',
'affiliation': '%s',
'revenue': '%s',
'tax': '%s',
'shipping': '%s'
});",
$order->getIncrementId(),
$this->jsQuoteEscape(Mage::app()->getStore()->getFrontendName()),
$order->getBaseGrandTotal(),
$order->getBaseTaxAmount(),
$order->getBaseShippingAmount()
);
foreach ($order->getAllVisibleItems() as $item) {
$result[] = sprintf(
"ga('ecommerce:addItem', {
'id': '%s',
'sku': '%s',
'name': '%s',
'category': '%s',
'price': '%s',
'quantity': '%s'
});",
$order->getIncrementId(),
$this->jsQuoteEscape($item->getSku()),
$this->jsQuoteEscape($item->getName()),
null, // there is no "category" defined for the order item
$item->getBasePrice(),
$item->getQtyOrdered()
);
}
$result[] = "ga('ecommerce:send');";
}
return implode("\n", $result);
return '';
}

/**
Expand Down Expand Up @@ -501,97 +391,6 @@ protected function _getOrdersTrackingCodeAnalytics4()
}

/**
* Render information about specified orders and their items
*
* @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addTrans
* @return string
* @throws Mage_Core_Model_Store_Exception
*/
protected function _getOrdersTrackingCodeAnalytics()
{
$orderIds = $this->getOrderIds();
if (empty($orderIds) || !is_array($orderIds)) {
return;
}
$collection = Mage::getResourceModel('sales/order_collection')
->addFieldToFilter('entity_id', ['in' => $orderIds]);
$result = [];
foreach ($collection as $order) {
if ($order->getIsVirtual()) {
$address = $order->getBillingAddress();
} else {
$address = $order->getShippingAddress();
}
$result[] = sprintf(
"_gaq.push(['_addTrans', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s']);",
$order->getIncrementId(),
$this->jsQuoteEscape(Mage::app()->getStore()->getFrontendName()),
$order->getBaseGrandTotal(),
$order->getBaseTaxAmount(),
$order->getBaseShippingAmount(),
$this->jsQuoteEscape(Mage::helper('core')->escapeHtml($address->getCity())),
$this->jsQuoteEscape(Mage::helper('core')->escapeHtml($address->getRegion())),
$this->jsQuoteEscape(Mage::helper('core')->escapeHtml($address->getCountry()))
);
foreach ($order->getAllVisibleItems() as $item) {
$result[] = sprintf(
"_gaq.push(['_addItem', '%s', '%s', '%s', '%s', '%s', '%s']);",
$order->getIncrementId(),
$this->jsQuoteEscape($item->getSku()),
$this->jsQuoteEscape($item->getName()),
null, // there is no "category" defined for the order item
$item->getBasePrice(),
$item->getQtyOrdered()
);
}
$result[] = "_gaq.push(['_trackTrans']);";
}
return implode("\n", $result);
}

/**
* Render IP anonymization code for page tracking javascript code
*
* @return string
*/
protected function _getAnonymizationCode()
{
if (!Mage::helper('googleanalytics')->isIpAnonymizationEnabled()) {
return '';
}

/** @var Mage_GoogleAnalytics_Helper_Data $helper */
$helper = $this->helper('googleanalytics');
if ($helper->isUseUniversalAnalytics()) {
return $this->_getAnonymizationCodeUniversal();
}

return $this->_getAnonymizationCodeAnalytics();
}

/**
* Render IP anonymization code for page tracking javascript universal analytics code
*
* @return string
*/
protected function _getAnonymizationCodeUniversal()
{
return "ga('set', 'anonymizeIp', true);";
}

/**
* Render IP anonymization code for page tracking javascript google analytics code
*
* @return string
*/
protected function _getAnonymizationCodeAnalytics()
{
return "_gaq.push (['_gat._anonymizeIp']);";
}

/**
* Is ga available
*
* @return bool
*/
protected function _isAvailable()
Expand Down
17 changes: 4 additions & 13 deletions app/code/core/Mage/GoogleAnalytics/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
public const XML_PATH_ACTIVE = 'google/analytics/active';
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';

Expand All @@ -37,17 +36,8 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
public const TYPE_ANALYTICS4 = 'analytics4';

/**
* @var string classic google analytics tracking code
* @deprecated
* @var string
*/
public const TYPE_ANALYTICS = 'analytics';

/**
* @var string google analytics universal tracking code
* @deprecated
*/
public const TYPE_UNIVERSAL = 'universal';

protected $_moduleName = 'Mage_GoogleAnalytics';

/**
Expand All @@ -67,10 +57,11 @@ public function isGoogleAnalyticsAvailable($store = null)
*
* @param null|string|bool|int|Mage_Core_Model_Store $store $store
* @return bool
* @deprecated
*/
public function isIpAnonymizationEnabled($store = null)
{
return Mage::getStoreConfigFlag(self::XML_PATH_ANONYMIZATION, $store);
return false;
}

/**
Expand All @@ -93,7 +84,7 @@ public function getAccountId($store = null)
*/
public function isUseUniversalAnalytics($store = null)
{
return Mage::getStoreConfig(self::XML_PATH_TYPE, $store) == self::TYPE_UNIVERSAL;
return false;
}

/**
Expand Down
12 changes: 0 additions & 12 deletions app/code/core/Mage/GoogleAnalytics/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@
*/
class Mage_GoogleAnalytics_Model_Observer
{
/**
* Create Google Analytics block for success page view
*
* @deprecated after 1.3.2.3 Use setGoogleAnalyticsOnOrderSuccessPageView() method instead
* @param Varien_Event_Observer $observer
*/
// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
public function order_success_page_view($observer)
{
$this->setGoogleAnalyticsOnOrderSuccessPageView($observer);
}

/**
* Add order information into GA block to render on checkout success pages
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ public function toOptionArray()
[
'value' => Mage_GoogleAnalytics_Helper_Data::TYPE_ANALYTICS4,
'label' => Mage::helper('googleanalytics')->__('Google Analytics 4')
],
[
'value' => Mage_GoogleAnalytics_Helper_Data::TYPE_ANALYTICS,
'label' => Mage::helper('googleanalytics')->__('Google Analytics')
],
[
'value' => Mage_GoogleAnalytics_Helper_Data::TYPE_UNIVERSAL,
'label' => Mage::helper('googleanalytics')->__('Universal Analytics')
]
];
}
Expand Down
Loading

0 comments on commit f157bc4

Please sign in to comment.