Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/3.6.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannu Pölönen committed Apr 25, 2018
2 parents 9e4d6ad + faebe9a commit c20ac7b
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

### 3.6.4
* Fix the issue with additional URL parameters being escaped in restore cart redirection URL
* Add setting for choosing the redirect location after cart has been restored

### 3.6.3
* Fix the issue that the price of discounted bundle products could be tagged as 0

Expand Down
17 changes: 17 additions & 0 deletions app/code/community/Nosto/Tagging/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ class Nosto_Tagging_Helper_Data extends Mage_Core_Helper_Abstract
*/
const XML_PATH_USE_SKUS = 'nosto_tagging/general/use_skus';

/**
* Path to store config for restore cart redirection
*/
const XML_PATH_RESTORE_CART_LOCATION = 'nosto_tagging/general/restore_cart_location';

/**
* Path to store config for custom fields
*/
Expand Down Expand Up @@ -638,6 +643,18 @@ public function getRatingsAndReviewsProvider($store = null)
return Mage::getStoreConfig(self::XML_PATH_RATING_PROVIDER, $store);
}

/**
* Return the restore cart redirect location
*
* @param Mage_Core_Model_Store|null $store the store model or null.
*
* @return string
*/
public function getRestoreCartRedirectLocation($store = null)
{
return Mage::getStoreConfig(self::XML_PATH_RESTORE_CART_LOCATION, $store);
}

/**
* Set the ratings and reviews provider
*
Expand Down
59 changes: 59 additions & 0 deletions app/code/community/Nosto/Tagging/Helper/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ class Nosto_Tagging_Helper_Url extends Mage_Core_Helper_Abstract
*/
const MAGENTO_PATH_CART = 'checkout/cart';

/**
* Path to Magento's one page checkout
*/
const MAGENTO_PATH_ONEPAGE_CHEKOUT = 'checkout/onepage';

/**
* Path to Magento's add to cart controller
*/
Expand Down Expand Up @@ -547,4 +552,58 @@ public function getAdminNostoConfiguratioUrl(Mage_Core_Model_Store $store)

return $adminHtmlHelper->getUrl(self::URL_PATH_NOSTO_CONFIG, $params);
}

/**
* Returns the current URL and reverts the htmlspecialchars
* for Magento's Mage_Core_Helper_Url::getCurrentUrl() bug
*
* @return string
*/
public function getCurrentUrl()
{
/* @var Mage_Core_Helper_Url $mageUrlHelper */
$mageUrl = Mage::helper('core/url')->getCurrentUrl();
// There's a bug in Magento's Mage_Core_Helper_Url::getCurrentUrl that
// calls htmlspecialchars for URL which ends up breaking the URL
// parameter separator
$currentUrl = str_replace('&', '&', $mageUrl);

return $currentUrl;
}

