Skip to content

Commit 80dae5c

Browse files
committed
Merge branch 'main' into next
2 parents eaca57c + 2764d0c commit 80dae5c

File tree

15 files changed

+174
-85
lines changed

15 files changed

+174
-85
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ not compatible with the new implementations made by ZF1-Future, which is much mo
264264
This may generate a problem with `Zend_Db_Select' statements that do not use 'Zend_Db_Expr' to quote expressions.
265265
If you see SQL errors after upgrading please remember to check for this specific issue in your code.
266266

267+
UPS shut down their old CGI APIs so we removed the support for it from the Mage_Usa module.
268+
267269
### New Config Options
268270

269271
- `admin/design/use_legacy_theme`

app/Mage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static function getOpenMageVersionInfo(): array
217217
'major' => '20',
218218
'minor' => '1',
219219
'patch' => '0',
220-
'stability' => 'rc6', // beta,alpha,rc
220+
'stability' => 'rc7', // beta,alpha,rc
221221
'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9
222222
];
223223
}
@@ -226,7 +226,7 @@ public static function getOpenMageVersionInfo(): array
226226
'major' => '19',
227227
'minor' => '5',
228228
'patch' => '0',
229-
'stability' => 'rc6', // beta,alpha,rc
229+
'stability' => 'rc7', // beta,alpha,rc
230230
'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9
231231
];
232232
}

app/code/core/Mage/Checkout/etc/system.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<fields>
8181
<delete_quote_after translate="label">
8282
<label>Quote Lifetime (days)</label>
83+
<validate>validate-not-negative-number</validate>
8384
<sort_order>1</sort_order>
8485
<show_in_default>1</show_in_default>
8586
<show_in_website>1</show_in_website>

app/code/core/Mage/GoogleAnalytics/Block/Ga.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,10 @@ protected function _getPageTrackingCodeAnalytics($accountId)
109109
*
110110
* @return string
111111
* @throws Mage_Core_Model_Store_Exception
112+
* @deprecated
112113
*/
113114
protected function _getOrdersTrackingCode()
114115
{
115-
/** @var Mage_GoogleAnalytics_Helper_Data $helper */
116-
$helper = $this->helper('googleanalytics');
117-
if ($helper->isUseAnalytics4()) {
118-
return $this->_getOrdersTrackingCodeAnalytics4();
119-
}
120-
121116
return '';
122117
}
123118

@@ -127,7 +122,7 @@ protected function _getOrdersTrackingCode()
127122
* @return string
128123
* @throws JsonException
129124
*/
130-
protected function _getOrdersTrackingCodeAnalytics4()
125+
protected function _getEnhancedEcommerceDataForAnalytics4()
131126
{
132127
$result = [];
133128
$request = $this->getRequest();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* OpenMage
4+
*
5+
* This source file is subject to the Open Software License (OSL 3.0)
6+
* that is bundled with this package in the file LICENSE.txt.
7+
* It is also available at https://opensource.org/license/osl-3-0-php
8+
*
9+
* @category Mage
10+
* @package Mage_GoogleAnalytics
11+
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
12+
* @copyright Copyright (c) 2022 The OpenMage Contributors (https://www.openmage.org)
13+
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14+
*/
15+
16+
/**
17+
* GoogleTagManager Page Block
18+
*
19+
* @category Mage
20+
* @package Mage_GoogleAnalytics
21+
*/
22+
class Mage_GoogleAnalytics_Block_Gtm extends Mage_Core_Block_Template
23+
{
24+
/**
25+
* @return bool
26+
*/
27+
protected function _isAvailable()
28+
{
29+
return Mage::helper('googleanalytics')->isGoogleTagManagerAvailable();
30+
}
31+
32+
/**
33+
* Render GA tracking scripts
34+
*
35+
* @return string
36+
*/
37+
protected function _toHtml()
38+
{
39+
if (!$this->_isAvailable()) {
40+
return '';
41+
}
42+
return parent::_toHtml();
43+
}
44+
}

app/code/core/Mage/GoogleAnalytics/Helper/Data.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
3030
public const XML_PATH_DEBUG = 'google/analytics/debug';
3131
public const XML_PATH_USERID = 'google/analytics/user_id';
3232

33+
public const XML_PATH_GTM_ACTIVE = 'google/gtm/active';
34+
public const XML_PATH_GTM_CONTAINER_ID = 'google/gtm/container_id';
35+
3336
/**
3437
* @var string google analytics 4
3538
*/
@@ -40,6 +43,18 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
4043
*/
4144
protected $_moduleName = 'Mage_GoogleAnalytics';
4245

46+
/**
47+
* Whether GTM is ready to use
48+
*
49+
* @param mixed $store
50+
* @return bool
51+
*/
52+
public function isGoogleTagManagerAvailable($store = null)
53+
{
54+
$containerId = Mage::getStoreConfig(self::XML_PATH_GTM_CONTAINER_ID, $store);
55+
return $containerId && Mage::getStoreConfigFlag(self::XML_PATH_GTM_ACTIVE, $store);
56+
}
57+
4358
/**
4459
* Whether GA is ready to use
4560
*
@@ -75,6 +90,17 @@ public function getAccountId($store = null)
7590
return Mage::getStoreConfig(self::XML_PATH_ACCOUNT, $store);
7691
}
7792

93+
/**
94+
* Get GTM account id
95+
*
96+
* @param string $store
97+
* @return string
98+
*/
99+
public function getGoogleTagManagerContainerId($store = null)
100+
{
101+
return Mage::getStoreConfig(self::XML_PATH_GTM_CONTAINER_ID, $store);
102+
}
103+
78104
/**
79105
* Returns true if should use Google Universal Analytics
80106
*
@@ -87,6 +113,17 @@ public function isUseUniversalAnalytics($store = null)
87113
return false;
88114
}
89115

116+
/**
117+
* Returns true if should use Google Tag Manager
118+
*
119+
* @param string $store
120+
* @return bool
121+
*/
122+
public function isUseGoogleTagManager($store = null)
123+
{
124+
return Mage::getStoreConfigFlag(self::XML_PATH_GTM_ACTIVE, $store);
125+
}
126+
90127
/**
91128
* Returns true if should use Google Universal Analytics 4
92129
*

app/code/core/Mage/GoogleAnalytics/etc/system.xml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,31 @@
2424
<show_in_website>1</show_in_website>
2525
<show_in_store>1</show_in_store>
2626
<groups>
27+
<gtm translate="label">
28+
<label>Google Tag Manager</label>
29+
<sort_order>10</sort_order>
30+
<show_in_default>1</show_in_default>
31+
<show_in_website>1</show_in_website>
32+
<show_in_store>1</show_in_store>
33+
<fields>
34+
<active translate="label">
35+
<label>Enable</label>
36+
<frontend_type>select</frontend_type>
37+
<source_model>adminhtml/system_config_source_yesno</source_model>
38+
<sort_order>10</sort_order>
39+
<show_in_default>1</show_in_default>
40+
<show_in_website>1</show_in_website>
41+
<show_in_store>1</show_in_store>
42+
</active>
43+
<container_id translate="label">
44+
<label>Container ID</label>
45+
<sort_order>20</sort_order>
46+
<show_in_default>1</show_in_default>
47+
<show_in_website>1</show_in_website>
48+
<show_in_store>1</show_in_store>
49+
</container_id>
50+
</fields>
51+
</gtm>
2752
<analytics translate="label">
2853
<label>Google Analytics</label>
2954
<sort_order>10</sort_order>
@@ -83,18 +108,6 @@
83108
<type>analytics4</type>
84109
</depends>
85110
</debug>
86-
<anonymization translate="label">
87-
<label>Enable IP anonymization</label>
88-
<frontend_type>select</frontend_type>
89-
<source_model>adminhtml/system_config_source_yesno</source_model>
90-
<sort_order>30</sort_order>
91-
<show_in_default>1</show_in_default>
92-
<show_in_website>1</show_in_website>
93-
<show_in_store>1</show_in_store>
94-
<depends>
95-
<type>universal</type>
96-
</depends>
97-
</anonymization>
98111
</fields>
99112
</analytics>
100113
</groups>

app/code/core/Mage/Sales/Model/Observer.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,27 @@ class Mage_Sales_Model_Observer
3838
public function cleanExpiredQuotes($schedule)
3939
{
4040
Mage::dispatchEvent('clear_expired_quotes_before', ['sales_observer' => $this]);
41-
4241
$lifetimes = Mage::getConfig()->getStoresConfigByPath('checkout/cart/delete_quote_after');
43-
foreach ($lifetimes as $storeId => $lifetime) {
44-
$lifetime = (int)$lifetime * 86400;
4542

46-
/** @var Mage_Sales_Model_Resource_Quote_Collection $quotes */
47-
$quotes = Mage::getModel('sales/quote')->getCollection();
43+
foreach ($lifetimes as $storeId => $day) {
44+
$day = (int) $day;
45+
$lifetime = 86400 * $day;
4846

47+
/** @var Mage_Sales_Model_Resource_Quote_Collection $quotes */
48+
$quotes = Mage::getResourceModel('sales/quote_collection');
4949
$quotes->addFieldToFilter('store_id', $storeId);
50-
$quotes->addFieldToFilter('updated_at', ['to' => date("Y-m-d", time() - $lifetime)]);
51-
$quotes->addFieldToFilter('is_active', 0);
50+
$quotes->addFieldToFilter('updated_at', ['to' => date('Y-m-d', time() - $lifetime)]);
51+
if ($day == 0) {
52+
$quotes->addFieldToFilter('is_active', 0);
53+
}
5254

5355
foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) {
5456
$quotes->addFieldToFilter($field, $condition);
5557
}
5658

5759
$quotes->walk('delete');
5860
}
61+
5962
return $this;
6063
}
6164

app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,6 @@ public function getResult()
305305
protected function _getQuotes()
306306
{
307307
switch ($this->getConfigData('type')) {
308-
case 'UPS':
309-
return $this->_getCgiQuotes();
310-
311308
case 'UPS_XML':
312309
return $this->_getXmlQuotes();
313310
}
@@ -1058,9 +1055,7 @@ public function getTracking($trackings)
10581055
$trackings = [$trackings];
10591056
}
10601057

1061-
if ($this->getConfigData('type') == 'UPS') {
1062-
$this->_getCgiTracking($trackings);
1063-
} elseif ($this->getConfigData('type') == 'UPS_XML') {
1058+
if ($this->getConfigData('type') == 'UPS_XML') {
10641059
$this->setXMLAccessRequest();
10651060
$this->_getXmlTracking($trackings);
10661061
}

app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups/Source/Type.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class Mage_Usa_Model_Shipping_Carrier_Ups_Source_Type
2525
public function toOptionArray()
2626
{
2727
return [
28-
['value' => 'UPS', 'label' => Mage::helper('usa')->__('United Parcel Service')],
29-
#array('value' => Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_ORDER, 'label' => Mage::helper('usa')->__('Order')),
3028
['value' => 'UPS_XML', 'label' => Mage::helper('usa')->__('United Parcel Service XML')],
3129
];
3230
}

app/code/core/Mage/Usa/etc/config.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@
154154
<cutoff_cost/>
155155
<dest_type>RES</dest_type>
156156
<free_method>GND</free_method>
157-
<gateway_url>http://www.ups.com/using/services/rave/qcostcgi.cgi</gateway_url>
158157
<gateway_xml_url>https://onlinetools.ups.com/ups.app/xml/Rate</gateway_xml_url>
159158
<tracking_xml_url>https://onlinetools.ups.com/ups.app/xml/Track</tracking_xml_url>
160159
<shipconfirm_xml_url>https://onlinetools.ups.com/ups.app/xml/ShipConfirm</shipconfirm_xml_url>

app/design/frontend/base/default/layout/googleanalytics.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Default layout, loads most of the pages
2323
<default>
2424
<!-- Mage_GoogleAnalytics -->
2525
<reference name="head" before="-">
26+
<block type="googleanalytics/gtm" name="google_tag_manager" as="google_tag_manager" template="googleanalytics/gtm.phtml" />
2627
<block type="googleanalytics/ga" name="google_analytics" as="google_analytics" template="googleanalytics/ga.phtml" />
2728
</reference>
2829
</default>

app/design/frontend/base/default/template/googleanalytics/ga.phtml

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,50 +16,18 @@
1616
<?php
1717
/** @var Mage_GoogleAnalytics_Block_Ga $this */
1818
$_helper = $this->helper('googleanalytics');
19-
$_accountId = $_helper->getAccountId();
2019
?>
2120
<?php if (!$this->helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
2221
<?php if ($_helper->isUseAnalytics4()): ?>
22+
<?php $_gaAccountId = $_helper->getAccountId() ?>
2323
<!-- BEGIN GOOGLE ANALYTICS 4 CODE -->
24-
<script async src="https://www.googletagmanager.com/gtag/js?id=<?= $_accountId ?>"></script>
24+
<script async src="https://www.googletagmanager.com/gtag/js?id=<?= $_gaAccountId ?>"></script>
2525
<script>
2626
window.dataLayer = window.dataLayer || [];
2727
function gtag(){dataLayer.push(arguments);}
28-
<?php echo $this->_getPageTrackingCode($_accountId) ?>
29-
<?php echo $this->_getOrdersTrackingCodeAnalytics4() ?>
28+
<?php echo $this->_getPageTrackingCode($_gaAccountId) ?>
29+
<?php echo $this->_getEnhancedEcommerceDataForAnalytics4() ?>
3030
</script>
3131
<!-- END GOOGLE ANALYTICS 4 CODE -->
32-
<?php elseif ($_helper->isUseUniversalAnalytics()): ?>
33-
<!-- BEGIN GOOGLE UNIVERSAL ANALYTICS CODE -->
34-
<script type="text/javascript">
35-
//<![CDATA[
36-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
37-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
38-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
39-
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
40-
41-
<?php echo $this->_getPageTrackingCode($_accountId) ?>
42-
<?php echo $this->_getOrdersTrackingCode() ?>
43-
44-
//]]>
45-
</script>
46-
<!-- END GOOGLE UNIVERSAL ANALYTICS CODE -->
47-
<?php else: ?>
48-
<!-- BEGIN GOOGLE ANALYTICS CODE -->
49-
<script type="text/javascript">
50-
//<![CDATA[
51-
var _gaq = _gaq || [];
52-
<?php echo $this->_getPageTrackingCode($_accountId) ?>
53-
<?php echo $this->_getOrdersTrackingCode() ?>
54-
55-
(function() {
56-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
57-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
58-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
59-
})();
60-
61-
//]]>
62-
</script>
63-
<!-- END GOOGLE ANALYTICS CODE -->
6432
<?php endif ?>
6533
<?php endif ?>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* OpenMage
4+
*
5+
* This source file is subject to the Academic Free License (AFL 3.0)
6+
* that is bundled with this package in the file LICENSE_AFL.txt.
7+
* It is also available at https://opensource.org/license/afl-3-0-php
8+
*
9+
* @category design
10+
* @package base_default
11+
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
12+
* @copyright Copyright (c) 2021 The OpenMage Contributors (https://www.openmage.org)
13+
* @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
14+
*/
15+
?>
16+
<?php
17+
/** @var Mage_GoogleAnalytics_Block_Gtm $this */
18+
$_helper = $this->helper('googleanalytics');
19+
?>
20+
<?php if (!$this->helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
21+
<?php if ($_helper->isUseGoogleTagManager()): ?>
22+
<?php $_gtmAccountId = $_helper->getGoogleTagManagerContainerId() ?>
23+
<!-- BEGIN GOOGLE TAG MANAGER CODE -->
24+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
25+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
26+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
27+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
28+
})(window,document,'script','dataLayer','<?= $_gtmAccountId ?>');</script>
29+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<?= $_gtmAccountId ?>"
30+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
31+
<!-- END GOOGLE TAG MANAGER CODE -->
32+
<?php endif ?>
33+
<?php endif ?>

0 commit comments

Comments
 (0)