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 Jul 3, 2023
2 parents eaca57c + 2764d0c commit 80dae5c
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 85 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ not compatible with the new implementations made by ZF1-Future, which is much mo
This may generate a problem with `Zend_Db_Select' statements that do not use 'Zend_Db_Expr' to quote expressions.
If you see SQL errors after upgrading please remember to check for this specific issue in your code.

UPS shut down their old CGI APIs so we removed the support for it from the Mage_Usa module.

### New Config Options

- `admin/design/use_legacy_theme`
Expand Down
4 changes: 2 additions & 2 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public static function getOpenMageVersionInfo(): array
'major' => '20',
'minor' => '1',
'patch' => '0',
'stability' => 'rc6', // beta,alpha,rc
'stability' => 'rc7', // beta,alpha,rc
'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9
];
}
Expand All @@ -226,7 +226,7 @@ public static function getOpenMageVersionInfo(): array
'major' => '19',
'minor' => '5',
'patch' => '0',
'stability' => 'rc6', // beta,alpha,rc
'stability' => 'rc7', // beta,alpha,rc
'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9
];
}
Expand Down
1 change: 1 addition & 0 deletions app/code/core/Mage/Checkout/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<fields>
<delete_quote_after translate="label">
<label>Quote Lifetime (days)</label>
<validate>validate-not-negative-number</validate>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
Expand Down
9 changes: 2 additions & 7 deletions app/code/core/Mage/GoogleAnalytics/Block/Ga.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,10 @@ protected function _getPageTrackingCodeAnalytics($accountId)
*
* @return string
* @throws Mage_Core_Model_Store_Exception
* @deprecated
*/
protected function _getOrdersTrackingCode()
{
/** @var Mage_GoogleAnalytics_Helper_Data $helper */
$helper = $this->helper('googleanalytics');
if ($helper->isUseAnalytics4()) {
return $this->_getOrdersTrackingCodeAnalytics4();
}

return '';
}

Expand All @@ -127,7 +122,7 @@ protected function _getOrdersTrackingCode()
* @return string
* @throws JsonException
*/
protected function _getOrdersTrackingCodeAnalytics4()
protected function _getEnhancedEcommerceDataForAnalytics4()
{
$result = [];
$request = $this->getRequest();
Expand Down
44 changes: 44 additions & 0 deletions app/code/core/Mage/GoogleAnalytics/Block/Gtm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* OpenMage
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available at https://opensource.org/license/osl-3-0-php
*
* @category Mage
* @package Mage_GoogleAnalytics
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2022 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* GoogleTagManager Page Block
*
* @category Mage
* @package Mage_GoogleAnalytics
*/
class Mage_GoogleAnalytics_Block_Gtm extends Mage_Core_Block_Template
{
/**
* @return bool
*/
protected function _isAvailable()
{
return Mage::helper('googleanalytics')->isGoogleTagManagerAvailable();
}

/**
* Render GA tracking scripts
*
* @return string
*/
protected function _toHtml()
{
if (!$this->_isAvailable()) {
return '';
}
return parent::_toHtml();
}
}
37 changes: 37 additions & 0 deletions app/code/core/Mage/GoogleAnalytics/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
public const XML_PATH_DEBUG = 'google/analytics/debug';
public const XML_PATH_USERID = 'google/analytics/user_id';

public const XML_PATH_GTM_ACTIVE = 'google/gtm/active';
public const XML_PATH_GTM_CONTAINER_ID = 'google/gtm/container_id';

/**
* @var string google analytics 4
*/
Expand All @@ -40,6 +43,18 @@ class Mage_GoogleAnalytics_Helper_Data extends Mage_Core_Helper_Abstract
*/
protected $_moduleName = 'Mage_GoogleAnalytics';

/**
* Whether GTM is ready to use
*
* @param mixed $store
* @return bool
*/
public function isGoogleTagManagerAvailable($store = null)
{
$containerId = Mage::getStoreConfig(self::XML_PATH_GTM_CONTAINER_ID, $store);
return $containerId && Mage::getStoreConfigFlag(self::XML_PATH_GTM_ACTIVE, $store);
}

/**
* Whether GA is ready to use
*
Expand Down Expand Up @@ -75,6 +90,17 @@ public function getAccountId($store = null)
return Mage::getStoreConfig(self::XML_PATH_ACCOUNT, $store);
}

/**
* Get GTM account id
*
* @param string $store
* @return string
*/
public function getGoogleTagManagerContainerId($store = null)
{
return Mage::getStoreConfig(self::XML_PATH_GTM_CONTAINER_ID, $store);
}

/**
* Returns true if should use Google Universal Analytics
*
Expand All @@ -87,6 +113,17 @@ public function isUseUniversalAnalytics($store = null)
return false;
}

/**
* Returns true if should use Google Tag Manager
*
* @param string $store
* @return bool
*/
public function isUseGoogleTagManager($store = null)
{
return Mage::getStoreConfigFlag(self::XML_PATH_GTM_ACTIVE, $store);
}

/**
* Returns true if should use Google Universal Analytics 4
*
Expand Down
37 changes: 25 additions & 12 deletions app/code/core/Mage/GoogleAnalytics/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<gtm translate="label">
<label>Google Tag Manager</label>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<active translate="label">
<label>Enable</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</active>
<container_id translate="label">
<label>Container ID</label>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</container_id>
</fields>
</gtm>
<analytics translate="label">
<label>Google Analytics</label>
<sort_order>10</sort_order>
Expand Down Expand Up @@ -83,18 +108,6 @@
<type>analytics4</type>
</depends>
</debug>
<anonymization translate="label">
<label>Enable IP anonymization</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>30</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<type>universal</type>
</depends>
</anonymization>
</fields>
</analytics>
</groups>
Expand Down
17 changes: 10 additions & 7 deletions app/code/core/Mage/Sales/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,27 @@ class Mage_Sales_Model_Observer
public function cleanExpiredQuotes($schedule)
{
Mage::dispatchEvent('clear_expired_quotes_before', ['sales_observer' => $this]);

$lifetimes = Mage::getConfig()->getStoresConfigByPath('checkout/cart/delete_quote_after');
foreach ($lifetimes as $storeId => $lifetime) {
$lifetime = (int)$lifetime * 86400;

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

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

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

$quotes->walk('delete');
}

return $this;
}

Expand Down
7 changes: 1 addition & 6 deletions app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@ public function getResult()
protected function _getQuotes()
{
switch ($this->getConfigData('type')) {
case 'UPS':
return $this->_getCgiQuotes();

case 'UPS_XML':
return $this->_getXmlQuotes();
}
Expand Down Expand Up @@ -1058,9 +1055,7 @@ public function getTracking($trackings)
$trackings = [$trackings];
}

if ($this->getConfigData('type') == 'UPS') {
$this->_getCgiTracking($trackings);
} elseif ($this->getConfigData('type') == 'UPS_XML') {
if ($this->getConfigData('type') == 'UPS_XML') {
$this->setXMLAccessRequest();
$this->_getXmlTracking($trackings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class Mage_Usa_Model_Shipping_Carrier_Ups_Source_Type
public function toOptionArray()
{
return [
['value' => 'UPS', 'label' => Mage::helper('usa')->__('United Parcel Service')],
#array('value' => Mage_Paypal_Model_Api_Abstract::PAYMENT_TYPE_ORDER, 'label' => Mage::helper('usa')->__('Order')),
['value' => 'UPS_XML', 'label' => Mage::helper('usa')->__('United Parcel Service XML')],
];
}
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Usa/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
<cutoff_cost/>
<dest_type>RES</dest_type>
<free_method>GND</free_method>
<gateway_url>http://www.ups.com/using/services/rave/qcostcgi.cgi</gateway_url>
<gateway_xml_url>https://onlinetools.ups.com/ups.app/xml/Rate</gateway_xml_url>
<tracking_xml_url>https://onlinetools.ups.com/ups.app/xml/Track</tracking_xml_url>
<shipconfirm_xml_url>https://onlinetools.ups.com/ups.app/xml/ShipConfirm</shipconfirm_xml_url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Default layout, loads most of the pages
<default>
<!-- Mage_GoogleAnalytics -->
<reference name="head" before="-">
<block type="googleanalytics/gtm" name="google_tag_manager" as="google_tag_manager" template="googleanalytics/gtm.phtml" />
<block type="googleanalytics/ga" name="google_analytics" as="google_analytics" template="googleanalytics/ga.phtml" />
</reference>
</default>
Expand Down
40 changes: 4 additions & 36 deletions app/design/frontend/base/default/template/googleanalytics/ga.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,18 @@
<?php
/** @var Mage_GoogleAnalytics_Block_Ga $this */
$_helper = $this->helper('googleanalytics');
$_accountId = $_helper->getAccountId();
?>
<?php if (!$this->helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
<?php if ($_helper->isUseAnalytics4()): ?>
<?php $_gaAccountId = $_helper->getAccountId() ?>
<!-- BEGIN GOOGLE ANALYTICS 4 CODE -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?= $_accountId ?>"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=<?= $_gaAccountId ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
<?php echo $this->_getPageTrackingCode($_accountId) ?>
<?php echo $this->_getOrdersTrackingCodeAnalytics4() ?>
<?php echo $this->_getPageTrackingCode($_gaAccountId) ?>
<?php echo $this->_getEnhancedEcommerceDataForAnalytics4() ?>
</script>
<!-- END GOOGLE ANALYTICS 4 CODE -->
<?php elseif ($_helper->isUseUniversalAnalytics()): ?>
<!-- BEGIN GOOGLE UNIVERSAL ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

<?php echo $this->_getPageTrackingCode($_accountId) ?>
<?php echo $this->_getOrdersTrackingCode() ?>

//]]>
</script>
<!-- END GOOGLE UNIVERSAL ANALYTICS CODE -->
<?php else: ?>
<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];
<?php echo $this->_getPageTrackingCode($_accountId) ?>
<?php echo $this->_getOrdersTrackingCode() ?>

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->
<?php endif ?>
<?php endif ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* OpenMage
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available at https://opensource.org/license/afl-3-0-php
*
* @category design
* @package base_default
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2021 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/** @var Mage_GoogleAnalytics_Block_Gtm $this */
$_helper = $this->helper('googleanalytics');
?>
<?php if (!$this->helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
<?php if ($_helper->isUseGoogleTagManager()): ?>
<?php $_gtmAccountId = $_helper->getGoogleTagManagerContainerId() ?>
<!-- BEGIN GOOGLE TAG MANAGER CODE -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','<?= $_gtmAccountId ?>');</script>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<?= $_gtmAccountId ?>"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- END GOOGLE TAG MANAGER CODE -->
<?php endif ?>
<?php endif ?>
Loading

0 comments on commit 80dae5c

Please sign in to comment.