/**
* Gets the URL where to redirect visitor after cart restoring
*
* @param Mage_Core_Model_Store $store the store to get the url for.
*
* @param array $additionalParams
* @return string the url.
*/
public function getRestoreCartRedirectUrl(
Mage_Core_Model_Store $store,
array $additionalParams = array()
)
{
/* @var Nosto_Tagging_Helper_Data $nostoHelper */
$nostoHelper = Mage::helper('nosto_tagging');
$path = $nostoHelper->getRestoreCartRedirectLocation($store);
$defaultParams = $this->getUrlOptionsWithNoSid($store);
$url = Mage::getUrl(
$path,
$defaultParams
);
if (!empty($additionalParams)) {
foreach ($additionalParams as $key => $val) {
$url = Nosto_Request_Http_HttpRequest::replaceQueryParamInUrl(
$key,
$val,
$url
);
}

}

return $url;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* 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 through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Nosto
* @package Nosto_Tagging
* @author Nosto Solutions Ltd <magento@nosto.com>
* @copyright Copyright (c) 2013-2017 Nosto Solutions Ltd (http://www.nosto.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Extension system setting source model for choosing where visitor should be redirected
* after the cart has been restored.
*
* @category Nosto
* @package Nosto_Tagging
* @author Nosto Solutions Ltd <magento@nosto.com>
* @suppress PhanUnreferencedClass
*/
class Nosto_Tagging_Model_System_Config_Source_Restore_Cart_Location
{
/**
* Returns the path options to choose from.
*
* @return array the options.
*/
public function toOptionArray()
{
return array(
array(
'value' => Nosto_Tagging_Helper_Url::MAGENTO_PATH_CART,
'label' => 'Cart page',
),
array(
'value' => Nosto_Tagging_Helper_Url::MAGENTO_PATH_ONEPAGE_CHEKOUT,
'label' => 'One page checkout',
)
);
}
}
11 changes: 4 additions & 7 deletions app/code/community/Nosto/Tagging/controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ class Nosto_Tagging_CartController extends Mage_Core_Controller_Front_Action
public function indexAction()
{
$store = Mage::app()->getStore();
/* @var Mage_Core_Helper_Url $mageUrlHelper */
$mageUrlHelper = Mage::helper('core/url');
$currentUrl = $mageUrlHelper->getCurrentUrl();
$urlParameters = Zend_Uri_Http::fromString($currentUrl)->getQueryAsArray();
/* @var Nosto_Tagging_Helper_Url $nostoUrlHelper */
$nostoUrlHelper = Mage::helper('nosto_tagging/url');
$currentUrl = $nostoUrlHelper->getCurrentUrl();
$urlParameters = Zend_Uri_Http::fromString($currentUrl)->getQueryAsArray();
$frontPageUrl = $nostoUrlHelper->getFrontPageUrl($store);
$redirectUrl = $frontPageUrl;
if (Mage::helper('nosto_tagging/module')->isModuleEnabled()) {
Expand All @@ -77,7 +75,7 @@ public function indexAction()
try {
$quote = $this->resolveQuote($restoreCartHash);
$checkoutSession->setQuoteId($quote->getId());
$redirectUrl = $nostoUrlHelper->getUrlCart(
$redirectUrl = $nostoUrlHelper->getRestoreCartRedirectUrl(
$store,
$urlParameters
);
Expand All @@ -89,13 +87,12 @@ public function indexAction()
}
}
} else {
$redirectUrl = $nostoUrlHelper->getUrlCart(
$redirectUrl = $nostoUrlHelper->getRestoreCartRedirectUrl(
$store,
$urlParameters
);
}
}

$this->_redirectUrl($redirectUrl);
}

Expand Down
3 changes: 2 additions & 1 deletion app/code/community/Nosto/Tagging/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<config>
<modules>
<Nosto_Tagging>
<version>3.6.3</version>
<version>3.6.4</version>
</Nosto_Tagging>
</modules>
<global>
Expand Down Expand Up @@ -257,6 +257,7 @@
<send_add_to_cart_event>0</send_add_to_cart_event>
<update_catalog_price_rules>0</update_catalog_price_rules>
<send_customer_data>1</send_customer_data>
<restore_cart_location>checkout/cart</restore_cart_location>
</general>
<image_options>
<image_version>image</image_version>
Expand Down
12 changes: 12 additions & 0 deletions app/code/community/Nosto/Tagging/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@
<show_in_store>1</show_in_store>
</send_add_to_cart_event>
</fields>
<fields>
<restore_cart_location translate="label">
<label>Redirect location after cart restore</label>
<comment>Choose where the visitor will be redirected after the cart has been restored</comment>
<frontend_type>select</frontend_type>
<source_model>nosto_tagging/system_config_source_restore_cart_location</source_model>
<sort_order>70</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</restore_cart_location>
</fields>
</general>
<currency_formats translate="label">
<label>Currency formats</label>
Expand Down

0 comments on commit c20ac7b

Please sign in to comment.