Diff between 1.9.3 and 1.9.2.4 + SUPEE-8788 / Don't mind the app/Mage.php autoloader patch ;)
diff --git a/.htaccess b/.htaccess | |
index aca7f55..63e1729 100644 | |
--- a/.htaccess | |
+++ b/.htaccess | |
@@ -144,6 +144,21 @@ | |
RewriteCond %{REQUEST_METHOD} ^TRAC[EK] | |
RewriteRule .* - [L,R=405] | |
+<IfModule mod_setenvif.c> | |
+ <IfModule mod_headers.c> | |
+ | |
+ ############################################ | |
+ # X-Content-Type-Options: nosniff disable content-type sniffing on some browsers. | |
+ Header set X-Content-Type-Options: nosniff | |
+ | |
+ ############################################ | |
+ # This header forces to enables the Cross-site scripting (XSS) filter in browsers (if disabled) | |
+ BrowserMatch \bMSIE\s8 ie8 | |
+ Header set X-XSS-Protection: "1; mode=block" env=!ie8 | |
+ | |
+ </IfModule> | |
+</IfModule> | |
+ | |
############################################ | |
## redirect for mobile user agents | |
diff --git a/.htaccess.sample b/.htaccess.sample | |
index 383313a..4353f6b 100644 | |
--- a/.htaccess.sample | |
+++ b/.htaccess.sample | |
@@ -127,6 +127,21 @@ | |
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
+<IfModule mod_setenvif.c> | |
+ <IfModule mod_headers.c> | |
+ | |
+ ############################################ | |
+ # X-Content-Type-Options: nosniff disable content-type sniffing on some browsers. | |
+ Header set X-Content-Type-Options: nosniff | |
+ | |
+ ############################################ | |
+ # This header forces to enables the Cross-site scripting (XSS) filter in browsers (if disabled) | |
+ BrowserMatch \bMSIE\s8 ie8 | |
+ Header set X-XSS-Protection: "1; mode=block" env=!ie8 | |
+ | |
+ </IfModule> | |
+</IfModule> | |
+ | |
############################################ | |
## always send 404 on missing files in these folders | |
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt | |
index abedf96..d237e58 100644 | |
--- a/RELEASE_NOTES.txt | |
+++ b/RELEASE_NOTES.txt | |
@@ -1,3 +1,13 @@ | |
+==== 1.9.3.0 ==== | |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
+] NOTE: Current Release Notes are maintained at: [ | |
+] [ | |
+] http://merch.docs.magento.com/ce/user_guide/magento/release-notes-ce-1.9.3.0.html [ | |
+] [ | |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
+ | |
==== 1.9.2.4 ==== | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
@@ -53,7 +63,7 @@ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
] NOTE: Current Release Notes are maintained at: [ | |
] [ | |
-] http://www.magentocommerce.com/knowledge-base/entry/ce-19-later-release-notes [ | |
+] http://devdocs.magento.com/guides/m1x/ce18-ee113/ce1.9_release-notes.html [ | |
] [ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
diff --git a/api.php b/api.php | |
index 1b6c612..e40400b 100644 | |
--- a/api.php | |
+++ b/api.php | |
@@ -74,8 +74,11 @@ if (in_array($apiAlias, Mage_Api2_Model_Server::getApiTypes())) { | |
} else { | |
/* @var $server Mage_Api_Model_Server */ | |
$server = Mage::getSingleton('api/server'); | |
- $adapterCode = $server->getAdapterCodeByAlias($apiAlias); | |
- | |
+ if (!$apiAlias) { | |
+ $adapterCode = 'default'; | |
+ } else { | |
+ $adapterCode = $server->getAdapterCodeByAlias($apiAlias); | |
+ } | |
// if no adapters found in aliases - find it by default, by code | |
if (null === $adapterCode) { | |
$adapterCode = $apiAlias; | |
diff --git a/app/Mage.php b/app/Mage.php | |
index 2ec7216..ca15775 100644 | |
--- a/app/Mage.php | |
+++ b/app/Mage.php | |
@@ -53,14 +53,6 @@ if (defined('COMPILER_INCLUDE_PATH')) { | |
Varien_Autoload::register(); | |
-/** AUTOLOADER PATCH **/ | |
-if (file_exists($autoloaderPath = BP . DS . '../vendor/autoload.php') || | |
- file_exists($autoloaderPath = BP . DS . 'vendor/autoload.php') | |
-) { | |
- require $autoloaderPath; | |
-} | |
-/** AUTOLOADER PATCH **/ | |
- | |
/** | |
* Main Mage hub class | |
* | |
@@ -178,8 +170,8 @@ final class Mage | |
return array( | |
'major' => '1', | |
'minor' => '9', | |
- 'revision' => '2', | |
- 'patch' => '4', | |
+ 'revision' => '3', | |
+ 'patch' => '0', | |
'stability' => '', | |
'number' => '', | |
); | |
diff --git a/app/code/core/Mage/Admin/Model/User.php b/app/code/core/Mage/Admin/Model/User.php | |
index 439085e..f1d193c 100644 | |
--- a/app/code/core/Mage/Admin/Model/User.php | |
+++ b/app/code/core/Mage/Admin/Model/User.php | |
@@ -640,8 +640,8 @@ class Mage_Admin_Model_User extends Mage_Core_Model_Abstract | |
return true; | |
} | |
- $dayDifference = floor(($currentTimestamp - $tokenTimestamp) / (24 * 60 * 60)); | |
- if ($dayDifference >= $tokenExpirationPeriod) { | |
+ $hoursDifference = floor(($currentTimestamp - $tokenTimestamp) / (60 * 60)); | |
+ if ($hoursDifference >= $tokenExpirationPeriod) { | |
return true; | |
} | |
@@ -665,7 +665,7 @@ class Mage_Admin_Model_User extends Mage_Core_Model_Abstract | |
/** | |
* Simple sql format date | |
* | |
- * @param string $format | |
+ * @param string | boolean $dayOnly | |
* @return string | |
*/ | |
protected function _getDateNow($dayOnly = false) | |
diff --git a/app/code/core/Mage/Admin/etc/config.xml b/app/code/core/Mage/Admin/etc/config.xml | |
index ccc27b9..d22e814 100644 | |
--- a/app/code/core/Mage/Admin/etc/config.xml | |
+++ b/app/code/core/Mage/Admin/etc/config.xml | |
@@ -85,7 +85,7 @@ | |
<emails> | |
<forgot_email_template>admin_emails_forgot_email_template</forgot_email_template> | |
<forgot_email_identity>general</forgot_email_identity> | |
- <password_reset_link_expiration_period>1</password_reset_link_expiration_period> | |
+ <password_reset_link_expiration_period>2</password_reset_link_expiration_period> | |
</emails> | |
</admin> | |
</default> | |
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php | |
index 5b32d48..e54f68a 100644 | |
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php | |
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php | |
@@ -207,14 +207,15 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Crosssell extends Mage_Admin | |
$this->addColumn('position', array( | |
- 'header' => Mage::helper('catalog')->__('Position'), | |
- 'name' => 'position', | |
- 'width' => 60, | |
- 'type' => 'number', | |
- 'validate_class' => 'validate-number', | |
- 'index' => 'position', | |
- 'editable' => !$this->isReadonly(), | |
- 'edit_only' => !$this->_getProduct()->getId() | |
+ 'header' => Mage::helper('catalog')->__('Position'), | |
+ 'name' => 'position', | |
+ 'width' => 60, | |
+ 'type' => 'number', | |
+ 'validate_class' => 'validate-number', | |
+ 'index' => 'position', | |
+ 'editable' => !$this->isReadonly(), | |
+ 'edit_only' => !$this->_getProduct()->getId(), | |
+ 'filter_condition_callback' => array($this, '_addLinkModelFilterCallback') | |
)); | |
return parent::_prepareColumns(); | |
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php | |
index ba8de8f..e786341 100644 | |
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php | |
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php | |
@@ -93,4 +93,13 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Group | |
return parent::_prepareLayout(); | |
} | |
+ /** | |
+ * Get is percent flag | |
+ * | |
+ * @return int | |
+ */ | |
+ public function getIsPercent() { | |
+ return $this->getData('is_percent') ? $this->getData('is_percent') : 0; | |
+ } | |
+ | |
} | |
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php | |
index ca37fb9..bf7e4a8 100644 | |
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php | |
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php | |
@@ -203,14 +203,15 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Related extends Mage_Adminht | |
)); | |
$this->addColumn('position', array( | |
- 'header' => Mage::helper('catalog')->__('Position'), | |
- 'name' => 'position', | |
- 'type' => 'number', | |
- 'validate_class' => 'validate-number', | |
- 'index' => 'position', | |
- 'width' => 60, | |
- 'editable' => !$this->_getProduct()->getRelatedReadonly(), | |
- 'edit_only' => !$this->_getProduct()->getId() | |
+ 'header' => Mage::helper('catalog')->__('Position'), | |
+ 'name' => 'position', | |
+ 'type' => 'number', | |
+ 'validate_class' => 'validate-number', | |
+ 'index' => 'position', | |
+ 'width' => 60, | |
+ 'editable' => !$this->_getProduct()->getRelatedReadonly(), | |
+ 'edit_only' => !$this->_getProduct()->getId(), | |
+ 'filter_condition_callback' => array($this, '_addLinkModelFilterCallback') | |
)); | |
return parent::_prepareColumns(); | |
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php | |
index 420b903..9ff8ad3 100644 | |
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php | |
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Group.php | |
@@ -156,7 +156,8 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group extends Mage_Adm | |
'validate_class' => 'validate-number', | |
'index' => 'qty', | |
'width' => '1', | |
- 'editable' => true | |
+ 'editable' => true, | |
+ 'filter_condition_callback' => array($this, '_addLinkModelFilterCallback') | |
)); | |
$this->addColumn('position', array( | |
@@ -167,7 +168,8 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Group extends Mage_Adm | |
'index' => 'position', | |
'width' => '1', | |
'editable' => true, | |
- 'edit_only' => !$this->_getProduct()->getId() | |
+ 'edit_only' => !$this->_getProduct()->getId(), | |
+ 'filter_condition_callback' => array($this, '_addLinkModelFilterCallback') | |
)); | |
return parent::_prepareColumns(); | |
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php | |
index e030ebb..4bf6fbb 100644 | |
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php | |
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php | |
@@ -203,14 +203,15 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Upsell extends Mage_Adminhtm | |
)); | |
$this->addColumn('position', array( | |
- 'header' => Mage::helper('catalog')->__('Position'), | |
- 'name' => 'position', | |
- 'type' => 'number', | |
- 'width' => 60, | |
- 'validate_class' => 'validate-number', | |
- 'index' => 'position', | |
- 'editable' => !$this->_getProduct()->getUpsellReadonly(), | |
- 'edit_only' => !$this->_getProduct()->getId() | |
+ 'header' => Mage::helper('catalog')->__('Position'), | |
+ 'name' => 'position', | |
+ 'type' => 'number', | |
+ 'width' => 60, | |
+ 'validate_class' => 'validate-number', | |
+ 'index' => 'position', | |
+ 'editable' => !$this->_getProduct()->getUpsellReadonly(), | |
+ 'edit_only' => !$this->_getProduct()->getId(), | |
+ 'filter_condition_callback' => array($this, '_addLinkModelFilterCallback') | |
)); | |
return parent::_prepareColumns(); | |
diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Curl.php b/app/code/core/Mage/Adminhtml/Block/Notification/Curl.php | |
new file mode 100644 | |
index 0000000..77b08c8 | |
--- /dev/null | |
+++ b/app/code/core/Mage/Adminhtml/Block/Notification/Curl.php | |
@@ -0,0 +1,96 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Adminhtml | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+ | |
+/** | |
+ * Class Mage_Adminhtml_Block_Notification_Curl | |
+ */ | |
+class Mage_Adminhtml_Block_Notification_Curl extends Mage_Adminhtml_Block_Template | |
+{ | |
+ /** | |
+ * Required version of cURL. | |
+ */ | |
+ const REQUIRED_CURL_VERSION = '7.34.0'; | |
+ | |
+ /** | |
+ * Information about cURL version. | |
+ * | |
+ * @var array | |
+ */ | |
+ protected $_curlVersion; | |
+ | |
+ public function __construct() | |
+ { | |
+ $this->_curlVersion = curl_version(); | |
+ } | |
+ | |
+ /** | |
+ * Check cURL version and return true if system must show notification message. | |
+ * | |
+ * @return bool | |
+ */ | |
+ protected function _canShow() | |
+ { | |
+ $result = false; | |
+ if ( | |
+ $this->getRequest()->getParam('section') == 'payment' | |
+ && !version_compare($this->_curlVersion['version'], $this::REQUIRED_CURL_VERSION, '>=') | |
+ ) { | |
+ $result = true; | |
+ } | |
+ | |
+ return $result; | |
+ } | |
+ | |
+ /** | |
+ * Returns a message that should be displayed. | |
+ * | |
+ * @return string | |
+ */ | |
+ public function getMessage() | |
+ { | |
+ $message = $this->helper('adminhtml')->__( | |
+ "Your current version of cURL php5 module is %s, which can prevent services that require TLS v1.2 from working correctly. It is recommended to update your cURL php5 module to version %s or higher.", | |
+ $this->_curlVersion['version'], | |
+ $this::REQUIRED_CURL_VERSION | |
+ ); | |
+ | |
+ return $message; | |
+ } | |
+ | |
+ /** | |
+ * Prepare html output. | |
+ * | |
+ * @return string | |
+ */ | |
+ protected function _toHtml() | |
+ { | |
+ if (!$this->_canShow()) { | |
+ return ''; | |
+ } | |
+ | |
+ return parent::_toHtml(); | |
+ } | |
+} | |
diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php | |
index 7010838..e08aa19 100644 | |
--- a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php | |
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php | |
@@ -217,6 +217,7 @@ class Mage_Adminhtml_Block_Report_Grid_Abstract extends Mage_Adminhtml_Block_Wid | |
->isTotals(true); | |
$this->_addOrderStatusFilter($totalsCollection, $filterData); | |
+ $this->_addCustomFilter($totalsCollection, $filterData); | |
if (count($totalsCollection->getItems()) < 1 || !$filterData->getData('from')) { | |
$this->setTotals(new Varien_Object()); | |
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php | |
index 8219eb1..da4125d 100644 | |
--- a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php | |
+++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php | |
@@ -147,7 +147,7 @@ class Mage_Adminhtml_Block_System_Config_Tabs extends Mage_Adminhtml_Block_Widge | |
} | |
} | |
- Mage::helper('adminhtml')->addPageHelpUrl($current.'/'); | |
+ Mage::helper('adminhtml')->addPageHelpUrl('/section/' . $current); | |
return $this; | |
} | |
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php | |
index 538a805..3affa5a 100644 | |
--- a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php | |
+++ b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit/Form.php | |
@@ -78,7 +78,9 @@ class Mage_Adminhtml_Block_System_Variable_Edit_Form extends Mage_Adminhtml_Bloc | |
$useDefault = false; | |
if ($this->getVariable()->getId() && $this->getVariable()->getStoreId()) { | |
- $useDefault = !((bool)$this->getVariable()->getStoreHtmlValue()); | |
+ $useDefault = !((bool)$this->getVariable()->getStoreHtmlValue() | |
+ || (bool)$this->getVariable()->getStorePlainValue() | |
+ ); | |
$this->getVariable()->setUseDefaultValue((int)$useDefault); | |
$fieldset->addField('use_default_value', 'select', array( | |
'name' => 'use_default_value', | |
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php | |
index 6e6226b..278ffa2 100644 | |
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php | |
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php | |
@@ -477,6 +477,23 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget | |
} | |
/** | |
+ * Add link model filter from grid column to collection | |
+ * | |
+ * @param Mage_Catalog_Model_Resource_Product_Link_Product_Collection $collection | |
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column | |
+ * | |
+ * @return Mage_Adminhtml_Block_Widget_Grid | |
+ */ | |
+ protected function _addLinkModelFilterCallback($collection, $column) | |
+ { | |
+ $field = ($column->getFilterIndex()) ? $column->getFilterIndex() : $column->getIndex(); | |
+ $condition = $column->getFilter()->getCondition(); | |
+ $collection->addLinkModelFieldToFilter($field, $condition); | |
+ | |
+ return $this; | |
+ } | |
+ | |
+ /** | |
* Sets sorting order by some column | |
* | |
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column | |
diff --git a/app/code/core/Mage/Adminhtml/Controller/Rss/Abstract.php b/app/code/core/Mage/Adminhtml/Controller/Rss/Abstract.php | |
new file mode 100644 | |
index 0000000..65f598a | |
--- /dev/null | |
+++ b/app/code/core/Mage/Adminhtml/Controller/Rss/Abstract.php | |
@@ -0,0 +1,77 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Adminhtml | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+ | |
+/** | |
+ * Adminhtml abstract Rss controller | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Adminhtml | |
+ * @author Magento Core Team <core@magentocommerce.com> | |
+ */ | |
+class Mage_Adminhtml_Controller_Rss_Abstract extends Mage_Adminhtml_Controller_Action | |
+{ | |
+ /** | |
+ * Check feed enabled in config | |
+ * | |
+ * @param string $code | |
+ * @return boolean | |
+ */ | |
+ protected function isFeedEnable($code) | |
+ { | |
+ return $this->_getHelper('rss')->isRssEnabled() | |
+ && Mage::getStoreConfig('rss/'. $code); | |
+ } | |
+ | |
+ /** | |
+ * Do check feed enabled and prepare response | |
+ * | |
+ * @param string $code | |
+ * @return boolean | |
+ */ | |
+ protected function checkFeedEnable($code) | |
+ { | |
+ if ($this->isFeedEnable($code)) { | |
+ $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); | |
+ return true; | |
+ } else { | |
+ $this->getResponse()->setHeader('HTTP/1.1', '404 Not Found'); | |
+ $this->getResponse()->setHeader('Status', '404 File not found'); | |
+ $this->_forward('noRoute'); | |
+ return false; | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * Retrieve helper instance | |
+ * | |
+ * @param string $name | |
+ * @return Mage_Core_Helper_Abstract | |
+ */ | |
+ protected function _getHelper($name) | |
+ { | |
+ return Mage::helper($name); | |
+ } | |
+} | |
diff --git a/app/code/core/Mage/Adminhtml/Helper/Data.php b/app/code/core/Mage/Adminhtml/Helper/Data.php | |
index b92e164..e92e1c5 100644 | |
--- a/app/code/core/Mage/Adminhtml/Helper/Data.php | |
+++ b/app/code/core/Mage/Adminhtml/Helper/Data.php | |
@@ -31,7 +31,7 @@ | |
* @package Mage_Adminhtml | |
* @author Magento Core Team <core@magentocommerce.com> | |
*/ | |
-class Mage_Adminhtml_Helper_Data extends Mage_Core_Helper_Abstract | |
+class Mage_Adminhtml_Helper_Data extends Mage_Adminhtml_Helper_Help_Mapping | |
{ | |
const XML_PATH_ADMINHTML_ROUTER_FRONTNAME = 'admin/routers/adminhtml/args/frontName'; | |
const XML_PATH_USE_CUSTOM_ADMIN_URL = 'default/admin/url/use_custom'; | |
@@ -40,15 +40,29 @@ class Mage_Adminhtml_Helper_Data extends Mage_Core_Helper_Abstract | |
protected $_pageHelpUrl; | |
- public function getPageHelpUrl() | |
+ /** | |
+ * Get mapped help pages url | |
+ * | |
+ * @param null|string $url | |
+ * @param null|string $suffix | |
+ * @return mixed | |
+ */ | |
+ public function getPageHelpUrl($url = null, $suffix = null) | |
{ | |
if (!$this->_pageHelpUrl) { | |
- $this->setPageHelpUrl(); | |
+ $this->setPageHelpUrl($url, $suffix); | |
} | |
return $this->_pageHelpUrl; | |
} | |
- public function setPageHelpUrl($url=null) | |
+ /** | |
+ * Set help page url | |
+ * | |
+ * @param null|string $url | |
+ * @param null|string $suffix | |
+ * @return $this | |
+ */ | |
+ public function setPageHelpUrl($url = null, $suffix = null) | |
{ | |
if (is_null($url)) { | |
$request = Mage::app()->getRequest(); | |
@@ -62,11 +76,17 @@ class Mage_Adminhtml_Helper_Data extends Mage_Core_Helper_Abstract | |
$frontModule = $frontModule[0]; | |
} | |
} | |
- $url = 'http://www.magentocommerce.com/gethelp/'; | |
- $url.= Mage::app()->getLocale()->getLocaleCode().'/'; | |
- $url.= $frontModule.'/'; | |
- $url.= $request->getControllerName().'/'; | |
- $url.= $request->getActionName().'/'; | |
+ $url = "http://merch.docs.magento.com/{$this->getHelpTargetVersion()}/user_guide/"; | |
+ | |
+ $moduleName = $frontModule; | |
+ $controllerName = $request->getControllerName(); | |
+ $actionName = $request->getActionName() . (!is_null($suffix) ? $suffix : ''); | |
+ | |
+ if ($mappingUrl = $this->findInMapping($moduleName, $controllerName, $actionName)) { | |
+ $url .= $mappingUrl; | |
+ } else { | |
+ $url = 'http://magento.com/help/documentation'; | |
+ } | |
$this->_pageHelpUrl = $url; | |
} | |
@@ -75,9 +95,15 @@ class Mage_Adminhtml_Helper_Data extends Mage_Core_Helper_Abstract | |
return $this; | |
} | |
+ /** | |
+ * Add suffix for help page url | |
+ * | |
+ * @param string $suffix | |
+ * @return $this | |
+ */ | |
public function addPageHelpUrl($suffix) | |
{ | |
- $this->_pageHelpUrl = $this->getPageHelpUrl().$suffix; | |
+ $this->_pageHelpUrl = $this->getPageHelpUrl(null, $suffix); | |
return $this; | |
} | |
diff --git a/app/code/core/Mage/Adminhtml/Helper/Help/Mapping.php b/app/code/core/Mage/Adminhtml/Helper/Help/Mapping.php | |
new file mode 100644 | |
index 0000000..9d05262 | |
--- /dev/null | |
+++ b/app/code/core/Mage/Adminhtml/Helper/Help/Mapping.php | |
@@ -0,0 +1,255 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Adminhtml | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+ | |
+/** | |
+ * Adminhtml help url mapper | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Adminhtml | |
+ */ | |
+ | |
+abstract class Mage_Adminhtml_Helper_Help_Mapping extends Mage_Core_Helper_Abstract | |
+{ | |
+ /** | |
+ * Mapping of help page urls depending on module and page route | |
+ * | |
+ * @var array | |
+ */ | |
+ protected $_moduleMappings = array( | |
+ 'Mage_Adminhtml' => array( | |
+ /* Dashboard */ | |
+ 'dashboard' => 'store-operations/reports-dashboard.html', | |
+ /* Sales */ | |
+ 'sales_order' => 'order-processing/order-manage.html', | |
+ 'sales_invoice' => 'order-processing/order-invoice.html', | |
+ 'sales_shipment' => 'order-processing/order-ship.html', | |
+ 'sales_creditmemo' => 'order-processing/credit-refunds.html', | |
+ 'sales_transactions' => 'order-processing/sales-transactions.html', | |
+ 'sales_recurring_profile' => 'catalog/product-recurring-profile.html', | |
+ 'sales_billing_agreement' => 'payment/paypal-billing-agreements.html', | |
+ 'checkout_agreement' => 'order-processing/terms-conditions.html', | |
+ /* Sales → Tax */ | |
+ 'tax_rule' => 'tax/tax-rules.html', | |
+ 'tax_rate' => 'tax/tax-zones-rates.html', | |
+ 'tax_rate/importExport' => 'tax/tax-rates-import-export.html', | |
+ 'tax_class_customer' => 'tax/tax-class-customer.html', | |
+ 'tax_class_product' => 'tax/tax-class-product.html', | |
+ /* Catalog */ | |
+ 'catalog_product' => 'catalog/product-create.html', | |
+ 'catalog_category/edit' => 'catalog/category-create.html', | |
+ 'urlrewrite' => 'search_seo/seo-url-redirect.html', | |
+ 'catalog_search' => 'search_seo/search-terms.html', | |
+ 'sitemap' => 'marketing/google-sitemap.html', | |
+ /* Catalog → Attributes */ | |
+ 'catalog_product_attribute' => 'catalog/attributes.html', | |
+ 'catalog_product_set' => 'catalog/attribute-set.html', | |
+ /* Catalog → Reviews and Ratings → Customer Reviews */ | |
+ 'catalog_product_review/pending' => 'marketing/product-reviews.html', | |
+ 'catalog_product_review' => 'marketing/product-reviews.html', | |
+ 'rating' => 'marketing/product-reviews-ratings.html', | |
+ /* Catalog → Tags */ | |
+ 'tag' => 'marketing/tags.html', | |
+ 'tag/pending' => 'marketing/tags-moderate.html', | |
+ /* Customers */ | |
+ 'customer' => 'customers/customer-account-create.html', | |
+ 'customer_group' => 'customers/customer-group-create.html', | |
+ 'customer_online' => 'order-processing/customers-online.html', | |
+ /* Promotions */ | |
+ 'promo_catalog' => 'marketing/price-rules-catalog.html', | |
+ 'promo_quote' => 'marketing/price-rules-shopping-cart.html', | |
+ /* Newsletter */ | |
+ 'newsletter_template' => 'marketing/newsletter-templates.html', | |
+ 'newsletter_queue' => 'marketing/newsletter-queue.html', | |
+ 'newsletter_subscriber' => 'marketing/newsletter.html', | |
+ 'newsletter_problem' => 'marketing/newsletter.html', | |
+ /* CMS */ | |
+ 'cms_page' => 'cms/pages.html', | |
+ 'cms_block' => 'cms/blocks.html', | |
+ 'poll' => 'marketing/polls.html', | |
+ /* Reports → Sales */ | |
+ 'report_sales/sales' => 'store-operations/reports-generating.html', | |
+ 'report_sales/tax' =>'store-operations/reports-available.html', | |
+ 'report_sales/invoiced' =>'store-operations/reports-available.html', | |
+ 'report_sales/shipping' =>'store-operations/reports-available.html', | |
+ 'report_sales/refunded' =>'store-operations/reports-available.html', | |
+ 'report_sales/coupons' =>'store-operations/reports-available.html', | |
+ /* Reports → Shopping Cart */ | |
+ 'report_shopcart/product' =>'store-operations/reports-available.html', | |
+ 'report_shopcart/abandoned' =>'store-operations/reports-available.html', | |
+ /* Reports → Products */ | |
+ 'report_sales/bestsellers' =>'store-operations/reports-available.html', | |
+ 'report_product/sold' =>'store-operations/reports-available.html', | |
+ 'report_product/viewed' =>'store-operations/reports-available.html', | |
+ 'report_product/lowstock' =>'store-operations/reports-available.html', | |
+ 'report_product/downloads' =>'store-operations/reports-available.html', | |
+ /* Reports → Customers */ | |
+ 'report_customer/accounts' =>'store-operations/reports-available.html', | |
+ 'report_customer/totals' =>'store-operations/reports-available.html', | |
+ 'report_customer/orders' =>'store-operations/reports-available.html', | |
+ /* Reports → Tags */ | |
+ 'report_tag/customer' =>'store-operations/reports-available.html', | |
+ 'report_tag/product' =>'store-operations/reports-available.html', | |
+ 'report_tag/popular' =>'store-operations/reports-available.html', | |
+ /* Reports → Reviews */ | |
+ 'report_review/customer' =>'store-operations/reports-available.html', | |
+ 'report_review/product' =>'store-operations/reports-available.html', | |
+ /* Search Terms */ | |
+ 'report/search' =>'store-operations/reports-available.html', | |
+ /* Refresh statistics */ | |
+ 'report_statistics' =>'store-operations/reports-refresh.html', | |
+ /* My Account */ | |
+ 'system_account' => 'store-operations/admin-my-account.html', | |
+ /* Notifications */ | |
+ 'notification' => 'store-operations/admin-messages.html', | |
+ /* Tools → Backup */ | |
+ 'system_backup' => 'system-operations/server-backup-rollback.html', | |
+ /* Web Services */ | |
+ 'api_user' => 'system-operations/web-services.html', | |
+ 'api_role' => 'system-operations/web-services.html', | |
+ 'api2_role' => 'system-operations/web-services.html', | |
+ /* System → Design */ | |
+ 'system_design' => 'design/themes.html', | |
+ /* System → Import/Export */ | |
+ 'system_convert_gui' => 'store-operations/dataflow.html', | |
+ 'system_convert_profile' => 'store-operations/dataflow.html', | |
+ /* System → Manage Currency */ | |
+ 'system_currency' => 'store-operations/currency-rates.html', | |
+ 'system_currencysymbol' => 'store-operations/currency-symbols.html', | |
+ /* System → Transactional emails */ | |
+ 'system_email_template' => 'store-operations/email-transactional.html', | |
+ /* System → Custom Variables */ | |
+ 'system_variable' => 'cms/variables-custom.html', | |
+ /* System → Permissions */ | |
+ 'permissions_user' => 'store-operations/permissions-user-new.html', | |
+ 'permissions_role' => 'store-operations/permissions-role-custom.html', | |
+ /* System → Cache Management */ | |
+ 'cache' => 'system-operations/cache-management.html', | |
+ /* System → Stores Management */ | |
+ 'system_store' => 'store-operations/store-hierarchy.html', | |
+ /* System → Order statuses */ | |
+ 'sales_order_status' => 'order-processing/order-status.html', | |
+ /* System → Configuration */ | |
+ 'system_config/edit/section/general' => 'configuration/general/general.html', | |
+ 'system_config/edit/section/web' => 'configuration/general/web.html', | |
+ 'system_config/edit/section/design' => 'configuration/general/design.html', | |
+ 'system_config/edit/section/currency' => 'configuration/general/currency-setup.html', | |
+ 'system_config/edit/section/trans_email' => 'configuration/general/store-email-addresses.html', | |
+ 'system_config/edit/section/contacts' => 'configuration/general/contacts.html', | |
+ 'system_config/edit/section/reports' => 'configuration/general/reports.html', | |
+ 'system_config/edit/section/cms' => 'configuration/general/content-management.html', | |
+ 'system_config/edit/section/catalog' => 'configuration/catalog/catalog.html', | |
+ 'system_config/edit/section/configswatches' => 'configuration/catalog/configurable-swatches.html', | |
+ 'system_config/edit/section/cataloginventory' => 'configuration/catalog/inventory.html', | |
+ 'system_config/edit/section/sitemap' => 'configuration/catalog/google-sitemap.html', | |
+ 'system_config/edit/section/rss' => 'configuration/catalog/rss-feeds.html', | |
+ 'system_config/edit/section/sendfriend' => 'configuration/catalog/email-to-a-friend.html', | |
+ 'system_config/edit/section/newsletter' => 'configuration/customers/newsletter.html', | |
+ 'system_config/edit/section/customer' => 'configuration/customers/customer-configuration.html', | |
+ 'system_config/edit/section/wishlist' => 'configuration/customers/wishlist.html', | |
+ 'system_config/edit/section/promo' => 'configuration/customers/promotions.html', | |
+ 'system_config/edit/section/persistent' => 'configuration/customers/persistent-shopping-cart.html', | |
+ 'system_config/edit/section/sales' => 'configuration/sales/sales.html', | |
+ 'system_config/edit/section/sales_email' => 'configuration/sales/sales-emails.html', | |
+ 'system_config/edit/section/sales_pdf' => 'configuration/sales/pdf-print-outs.html', | |
+ 'system_config/edit/section/tax' => 'configuration/sales/tax.html', | |
+ 'system_config/edit/section/checkout' => 'configuration/sales/checkout.html', | |
+ 'system_config/edit/section/shipping' => 'configuration/sales/shipping-settings.html', | |
+ 'system_config/edit/section/carriers' => 'configuration/sales/shipping-methods.html', | |
+ 'system_config/edit/section/google' => 'configuration/sales/google-api.html', | |
+ 'system_config/edit/section/payment' => 'configuration/sales/payment-methods.html', | |
+ 'system_config/edit/section/payment_services' => 'configuration/sales/payment-services.html', | |
+ 'system_config/edit/section/moneybookers' => 'payment/gateways.html', | |
+ 'system_config/edit/section/api' => 'configuration/services/magento-core-api.html', | |
+ 'system_config/edit/section/oauth' => 'configuration/services/oauth.html', | |
+ 'system_config/edit/section/admin' => 'configuration/advanced/admin.html', | |
+ 'system_config/edit/section/system' => 'configuration/advanced/system.html', | |
+ 'system_config/edit/section/advanced' => 'configuration/advanced/advanced.html', | |
+ 'system_config/edit/section/dev' => 'configuration/advanced/developer.html', | |
+ ), | |
+ 'Mage_Widget_Adminhtml' => array( | |
+ 'widget_instance' => 'cms/widgets.html', | |
+ ), | |
+ 'Mage_Paypal_Adminhtml' => array( | |
+ 'paypal_reports' => 'store-operations/reports-available.html', | |
+ ), | |
+ 'Mage_Compiler_Adminhtml' => array( | |
+ 'compiler_process' => 'system-operations/system-tools-compilation.html', | |
+ ), | |
+ 'Mage_Api2_Adminhtml' => array( | |
+ 'api2_attribute' => 'system-operations/web-services.html', | |
+ ), | |
+ 'Mage_Oauth_Adminhtml' => array( | |
+ 'oauth_consumer' => 'system-operations/web-services.html', | |
+ 'oauth_authorizedTokens' => 'system-operations/web-services.html', | |
+ 'oauth_admin_token' => 'system-operations/web-services.html', | |
+ ), | |
+ 'Mage_ImportExport_Adminhtml' => array( | |
+ 'import' => 'store-operations/data-import.html', | |
+ 'export' => 'store-operations/data-export.html', | |
+ ), | |
+ 'Mage_Connect_Adminhtml' => array( | |
+ 'extension_custom/edit' => 'magento/magento-connect.html' | |
+ ), | |
+ 'Mage_Index_Adminhtml' => array( | |
+ 'process/list' => 'system-operations/index-management.html' | |
+ ), | |
+ ); | |
+ | |
+ /** | |
+ * Compose reconstructed URL using mapping | |
+ * | |
+ * @param string $frontModule | |
+ * @param string $controllerName | |
+ * @param string $actionName | |
+ * @return string|bool | |
+ */ | |
+ protected function findInMapping($frontModule, $controllerName, $actionName) | |
+ { | |
+ if ($actionName === 'index' ) { | |
+ $targetToFind = $controllerName; | |
+ } else { | |
+ $targetToFind = $controllerName . '/' . $actionName; | |
+ } | |
+ if (isset($this->_moduleMappings[$frontModule]) | |
+ && isset($this->_moduleMappings[$frontModule][$targetToFind]) | |
+ ) { | |
+ return $this->_moduleMappings[$frontModule][$targetToFind]; | |
+ } | |
+ | |
+ return false; | |
+ } | |
+ | |
+ /** | |
+ * Determine which version of docs should target onto | |
+ * | |
+ * @return string | |
+ */ | |
+ protected function getHelpTargetVersion() | |
+ { | |
+ return Mage::getConfig()->getNode('default/help/target_version'); | |
+ } | |
+ | |
+} | |
diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php | |
index 334d8b3..76ee575 100644 | |
--- a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php | |
+++ b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php | |
@@ -596,6 +596,9 @@ class Mage_Adminhtml_Model_Sales_Order_Create extends Varien_Object implements M | |
if (is_string($cartItem)) { | |
Mage::throwException($cartItem); | |
} | |
+ if ($cartItem->getParentItem()) { | |
+ $cartItem = $cartItem->getParentItem(); | |
+ } | |
$cartItem->setPrice($item->getProduct()->getPrice()); | |
$this->_needCollectCart = true; | |
$removeItem = true; | |
diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Customer/Forgotpassword.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Customer/Forgotpassword.php | |
new file mode 100644 | |
index 0000000..a5c82b6 | |
--- /dev/null | |
+++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Customer/Forgotpassword.php | |
@@ -0,0 +1,51 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Adminhtml | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+ | |
+/** | |
+ * Source model of forgot password flow requests options types | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Adminhtml | |
+ * @author Magento Core Team <core@magentocommerce.com> | |
+ */ | |
+class Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword | |
+{ | |
+ const FORGOTPASS_FLOW_DISABLED = 0; | |
+ const FORGOTPASS_FLOW_IP_EMAIL = 1; | |
+ const FORGOTPASS_FLOW_IP = 2; | |
+ const FORGOTPASS_FLOW_EMAIL = 3; | |
+ | |
+ public function toOptionArray() | |
+ { | |
+ return array( | |
+ array('value' => self::FORGOTPASS_FLOW_DISABLED, 'label' => Mage::helper('adminhtml')->__('Disabled')), | |
+ array('value' => self::FORGOTPASS_FLOW_IP_EMAIL, 'label' => Mage::helper('adminhtml')->__('By IP and Email')), | |
+ array('value' => self::FORGOTPASS_FLOW_IP, 'label' => Mage::helper('adminhtml')->__('By IP')), | |
+ array('value' => self::FORGOTPASS_FLOW_EMAIL, 'label' => Mage::helper('adminhtml')->__('By Email')), | |
+ ); | |
+ } | |
+ | |
+} | |
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php | |
index 7ae3fb6..95fe677 100644 | |
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php | |
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php | |
@@ -37,6 +37,21 @@ class Mage_Adminhtml_Catalog_Product_AttributeController extends Mage_Adminhtml_ | |
protected $_entityTypeId; | |
+ /** | |
+ * List of tags from setting | |
+ */ | |
+ const XML_PATH_ALLOWED_TAGS = 'system/catalog/frontend/allowed_html_tags_list'; | |
+ | |
+ /** | |
+ * Get list of allowed text formatted as array | |
+ * | |
+ * @return array | |
+ */ | |
+ protected function _getAllowedTags() | |
+ { | |
+ return explode(',', Mage::getStoreConfig(self::XML_PATH_ALLOWED_TAGS)); | |
+ } | |
+ | |
public function preDispatch() | |
{ | |
parent::preDispatch(); | |
@@ -164,7 +179,17 @@ class Mage_Adminhtml_Catalog_Product_AttributeController extends Mage_Adminhtml_ | |
if (!empty($data['option']) && !empty($data['option']['value']) && is_array($data['option']['value'])) { | |
foreach ($data['option']['value'] as $key => $values) { | |
- $data['option']['value'][$key] = array_map(array($helperCatalog, 'stripTags'), $values); | |
+ $isHtmlAllowedOnFrontend = isset($data['is_html_allowed_on_front']) | |
+ && $data['is_html_allowed_on_front']; | |
+ $data['option']['value'][$key] = array_map( | |
+ array($helperCatalog, 'stripTags'), | |
+ $values, | |
+ array_fill( | |
+ 0, | |
+ count($values), | |
+ $isHtmlAllowedOnFrontend ? sprintf('<%s>', implode('><', $this->_getAllowedTags())): null | |
+ ) | |
+ ); | |
} | |
} | |
} | |
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php | |
index ce53168..6baa56c 100644 | |
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php | |
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php | |
@@ -188,7 +188,10 @@ class Mage_Adminhtml_Cms_Wysiwyg_ImagesController extends Mage_Adminhtml_Control | |
if ($thumb !== false) { | |
$image = Varien_Image_Adapter::factory('GD2'); | |
$image->open($thumb); | |
+ ob_start(); | |
$image->display(); | |
+ $this->getResponse()->setBody(ob_get_contents()); | |
+ ob_end_clean(); | |
} else { | |
// todo: genearte some placeholder | |
} | |
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php | |
index 28f8783..7a93bc0 100644 | |
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php | |
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php | |
@@ -46,22 +46,14 @@ class Mage_Adminhtml_Cms_WysiwygController extends Mage_Adminhtml_Controller_Act | |
try { | |
$image = Varien_Image_Adapter::factory('GD2'); | |
$image->open($url); | |
- $image->display(); | |
} catch (Exception $e) { | |
$image = Varien_Image_Adapter::factory('GD2'); | |
$image->open(Mage::getSingleton('cms/wysiwyg_config')->getSkinImagePlaceholderPath()); | |
- $image->display(); | |
- /* | |
- $image = imagecreate(100, 100); | |
- $bkgrColor = imagecolorallocate($image,10,10,10); | |
- imagefill($image,0,0,$bkgrColor); | |
- $textColor = imagecolorallocate($image,255,255,255); | |
- imagestring($image, 4, 10, 10, 'Skin image', $textColor); | |
- header('Content-type: image/png'); | |
- imagepng($image); | |
- imagedestroy($image); | |
- */ | |
} | |
+ ob_start(); | |
+ $image->display(); | |
+ $this->getResponse()->setBody(ob_get_contents()); | |
+ ob_end_clean(); | |
} | |
/** | |
diff --git a/app/code/core/Mage/Adminhtml/controllers/Rss/CatalogController.php b/app/code/core/Mage/Adminhtml/controllers/Rss/CatalogController.php | |
index a296f3d..d9a494a 100644 | |
--- a/app/code/core/Mage/Adminhtml/controllers/Rss/CatalogController.php | |
+++ b/app/code/core/Mage/Adminhtml/controllers/Rss/CatalogController.php | |
@@ -32,7 +32,7 @@ | |
* @author Magento Core Team <core@magentocommerce.com> | |
*/ | |
-class Mage_Adminhtml_Rss_CatalogController extends Mage_Adminhtml_Controller_Action | |
+class Mage_Adminhtml_Rss_CatalogController extends Mage_Adminhtml_Controller_Rss_Abstract | |
{ | |
/** | |
* Check is allowed access to action | |
@@ -53,15 +53,17 @@ class Mage_Adminhtml_Rss_CatalogController extends Mage_Adminhtml_Controller_Act | |
public function notifystockAction() | |
{ | |
- $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); | |
- $this->loadLayout(false); | |
- $this->renderLayout(); | |
+ if ($this->checkFeedEnable('admin_catalog/notifystock')) { | |
+ $this->loadLayout(false); | |
+ $this->renderLayout(); | |
+ } | |
} | |
public function reviewAction() | |
{ | |
- $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); | |
- $this->loadLayout(false); | |
- $this->renderLayout(); | |
+ if ($this->checkFeedEnable('admin_catalog/review')) { | |
+ $this->loadLayout(false); | |
+ $this->renderLayout(); | |
+ } | |
} | |
} | |
diff --git a/app/code/core/Mage/Adminhtml/controllers/Rss/OrderController.php b/app/code/core/Mage/Adminhtml/controllers/Rss/OrderController.php | |
index bc4fedd..ddf69e3 100644 | |
--- a/app/code/core/Mage/Adminhtml/controllers/Rss/OrderController.php | |
+++ b/app/code/core/Mage/Adminhtml/controllers/Rss/OrderController.php | |
@@ -32,15 +32,15 @@ | |
* @author Magento Core Team <core@magentocommerce.com> | |
*/ | |
-class Mage_Adminhtml_Rss_OrderController extends Mage_Adminhtml_Controller_Action | |
+class Mage_Adminhtml_Rss_OrderController extends Mage_Adminhtml_Controller_Rss_Abstract | |
{ | |
public function newAction() | |
{ | |
- Mage::helper('rss')->authAdmin('sales/order'); | |
- $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); | |
- $this->loadLayout(false); | |
- $this->renderLayout(); | |
+ if ($this->checkFeedEnable('order/new')) { | |
+ $this->loadLayout(false); | |
+ $this->renderLayout(); | |
+ } | |
} | |
/** | |
diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php | |
index cabd6e3..49c9992 100644 | |
--- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php | |
+++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php | |
@@ -135,7 +135,7 @@ class Mage_Adminhtml_UrlrewriteController extends Mage_Adminhtml_Controller_Acti | |
->setTargetPath($this->getRequest()->getParam('target_path')) | |
->setOptions($this->getRequest()->getParam('options')) | |
->setDescription($this->getRequest()->getParam('description')) | |
- ->setRequestPath($requestPath); | |
+ ->setRequestPath(strtolower($requestPath)); | |
if (!$model->getId()) { | |
$model->setIsSystem(0); | |
diff --git a/app/code/core/Mage/Adminhtml/etc/config.xml b/app/code/core/Mage/Adminhtml/etc/config.xml | |
index a088550..92829f6 100644 | |
--- a/app/code/core/Mage/Adminhtml/etc/config.xml | |
+++ b/app/code/core/Mage/Adminhtml/etc/config.xml | |
@@ -191,13 +191,18 @@ | |
<dashboard> | |
<enable_charts>1</enable_charts> | |
</dashboard> | |
+ <catalog> | |
+ <frontend> | |
+ <allowed_html_tags_list>a,abbr,acronym,address,applet,area,base,basefont,bdo,big,blockquote,br,button,caption,center,cite,code,col,colgroup,dd,del,dfn,dir,div,dl,dt,em,i,fieldset,font,form,frame,frameset,h1,h2,h3,h4,h5,h6,hr,img,input,ins,kbd,label,legend,li,map,menu,meta,noscript,ol,optgroup,option,p,param,pre,q,s,samp,select,small,span,strike,strong,b,sub,sup,table,tbody,td,textarea,tfoot,th,thead,title,tr,tt,u,ul,var</allowed_html_tags_list> | |
+ </frontend> | |
+ </catalog> | |
</system> | |
<general> | |
<file> | |
<sitemap_generate_valid_paths> | |
<!-- This data should be merged with public_files_valid_paths --> | |
<available> | |
- <any_path>/*/sitemap.xml</any_path> | |
+ <any_path>/*/*.xml</any_path> | |
</available> | |
</sitemap_generate_valid_paths> | |
</file> | |
@@ -211,10 +216,13 @@ | |
</general> | |
<hints> | |
<store_switcher> | |
- <url><![CDATA[http://www.magentocommerce.com/knowledge-base/entry/understanding-store-scopes]]></url> | |
+ <url><![CDATA[http://merch.docs.magento.com/ce/user_guide/configuration/scope.html]]></url> | |
<enabled>1</enabled> | |
</store_switcher> | |
</hints> | |
+ <help> | |
+ <target_version>ce</target_version> | |
+ </help> | |
</default> | |
<stores> | |
<admin> | |
diff --git a/app/code/core/Mage/Adminhtml/etc/jstranslator.xml b/app/code/core/Mage/Adminhtml/etc/jstranslator.xml | |
index 9fae860..44dff5b 100644 | |
--- a/app/code/core/Mage/Adminhtml/etc/jstranslator.xml | |
+++ b/app/code/core/Mage/Adminhtml/etc/jstranslator.xml | |
@@ -26,6 +26,10 @@ | |
*/ | |
--> | |
<jstranslator> | |
+ <!-- validation.js --> | |
+ <validate-special-price translate="message" module="adminhtml"> | |
+ <message>The Special Price is active only when lower than the Actual Price.</message> | |
+ </validate-special-price> | |
<!-- flexuploader.js --> | |
<flexuploader-complete translate="message" module="adminhtml"> | |
<message>Complete</message> | |
diff --git a/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php b/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php | |
index 7dd517d..bfc6763 100644 | |
--- a/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php | |
+++ b/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php | |
@@ -288,13 +288,15 @@ abstract class Mage_Api_Model_Server_Handler_Abstract | |
} | |
if (method_exists($model, $method)) { | |
+ $result = array(); | |
if (isset($methodInfo->arguments) && ((string)$methodInfo->arguments) == 'array') { | |
- return $model->$method((is_array($args) ? $args : array($args))); | |
+ $result = $model->$method((is_array($args) ? $args : array($args))); | |
} elseif (!is_array($args)) { | |
- return $model->$method($args); | |
+ $result = $model->$method($args); | |
} else { | |
- return call_user_func_array(array(&$model, $method), $args); | |
+ $result = call_user_func_array(array(&$model, $method), $args); | |
} | |
+ return $this->processingMethodResult($result); | |
} else { | |
throw new Mage_Api_Exception('resource_path_not_callable'); | |
} | |
@@ -401,13 +403,15 @@ abstract class Mage_Api_Model_Server_Handler_Abstract | |
} | |
if (method_exists($model, $method)) { | |
+ $callResult = array(); | |
if (isset($methodInfo->arguments) && ((string)$methodInfo->arguments) == 'array') { | |
- $result[] = $model->$method((is_array($args) ? $args : array($args))); | |
+ $callResult = $model->$method((is_array($args) ? $args : array($args))); | |
} elseif (!is_array($args)) { | |
- $result[] = $model->$method($args); | |
+ $callResult = $model->$method($args); | |
} else { | |
- $result[] = call_user_func_array(array(&$model, $method), $args); | |
+ $callResult = call_user_func_array(array(&$model, $method), $args); | |
} | |
+ $result[] = $this->processingMethodResult($callResult); | |
} else { | |
throw new Mage_Api_Exception('resource_path_not_callable'); | |
} | |
@@ -543,4 +547,41 @@ abstract class Mage_Api_Model_Server_Handler_Abstract | |
$this->_startSession($sessionId); | |
return array_values($this->_getConfig()->getFaults()); | |
} | |
+ | |
+ /** | |
+ * Prepare Api data for XML exporting | |
+ * See allowed characters in XML: | |
+ * @link http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char | |
+ * | |
+ * @param array $result | |
+ * @return mixed | |
+ */ | |
+ public function processingMethodResult(array $result) | |
+ { | |
+ foreach ($result as &$row) { | |
+ if (!is_null($row) && !is_bool($row) && !is_numeric($row)) { | |
+ $row = $this->processingRow($row); | |
+ } | |
+ } | |
+ return $result; | |
+ } | |
+ | |
+ /** | |
+ * Prepare Api row data for XML exporting | |
+ * Convert not allowed symbol to numeric character reference | |
+ * | |
+ * @param $row | |
+ * @return mixed | |
+ */ | |
+ public function processingRow($row) | |
+ { | |
+ $row = preg_replace_callback( | |
+ '/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u', | |
+ function ($matches) { | |
+ return '&#' . Mage::helper('core/string')->uniOrd($matches[0]) . ';'; | |
+ }, | |
+ $row | |
+ ); | |
+ return $row; | |
+ } | |
} // Class Mage_Api_Model_Server_Handler_Abstract End | |
diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes.php | |
index 8cbef43..eb23487 100644 | |
--- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes.php | |
+++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes.php | |
@@ -121,6 +121,7 @@ class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes | |
$groupPrice->setRenderer( | |
$this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_group') | |
->setPriceColumnHeader(Mage::helper('bundle')->__('Percent Discount')) | |
+ ->setIsPercent(true) | |
->setPriceValidation('validate-greater-than-zero validate-percents') | |
); | |
} | |
diff --git a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php b/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php | |
index 140ed24..58f8ab9 100644 | |
--- a/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php | |
+++ b/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php | |
@@ -85,8 +85,13 @@ class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bun | |
$_canChangeQty = $_default->getSelectionCanChangeQty(); | |
} elseif (!$inPreConfigured && $selectedOptions && is_numeric($selectedOptions)) { | |
$selectedSelection = $_option->getSelectionById($selectedOptions); | |
- $_defaultQty = $selectedSelection->getSelectionQty() * 1; | |
- $_canChangeQty = $selectedSelection->getSelectionCanChangeQty(); | |
+ if ($selectedSelection) { | |
+ $_defaultQty = $selectedSelection->getSelectionQty() * 1; | |
+ $_canChangeQty = $selectedSelection->getSelectionCanChangeQty(); | |
+ } else { | |
+ $_defaultQty = $_selections[0]->getSelectionQty() * 1; | |
+ $_canChangeQty = $_selections[0]->getSelectionCanChangeQty(); | |
+ } | |
} elseif (!$this->_showSingle() || $inPreConfigured) { | |
$_defaultQty = $this->_getSelectedQty(); | |
$_canChangeQty = (bool)$_defaultQty; | |
diff --git a/app/code/core/Mage/Catalog/Block/Product/Abstract.php b/app/code/core/Mage/Catalog/Block/Product/Abstract.php | |
index 027d838..0723b55 100644 | |
--- a/app/code/core/Mage/Catalog/Block/Product/Abstract.php | |
+++ b/app/code/core/Mage/Catalog/Block/Product/Abstract.php | |
@@ -105,6 +105,16 @@ abstract class Mage_Catalog_Block_Product_Abstract extends Mage_Core_Block_Templ | |
protected $_mapRenderer = 'msrp'; | |
/** | |
+ * Get catalog product helper | |
+ * | |
+ * @return Mage_Catalog_Helper_Product | |
+ */ | |
+ public function getProductHelper() | |
+ { | |
+ return Mage::helper('catalog/product'); | |
+ } | |
+ | |
+ /** | |
* Retrieve url for add product to cart | |
* Will return product view page URL if product has required options | |
* | |
@@ -195,12 +205,7 @@ abstract class Mage_Catalog_Block_Product_Abstract extends Mage_Core_Block_Templ | |
*/ | |
public function getMinimalQty($product) | |
{ | |
- $stockItem = $product->getStockItem(); | |
- if ($stockItem) { | |
- return ($stockItem->getMinSaleQty() | |
- && $stockItem->getMinSaleQty() > 0 ? $stockItem->getMinSaleQty() * 1 : null); | |
- } | |
- return null; | |
+ return $this->getProductHelper()->getMinimalQty($product); | |
} | |
/** | |
diff --git a/app/code/core/Mage/Catalog/Block/Product/List.php b/app/code/core/Mage/Catalog/Block/Product/List.php | |
index 8bc5cb9..e1279fa 100644 | |
--- a/app/code/core/Mage/Catalog/Block/Product/List.php | |
+++ b/app/code/core/Mage/Catalog/Block/Product/List.php | |
@@ -62,16 +62,13 @@ class Mage_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_Abstrac | |
$this->setCategoryId(Mage::app()->getStore()->getRootCategoryId()); | |
} | |
- // if this is a product view page | |
if (Mage::registry('product')) { | |
- // get collection of categories this product is associated with | |
+ /** @var Mage_Catalog_Model_Resource_Category_Collection $categories */ | |
$categories = Mage::registry('product')->getCategoryCollection() | |
->setPage(1, 1) | |
->load(); | |
- // if the product is associated with any category | |
if ($categories->count()) { | |
- // show products from this category | |
- $this->setCategoryId(current($categories->getIterator())); | |
+ $this->setCategoryId($categories->getFirstItem()->getId()); | |
} | |
} | |
diff --git a/app/code/core/Mage/Catalog/Block/Product/View.php b/app/code/core/Mage/Catalog/Block/Product/View.php | |
index c444a6d..2f31de9 100644 | |
--- a/app/code/core/Mage/Catalog/Block/Product/View.php | |
+++ b/app/code/core/Mage/Catalog/Block/Product/View.php | |
@@ -141,62 +141,14 @@ class Mage_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_Abstrac | |
return Mage::helper('core')->jsonEncode($config); | |
} | |
- $_request = Mage::getSingleton('tax/calculation')->getDefaultRateRequest(); | |
/* @var $product Mage_Catalog_Model_Product */ | |
$product = $this->getProduct(); | |
- $_request->setProductClassId($product->getTaxClassId()); | |
- $defaultTax = Mage::getSingleton('tax/calculation')->getRate($_request); | |
- $_request = Mage::getSingleton('tax/calculation')->getRateRequest(); | |
- $_request->setProductClassId($product->getTaxClassId()); | |
- $currentTax = Mage::getSingleton('tax/calculation')->getRate($_request); | |
- | |
- $_regularPrice = $product->getPrice(); | |
- $_finalPrice = $product->getFinalPrice(); | |
- if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) { | |
- $_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true, | |
- null, null, null, null, null, false); | |
- $_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, false, | |
- null, null, null, null, null, false); | |
- } else { | |
- $_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true); | |
- $_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice); | |
- } | |
- $_tierPrices = array(); | |
- $_tierPricesInclTax = array(); | |
- foreach ($product->getTierPrice() as $tierPrice) { | |
- $_tierPrices[] = Mage::helper('core')->currency( | |
- Mage::helper('tax')->getPrice($product, (float)$tierPrice['website_price'], false) - $_priceExclTax | |
- , false, false); | |
- $_tierPricesInclTax[] = Mage::helper('core')->currency( | |
- Mage::helper('tax')->getPrice($product, (float)$tierPrice['website_price'], true) - $_priceInclTax | |
- , false, false); | |
- } | |
- $config = array( | |
- 'productId' => $product->getId(), | |
- 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), | |
- 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false', | |
- 'showIncludeTax' => Mage::helper('tax')->displayPriceIncludingTax(), | |
- 'showBothPrices' => Mage::helper('tax')->displayBothPrices(), | |
- 'productPrice' => Mage::helper('core')->currency($_finalPrice, false, false), | |
- 'productOldPrice' => Mage::helper('core')->currency($_regularPrice, false, false), | |
- 'priceInclTax' => Mage::helper('core')->currency($_priceInclTax, false, false), | |
- 'priceExclTax' => Mage::helper('core')->currency($_priceExclTax, false, false), | |
- /** | |
- * @var skipCalculate | |
- * @deprecated after 1.5.1.0 | |
- */ | |
- 'skipCalculate' => ($_priceExclTax != $_priceInclTax ? 0 : 1), | |
- 'defaultTax' => $defaultTax, | |
- 'currentTax' => $currentTax, | |
- 'idSuffix' => '_clone', | |
- 'oldPlusDisposition' => 0, | |
- 'plusDisposition' => 0, | |
- 'plusDispositionTax' => 0, | |
- 'oldMinusDisposition' => 0, | |
- 'minusDisposition' => 0, | |
- 'tierPrices' => $_tierPrices, | |
- 'tierPricesInclTax' => $_tierPricesInclTax, | |
+ /** @var Mage_Catalog_Helper_Product_Type_Composite $compositeProductHelper */ | |
+ $compositeProductHelper = $this->helper('catalog/product_type_composite'); | |
+ $config = array_merge( | |
+ $compositeProductHelper->prepareJsonGeneralConfig(), | |
+ $compositeProductHelper->prepareJsonProductConfig($product) | |
); | |
$responseObject = new Varien_Object(); | |
@@ -259,14 +211,7 @@ class Mage_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_Abstrac | |
$product = $this->getProduct(); | |
} | |
- $qty = $this->getMinimalQty($product); | |
- $config = $product->getPreconfiguredValues(); | |
- $configQty = $config->getQty(); | |
- if ($configQty > $qty) { | |
- $qty = $configQty; | |
- } | |
- | |
- return $qty; | |
+ return $this->getProductHelper()->getDefaultQty($product); | |
} | |
/** | |
diff --git a/app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php b/app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php | |
index ec48b25..c0088ba 100644 | |
--- a/app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php | |
+++ b/app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php | |
@@ -49,6 +49,16 @@ class Mage_Catalog_Block_Product_View_Type_Configurable extends Mage_Catalog_Blo | |
protected $_resPrices = array(); | |
/** | |
+ * Get helper for calculation purposes | |
+ * | |
+ * @return Mage_Catalog_Helper_Product_Type_Composite | |
+ */ | |
+ protected function _getHelper() | |
+ { | |
+ return $this->helper('catalog/product_type_composite'); | |
+ } | |
+ | |
+ /** | |
* Get allowed attributes | |
* | |
* @return array | |
@@ -91,7 +101,10 @@ class Mage_Catalog_Block_Product_View_Type_Configurable extends Mage_Catalog_Blo | |
$allProducts = $this->getProduct()->getTypeInstance(true) | |
->getUsedProducts(null, $this->getProduct()); | |
foreach ($allProducts as $product) { | |
- if ($product->isSaleable() || $skipSaleableCheck) { | |
+ if ($product->isSaleable() | |
+ || $skipSaleableCheck | |
+ || (!$product->getStockItem()->getIsInStock() | |
+ && Mage::helper('cataloginventory')->isShowOutOfStock())) { | |
$products[] = $product; | |
} | |
} | |
@@ -103,11 +116,12 @@ class Mage_Catalog_Block_Product_View_Type_Configurable extends Mage_Catalog_Blo | |
/** | |
* retrieve current store | |
* | |
+ * @deprecated | |
* @return Mage_Core_Model_Store | |
*/ | |
public function getCurrentStore() | |
{ | |
- return Mage::app()->getStore(); | |
+ return $this->_getHelper()->getCurrentStore(); | |
} | |
/** | |
@@ -138,10 +152,10 @@ class Mage_Catalog_Block_Product_View_Type_Configurable extends Mage_Catalog_Blo | |
$preconfiguredValues = $currentProduct->getPreconfiguredValues(); | |
$defaultValues = array(); | |
} | |
- | |
+ $productStock = array(); | |
foreach ($this->getAllowProducts() as $product) { | |
$productId = $product->getId(); | |
- | |
+ $productStock[$productId] = $product->getStockItem()->getIsInStock(); | |
foreach ($this->getAllowAttributes() as $attribute) { | |
$productAttribute = $attribute->getProductAttribute(); | |
$productAttributeId = $productAttribute->getId(); | |
@@ -189,7 +203,13 @@ class Mage_Catalog_Block_Product_View_Type_Configurable extends Mage_Catalog_Blo | |
$configurablePrice = $currentProduct->getConfigurablePrice(); | |
if (isset($options[$attributeId][$value['value_index']])) { | |
- $productsIndex = $options[$attributeId][$value['value_index']]; | |
+ $productsIndexOptions = $options[$attributeId][$value['value_index']]; | |
+ $productsIndex = array(); | |
+ foreach ($productsIndexOptions as $productIndex) { | |
+ if ($productStock[$productIndex]) { | |
+ $productsIndex[] = $productIndex; | |
+ } | |
+ } | |
} else { | |
$productsIndex = array(); | |
} | |
@@ -300,64 +320,51 @@ class Mage_Catalog_Block_Product_View_Type_Configurable extends Mage_Catalog_Blo | |
/** | |
* Calculation real price | |
* | |
+ * @deprecated | |
* @param float $price | |
* @param bool $isPercent | |
* @return mixed | |
*/ | |
protected function _preparePrice($price, $isPercent = false) | |
{ | |
- if ($isPercent && !empty($price)) { | |
- $price = $this->getProduct()->getFinalPrice() * $price / 100; | |
- } | |
- | |
- return $this->_registerJsPrice($this->_convertPrice($price, true)); | |
+ return $this->_getHelper()->preparePrice($this->getProduct(), $price, $isPercent); | |
} | |
/** | |
* Calculation price before special price | |
* | |
+ * @deprecated | |
* @param float $price | |
* @param bool $isPercent | |
* @return mixed | |
*/ | |
protected function _prepareOldPrice($price, $isPercent = false) | |
{ | |
- if ($isPercent && !empty($price)) { | |
- $price = $this->getProduct()->getPrice() * $price / 100; | |
- } | |
- | |
- return $this->_registerJsPrice($this->_convertPrice($price, true)); | |
+ return $this->_getHelper()->prepareOldPrice($this->getProduct(), $price, $isPercent); | |
} | |
/** | |
* Replace ',' on '.' for js | |
* | |
+ * @deprecated | |
* @param float $price | |
* @return string | |
*/ | |
protected function _registerJsPrice($price) | |
{ | |
- return str_replace(',', '.', $price); | |
+ return $this->_getHelper()->registerJsPrice($price); | |
} | |
/** | |
* Convert price from default currency to current currency | |
* | |
+ * @deprecated | |
* @param float $price | |
* @param boolean $round | |
* @return float | |
*/ | |
protected function _convertPrice($price, $round = false) | |
{ | |
- if (empty($price)) { | |
- return 0; | |
- } | |
- | |
- $price = $this->getCurrentStore()->convertPrice($price); | |
- if ($round) { | |
- $price = $this->getCurrentStore()->roundPrice($price); | |
- } | |
- | |
- return $price; | |
+ return $this->_getHelper()->convertPrice($price, $round); | |
} | |
} | |
diff --git a/app/code/core/Mage/Catalog/Helper/Product.php b/app/code/core/Mage/Catalog/Helper/Product.php | |
index a861e4d..0ac0ec5 100644 | |
--- a/app/code/core/Mage/Catalog/Helper/Product.php | |
+++ b/app/code/core/Mage/Catalog/Helper/Product.php | |
@@ -35,6 +35,8 @@ class Mage_Catalog_Helper_Product extends Mage_Core_Helper_Url | |
const XML_PATH_PRODUCT_URL_USE_CATEGORY = 'catalog/seo/product_use_categories'; | |
const XML_PATH_USE_PRODUCT_CANONICAL_TAG = 'catalog/seo/product_canonical_tag'; | |
+ const DEFAULT_QTY = 1; | |
+ | |
/** | |
* Flag that shows if Magento has to check product to be saleable (enabled and/or inStock) | |
* | |
@@ -485,4 +487,42 @@ class Mage_Catalog_Helper_Product extends Mage_Core_Helper_Url | |
{ | |
return $this->_skipSaleableCheck; | |
} | |
+ | |
+ /** | |
+ * Gets minimal sales quantity | |
+ * | |
+ * @param Mage_Catalog_Model_Product $product | |
+ * @return int|null | |
+ */ | |
+ public function getMinimalQty($product) | |
+ { | |
+ $stockItem = $product->getStockItem(); | |
+ if ($stockItem && $stockItem->getMinSaleQty()) { | |
+ return $stockItem->getMinSaleQty() * 1; | |
+ } | |
+ return null; | |
+ } | |
+ | |
+ /** | |
+ * Get default qty - either as preconfigured, or as 1. | |
+ * Also restricts it by minimal qty. | |
+ * | |
+ * @param Mage_Catalog_Model_Product $product | |
+ * @return int|float | |
+ */ | |
+ public function getDefaultQty($product) | |
+ { | |
+ $qty = $this->getMinimalQty($product); | |
+ $configQty = $product->getPreconfiguredValues()->getQty(); | |
+ | |
+ if ($product->isConfigurable() || $configQty > $qty) { | |
+ $qty = $configQty; | |
+ } | |
+ | |
+ if (is_null($qty)) { | |
+ $qty = self::DEFAULT_QTY; | |
+ } | |
+ | |
+ return $qty; | |
+ } | |
} | |
diff --git a/app/code/core/Mage/Catalog/Helper/Product/Type/Composite.php b/app/code/core/Mage/Catalog/Helper/Product/Type/Composite.php | |
new file mode 100644 | |
index 0000000..19d3e36 | |
--- /dev/null | |
+++ b/app/code/core/Mage/Catalog/Helper/Product/Type/Composite.php | |
@@ -0,0 +1,195 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Catalog | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+ | |
+/** | |
+ * Helper for preparing properties for configurable product | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Catalog | |
+ * @author Magento Core Team <core@magentocommerce.com> | |
+ */ | |
+class Mage_Catalog_Helper_Product_Type_Composite extends Mage_Core_Helper_Abstract | |
+{ | |
+ /** | |
+ * Calculation real price | |
+ * | |
+ * @param Mage_Catalog_Model_Product $product | |
+ * @param float $price | |
+ * @param bool $isPercent | |
+ * @param null|int $storeId | |
+ * @return mixed | |
+ */ | |
+ public function preparePrice($product, $price, $isPercent = false, $storeId = null) | |
+ { | |
+ if ($isPercent && !empty($price)) { | |
+ $price = $product->getFinalPrice() * $price / 100; | |
+ } | |
+ | |
+ return $this->registerJsPrice($this->convertPrice($price, true, $storeId)); | |
+ } | |
+ | |
+ /** | |
+ * Calculation price before special price | |
+ * | |
+ * @param Mage_Catalog_Model_Product $product | |
+ * @param float $price | |
+ * @param bool $isPercent | |
+ * @param null|int $storeId | |
+ * @return mixed | |
+ */ | |
+ public function prepareOldPrice($product, $price, $isPercent = false, $storeId = null) | |
+ { | |
+ if ($isPercent && !empty($price)) { | |
+ $price = $product->getPrice() * $price / 100; | |
+ } | |
+ | |
+ return $this->registerJsPrice($this->convertPrice($price, true, $storeId)); | |
+ } | |
+ | |
+ /** | |
+ * Replace ',' on '.' for js | |
+ * | |
+ * @param float $price | |
+ * @return string | |
+ */ | |
+ public function registerJsPrice($price) | |
+ { | |
+ return str_replace(',', '.', $price); | |
+ } | |
+ | |
+ /** | |
+ * Convert price from default currency to current currency | |
+ * | |
+ * @param float $price | |
+ * @param boolean $round | |
+ * @param null|int $storeId | |
+ * @return float | |
+ */ | |
+ public function convertPrice($price, $round = false, $storeId = null) | |
+ { | |
+ if (empty($price)) { | |
+ return 0; | |
+ } | |
+ | |
+ $price = $this->getCurrentStore($storeId)->convertPrice($price); | |
+ if ($round) { | |
+ $price = $this->getCurrentStore($storeId)->roundPrice($price); | |
+ } | |
+ | |
+ return $price; | |
+ } | |
+ | |
+ /** | |
+ * Retrieve current store | |
+ * | |
+ * @param null $storeId | |
+ * @return Mage_Core_Model_Store | |
+ */ | |
+ public function getCurrentStore($storeId = null) | |
+ { | |
+ return Mage::app()->getStore($storeId); | |
+ } | |
+ | |
+ /** | |
+ * Prepare general params for product to be used in getJsonConfig() | |
+ * @see Mage_Catalog_Block_Product_View::getJsonConfig() | |
+ * @see Mage_ConfigurableSwatches_Block_Catalog_Product_List_Price::getJsonConfig() | |
+ * | |
+ * @return array | |
+ */ | |
+ public function prepareJsonGeneralConfig() | |
+ { | |
+ return array( | |
+ 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), | |
+ 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false', | |
+ 'showIncludeTax' => Mage::helper('tax')->displayPriceIncludingTax(), | |
+ 'showBothPrices' => Mage::helper('tax')->displayBothPrices(), | |
+ 'idSuffix' => '', | |
+ 'oldPlusDisposition' => 0, | |
+ 'plusDisposition' => 0, | |
+ 'plusDispositionTax' => 0, | |
+ 'oldMinusDisposition' => 0, | |
+ 'minusDisposition' => 0, | |
+ ); | |
+ } | |
+ | |
+ | |
+ | |
+ /** | |
+ * Prepare product specific params to be used in getJsonConfig() | |
+ * @see Mage_Catalog_Block_Product_View::getJsonConfig() | |
+ * @see Mage_ConfigurableSwatches_Block_Catalog_Product_List_Price::getJsonConfig() | |
+ * | |
+ * @param Mage_Catalog_Model_Product $product | |
+ * @return array | |
+ */ | |
+ public function prepareJsonProductConfig($product) | |
+ { | |
+ $_request = Mage::getSingleton('tax/calculation')->getDefaultRateRequest(); | |
+ $_request->setProductClassId($product->getTaxClassId()); | |
+ $defaultTax = Mage::getSingleton('tax/calculation')->getRate($_request); | |
+ | |
+ $_request = Mage::getSingleton('tax/calculation')->getRateRequest(); | |
+ $_request->setProductClassId($product->getTaxClassId()); | |
+ $currentTax = Mage::getSingleton('tax/calculation')->getRate($_request); | |
+ | |
+ $_regularPrice = $product->getPrice(); | |
+ $_finalPrice = $product->getFinalPrice(); | |
+ if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) { | |
+ $_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true, | |
+ null, null, null, null, null, false); | |
+ $_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, false, | |
+ null, null, null, null, null, false); | |
+ } else { | |
+ $_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true); | |
+ $_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice); | |
+ } | |
+ $_tierPrices = array(); | |
+ $_tierPricesInclTax = array(); | |
+ foreach ($product->getTierPrice() as $tierPrice) { | |
+ $_tierPrices[] = Mage::helper('core')->currency( | |
+ Mage::helper('tax')->getPrice($product, (float)$tierPrice['website_price'], false) - $_priceExclTax | |
+ , false, false); | |
+ $_tierPricesInclTax[] = Mage::helper('core')->currency( | |
+ Mage::helper('tax')->getPrice($product, (float)$tierPrice['website_price'], true) - $_priceInclTax | |
+ , false, false); | |
+ } | |
+ | |
+ return array( | |
+ 'productId' => $product->getId(), | |
+ 'productPrice' => Mage::helper('core')->currency($_finalPrice, false, false), | |
+ 'productOldPrice' => Mage::helper('core')->currency($_regularPrice, false, false), | |
+ 'priceInclTax' => Mage::helper('core')->currency($_priceInclTax, false, false), | |
+ 'priceExclTax' => Mage::helper('core')->currency($_priceExclTax, false, false), | |
+ 'skipCalculate' => ($_priceExclTax != $_priceInclTax ? 0 : 1), | |
+ 'defaultTax' => $defaultTax, | |
+ 'currentTax' => $currentTax, | |
+ 'tierPrices' => $_tierPrices, | |
+ 'tierPricesInclTax' => $_tierPricesInclTax, | |
+ 'swatchPrices' => $product->getSwatchPrices(), | |
+ ); | |
+ } | |
+} | |
diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php | |
index a696fc9..70fadce 100644 | |
--- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php | |
+++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php | |
@@ -227,6 +227,7 @@ abstract class Mage_Catalog_Model_Product_Attribute_Backend_Groupprice_Abstract | |
$data = $this->_getResource()->loadPriceData($object->getId(), $websiteId); | |
foreach ($data as $k => $v) { | |
$data[$k]['website_price'] = $v['price']; | |
+ $data[$k]['is_percent'] = isset($v['is_percent']) ? isset($v['is_percent']) : 0; | |
if ($v['all_groups']) { | |
$data[$k]['cust_group'] = Mage_Customer_Model_Group::CUST_GROUP_ALL; | |
} | |
@@ -318,6 +319,7 @@ abstract class Mage_Catalog_Model_Product_Attribute_Backend_Groupprice_Abstract | |
'all_groups' => $useForAllGroups ? 1 : 0, | |
'customer_group_id' => $customerGroupId, | |
'value' => $data['price'], | |
+ 'is_percent' => isset($data['is_percent']) ? $data['is_percent'] : 0, | |
), $this->_getAdditionalUniqueFields($data)); | |
} | |
@@ -347,10 +349,11 @@ abstract class Mage_Catalog_Model_Product_Attribute_Backend_Groupprice_Abstract | |
if (!empty($update)) { | |
foreach ($update as $k => $v) { | |
- if ($old[$k]['price'] != $v['value']) { | |
+ if ($old[$k]['price'] != $v['value'] || $old[$k]['is_percent'] != $v['is_percent']) { | |
$price = new Varien_Object(array( | |
- 'value_id' => $old[$k]['price_id'], | |
- 'value' => $v['value'] | |
+ 'value_id' => $old[$k]['price_id'], | |
+ 'value' => $v['value'], | |
+ 'is_percent' => $v['is_percent'] | |
)); | |
$this->_getResource()->savePriceData($price); | |
diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php | |
index 5579b01..f7ea86e 100644 | |
--- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php | |
+++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php | |
@@ -643,8 +643,11 @@ class Mage_Catalog_Model_Product_Attribute_Backend_Media extends Mage_Eav_Model_ | |
} catch (Exception $e) { | |
$file = $this->_getConfig()->getMediaPath($file); | |
+ $io = new Varien_Io_File(); | |
Mage::throwException( | |
- Mage::helper('catalog')->__('Failed to copy file %s. Please, delete media with non-existing images and try again.', $file) | |
+ Mage::helper('catalog')->__( | |
+ 'Failed to copy file %s. Please, delete media with non-existing images and try again.', | |
+ $io->getFilteredPath($file)) | |
); | |
} | |
diff --git a/app/code/core/Mage/Catalog/Model/Product/Link/Api/V2.php b/app/code/core/Mage/Catalog/Model/Product/Link/Api/V2.php | |
index 5b59810..eca7486 100644 | |
--- a/app/code/core/Mage/Catalog/Model/Product/Link/Api/V2.php | |
+++ b/app/code/core/Mage/Catalog/Model/Product/Link/Api/V2.php | |
@@ -61,8 +61,8 @@ class Mage_Catalog_Model_Product_Link_Api_V2 extends Mage_Catalog_Model_Product_ | |
$links[(int)$linkedProductId] = array(); | |
foreach ($collection->getLinkModel()->getAttributes() as $attribute) { | |
- if (isset($data->$attribute['code'])) { | |
- $links[(int)$linkedProductId][$attribute['code']] = $data->$attribute['code']; | |
+ if (isset($data->{$attribute['code']})) { | |
+ $links[(int)$linkedProductId][$attribute['code']] = $data->{$attribute['code']}; | |
} | |
} | |
@@ -118,8 +118,8 @@ class Mage_Catalog_Model_Product_Link_Api_V2 extends Mage_Catalog_Model_Product_ | |
} | |
foreach ($collection->getLinkModel()->getAttributes() as $attribute) { | |
- if (isset($data->$attribute['code'])) { | |
- $links[(int)$linkedProductId][$attribute['code']] = $data->$attribute['code']; | |
+ if (isset($data->{$attribute['code']})) { | |
+ $links[(int)$linkedProductId][$attribute['code']] = $data->{$attribute['code']}; | |
} | |
} | |
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php | |
index a7302c9..4586140 100644 | |
--- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php | |
+++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php | |
@@ -359,7 +359,7 @@ class Mage_Catalog_Model_Resource_Eav_Attribute extends Mage_Eav_Model_Entity_At | |
if ($backendType == 'int' && $frontendInput == 'select') { | |
return true; | |
- } else if ($backendType == 'varchar' && $frontendInput == 'multiselect') { | |
+ } else if (($backendType == 'varchar' || $backendType == 'text') && $frontendInput == 'multiselect') { | |
return true; | |
} else if ($backendType == 'decimal') { | |
return true; | |
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice.php | |
index 0d3c4a1..390c58e 100644 | |
--- a/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice.php | |
+++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice.php | |
@@ -43,4 +43,17 @@ class Mage_Catalog_Model_Resource_Product_Attribute_Backend_Groupprice | |
{ | |
$this->_init('catalog/product_attribute_group_price', 'value_id'); | |
} | |
+ | |
+ /** | |
+ * Add is_percent column | |
+ * | |
+ * @param array $columns | |
+ * @return array | |
+ */ | |
+ protected function _loadPriceDataColumns($columns) | |
+ { | |
+ $columns = parent::_loadPriceDataColumns($columns); | |
+ $columns['is_percent'] = 'is_percent'; | |
+ return $columns; | |
+ } | |
} | |
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php | |
index 64009ac..00c7fdf 100644 | |
--- a/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php | |
+++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Source.php | |
@@ -61,7 +61,7 @@ class Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source | |
->where($this->_getIndexableAttributesCondition()); | |
if ($multiSelect == true) { | |
- $select->where('ea.backend_type = ?', 'varchar') | |
+ $select->where('ea.backend_type = ?', 'text') | |
->where('ea.frontend_input = ?', 'multiselect'); | |
} else { | |
$select->where('ea.backend_type = ?', 'int') | |
@@ -203,14 +203,14 @@ class Mage_Catalog_Model_Resource_Product_Indexer_Eav_Source | |
$productValueExpression = $adapter->getCheckSql('pvs.value_id > 0', 'pvs.value', 'pvd.value'); | |
$select = $adapter->select() | |
->from( | |
- array('pvd' => $this->getValueTable('catalog/product', 'varchar')), | |
+ array('pvd' => $this->getValueTable('catalog/product', 'text')), | |
array('entity_id', 'attribute_id')) | |
->join( | |
array('cs' => $this->getTable('core/store')), | |
'', | |
array('store_id')) | |
->joinLeft( | |
- array('pvs' => $this->getValueTable('catalog/product', 'varchar')), | |
+ array('pvs' => $this->getValueTable('catalog/product', 'text')), | |
'pvs.entity_id = pvd.entity_id AND pvs.attribute_id = pvd.attribute_id' | |
. ' AND pvs.store_id=cs.store_id', | |
array('value' => $productValueExpression)) | |
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Link/Product/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Link/Product/Collection.php | |
index d7a353f..fc8350a 100644 | |
--- a/app/code/core/Mage/Catalog/Model/Resource/Product/Link/Product/Collection.php | |
+++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Link/Product/Collection.php | |
@@ -283,6 +283,19 @@ class Mage_Catalog_Model_Resource_Product_Link_Product_Collection extends Mage_C | |
} | |
/** | |
+ * Get table alias for link model attribute | |
+ * | |
+ * @param string $attributeCode | |
+ * @param string $attributeType | |
+ * | |
+ * @return string | |
+ */ | |
+ protected function _getLinkAttributeTableAlias($attributeCode, $attributeType) | |
+ { | |
+ return sprintf('link_attribute_%s_%s', $attributeCode, $attributeType); | |
+ } | |
+ | |
+ /** | |
* Join attributes | |
* | |
* @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection | |
@@ -294,10 +307,9 @@ class Mage_Catalog_Model_Resource_Product_Link_Product_Collection extends Mage_C | |
} | |
$attributes = $this->getLinkModel()->getAttributes(); | |
- $attributesByType = array(); | |
foreach ($attributes as $attribute) { | |
$table = $this->getLinkModel()->getAttributeTypeTable($attribute['type']); | |
- $alias = sprintf('link_attribute_%s_%s', $attribute['code'], $attribute['type']); | |
+ $alias = $this->_getLinkAttributeTableAlias($attribute['code'], $attribute['type']); | |
$joinCondiotion = array( | |
"{$alias}.link_id = links.link_id", | |
@@ -331,4 +343,38 @@ class Mage_Catalog_Model_Resource_Product_Link_Product_Collection extends Mage_C | |
} | |
return parent::setOrder($attribute, $dir); | |
} | |
+ | |
+ /** | |
+ * Add specific link model attribute to collection filter | |
+ * | |
+ * @param string $attributeCode | |
+ * @param array|null $condition | |
+ * | |
+ * @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection | |
+ */ | |
+ public function addLinkModelFieldToFilter($attributeCode, $condition = null) | |
+ { | |
+ if (!$this->getProduct() || !$this->getProduct()->getId()) { | |
+ return $this; | |
+ } | |
+ | |
+ $attribute = null; | |
+ foreach ($this->getLinkModel()->getAttributes() as $attributeData) { | |
+ if ($attributeData['code'] == $attributeCode) { | |
+ $attribute = $attributeData; | |
+ break; | |
+ } | |
+ } | |
+ | |
+ if (!$attribute) { | |
+ return $this; | |
+ } | |
+ | |
+ $this->_hasLinkFilter = true; | |
+ | |
+ $field = $this->_getLinkAttributeTableAlias($attribute['code'], $attribute['type']) . '.value'; | |
+ $this->getSelect()->where($this->_getConditionSql($field, $condition)); | |
+ | |
+ return $this; | |
+ } | |
} | |
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php | |
index 4ffb021..8807ab8 100644 | |
--- a/app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php | |
+++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php | |
@@ -241,7 +241,7 @@ class Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection | |
} | |
$values = array(); | |
- | |
+ $sortOrder = 1; | |
foreach ($this->_items as $item) { | |
$productAttribute = $item->getProductAttribute(); | |
if (!($productAttribute instanceof Mage_Eav_Model_Entity_Attribute_Abstract)) { | |
@@ -251,7 +251,7 @@ class Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection | |
$optionsByValue = array(); | |
foreach ($options as $option) { | |
- $optionsByValue[$option['value']] = $option['label']; | |
+ $optionsByValue[$option['value']] = array('label' => $option['label'], 'order' => $sortOrder++); | |
} | |
foreach ($this->getProduct()->getTypeInstance(true) | |
@@ -267,18 +267,23 @@ class Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection | |
$values[$item->getId() . ':' . $optionValue] = array( | |
'product_super_attribute_id' => $item->getId(), | |
'value_index' => $optionValue, | |
- 'label' => $optionsByValue[$optionValue], | |
- 'default_label' => $optionsByValue[$optionValue], | |
- 'store_label' => $optionsByValue[$optionValue], | |
+ 'label' => $optionsByValue[$optionValue]['label'], | |
+ 'default_label' => $optionsByValue[$optionValue]['label'], | |
+ 'store_label' => $optionsByValue[$optionValue]['label'], | |
'is_percent' => 0, | |
'pricing_value' => null, | |
- 'use_default_value' => true | |
+ 'use_default_value' => true, | |
+ 'order' => $optionsByValue[$optionValue]['order'] | |
); | |
} | |
} | |
} | |
} | |
+ uasort($values, function($a, $b) { | |
+ return $a['order'] - $b['order']; | |
+ }); | |
+ | |
foreach ($pricings[0] as $pricing) { | |
// Addding pricing to options | |
$valueKey = $pricing['product_super_attribute_id'] . ':' . $pricing['value_index']; | |
diff --git a/app/code/core/Mage/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.19.1.3-1.6.0.0.19.1.4.php b/app/code/core/Mage/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.19.1.3-1.6.0.0.19.1.4.php | |
new file mode 100644 | |
index 0000000..f9aa8a3 | |
--- /dev/null | |
+++ b/app/code/core/Mage/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.19.1.3-1.6.0.0.19.1.4.php | |
@@ -0,0 +1,77 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Catalog | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+/** @var $installer Mage_Catalog_Model_Resource_Setup */ | |
+ | |
+$installer = $this; | |
+$installer->startSetup(); | |
+$connection = $installer->getConnection(); | |
+ | |
+$catalogProductEntityTypeId = Mage::getSingleton('eav/config')->getEntityType('catalog_product')->getEntityTypeId(); | |
+ | |
+$attributes = Mage::getResourceModel('eav/entity_attribute_collection') | |
+ ->addFieldToFilter('frontend_input', 'multiselect') | |
+ ->addFieldToFilter('entity_type_id', $catalogProductEntityTypeId) | |
+ ->getItems(); | |
+ | |
+foreach ($attributes as $attribute) { | |
+ $entityTypeId = $attribute->getEntityTypeId(); | |
+ $attributeId = $attribute->getId(); | |
+ $attributeTableOld = $installer->getAttributeTable($entityTypeId, $attributeId); | |
+ | |
+ $installer->updateAttribute($entityTypeId, $attributeId, 'backend_type', 'text'); | |
+ | |
+ $attributeTableNew = $installer->getAttributeTable($entityTypeId, $attributeId); | |
+ | |
+ if ($attributeTableOld != $attributeTableNew) { | |
+ $connection->disableTableKeys($attributeTableOld) | |
+ ->disableTableKeys($attributeTableNew); | |
+ | |
+ $select = $connection->select() | |
+ ->from($attributeTableOld, array('entity_type_id', 'attribute_id', 'store_id', 'entity_id', 'value')) | |
+ ->where('entity_type_id = ?', $entityTypeId) | |
+ ->where('attribute_id = ?', $attributeId); | |
+ | |
+ $query = $select->insertFromSelect($attributeTableNew, | |
+ array('entity_type_id', 'attribute_id', 'store_id', 'entity_id', 'value') | |
+ ); | |
+ | |
+ $connection->query($query); | |
+ | |
+ $connection->delete($attributeTableOld, | |
+ $connection->quoteInto('entity_type_id = ?', $entityTypeId) | |
+ . $connection->quoteInto(' AND attribute_id = ?', $attributeId) | |
+ ); | |
+ | |
+ $connection->enableTableKeys($attributeTableOld) | |
+ ->enableTableKeys($attributeTableNew); | |
+ } | |
+} | |
+ | |
+Mage::getModel('index/indexer') | |
+ ->getProcessByCode(Mage_Catalog_Helper_Product_Flat::CATALOG_FLAT_PROCESS_CODE) | |
+ ->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX); | |
+ | |
+$installer->endSetup(); | |
diff --git a/app/code/core/Mage/Catalog/etc/config.xml b/app/code/core/Mage/Catalog/etc/config.xml | |
index 0d8825c..779422f 100644 | |
--- a/app/code/core/Mage/Catalog/etc/config.xml | |
+++ b/app/code/core/Mage/Catalog/etc/config.xml | |
@@ -28,7 +28,7 @@ | |
<config> | |
<modules> | |
<Mage_Catalog> | |
- <version>1.6.0.0.19.1.2</version> | |
+ <version>1.6.0.0.19.1.5</version> | |
</Mage_Catalog> | |
</modules> | |
<admin> | |
diff --git a/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.19.1.2-1.6.0.0.19.1.3.php b/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.19.1.2-1.6.0.0.19.1.3.php | |
new file mode 100644 | |
index 0000000..5a4acc3 | |
--- /dev/null | |
+++ b/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.19.1.2-1.6.0.0.19.1.3.php | |
@@ -0,0 +1,44 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Catalog | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+ | |
+$installer = $this; | |
+/** @var $installer Mage_Catalog_Model_Resource_Setup */ | |
+ | |
+$attribute = 'special_price'; | |
+$installer | |
+ ->updateAttribute( | |
+ Mage_Catalog_Model_Product::ENTITY, | |
+ 'special_price', | |
+ 'note', | |
+ NULL | |
+ ) | |
+ ->updateAttribute( | |
+ Mage_Catalog_Model_Product::ENTITY, | |
+ 'special_price', | |
+ 'frontend_class', | |
+ 'validate-special-price' | |
+ ) | |
+; | |
diff --git a/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.19.1.4-1.6.0.0.19.1.5.php b/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.19.1.4-1.6.0.0.19.1.5.php | |
new file mode 100644 | |
index 0000000..56d90de | |
--- /dev/null | |
+++ b/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.19.1.4-1.6.0.0.19.1.5.php | |
@@ -0,0 +1,37 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_Catalog | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+ | |
+/** @var $installer Mage_Catalog_Model_Resource_Setup */ | |
+$installer = $this; | |
+$connection = $installer->getConnection(); | |
+ | |
+$connection->addColumn($installer->getTable('catalog/product_attribute_group_price'), 'is_percent', array( | |
+ 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, | |
+ 'unsigned' => true, | |
+ 'nullable' => false, | |
+ 'default' => '0', | |
+ 'comment' => 'Is Percent', | |
+)); | |
diff --git a/app/code/core/Mage/CatalogInventory/Model/Observer.php b/app/code/core/Mage/CatalogInventory/Model/Observer.php | |
index 18c5a19..ae4a7f9 100644 | |
--- a/app/code/core/Mage/CatalogInventory/Model/Observer.php | |
+++ b/app/code/core/Mage/CatalogInventory/Model/Observer.php | |
@@ -384,6 +384,7 @@ class Mage_CatalogInventory_Model_Observer | |
$stockItem = $option->getProduct()->getStockItem(); | |
if ($quoteItem->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) { | |
+ $stockItem->setParentItem($quoteItem); | |
$stockItem->setProductName($quoteItem->getName()); | |
} | |
diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php | |
index e186eec..d964430 100644 | |
--- a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php | |
+++ b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php | |
@@ -526,6 +526,27 @@ class Mage_CatalogInventory_Model_Stock_Item extends Mage_Core_Model_Abstract | |
} | |
/** | |
+ * Check if child product assigned to parent | |
+ */ | |
+ $parentItem = $this->getParentItem(); | |
+ if ($this->getIsChildItem() && !empty($parentItem)) { | |
+ $typeInstance = $parentItem->getProduct()->getTypeInstance(true); | |
+ $requiredChildrenIds = $typeInstance->getChildrenIds($parentItem->getProductId(), true); | |
+ $childrenIds = array(); | |
+ foreach ($requiredChildrenIds as $groupedChildrenIds) { | |
+ $childrenIds = array_merge($childrenIds, $groupedChildrenIds); | |
+ } | |
+ if (!in_array($this->getProductId(), $childrenIds)) { | |
+ $result->setHasError(true) | |
+ ->setMessage(Mage::helper('cataloginventory') | |
+ ->__('This product with current option is not available')) | |
+ ->setQuoteMessage(Mage::helper('cataloginventory')->__('Some of the products are not available')) | |
+ ->setQuoteMessageIndex('stock'); | |
+ return $result; | |
+ } | |
+ } | |
+ | |
+ /** | |
* Check quantity type | |
*/ | |
$result->setItemIsQtyDecimal($this->getIsQtyDecimal()); | |
diff --git a/app/code/core/Mage/CatalogRule/Model/Action/Index/Refresh.php b/app/code/core/Mage/CatalogRule/Model/Action/Index/Refresh.php | |
index b2d938e..eaea7e9 100644 | |
--- a/app/code/core/Mage/CatalogRule/Model/Action/Index/Refresh.php | |
+++ b/app/code/core/Mage/CatalogRule/Model/Action/Index/Refresh.php | |
@@ -319,8 +319,16 @@ class Mage_CatalogRule_Model_Action_Index_Refresh | |
); | |
$priceColumn = $this->_connection->getIfNullSql( | |
$this->_connection->getIfNullSql( | |
- 'pg.value', | |
- 'pgd.value' | |
+ $this->_connection->getCheckSql( | |
+ 'pg.is_percent = 1', | |
+ 'p.price * (100 - pg.value)/100', | |
+ 'pg.value' | |
+ ), | |
+ $this->_connection->getCheckSql( | |
+ 'pgd.is_percent = 1', | |
+ 'p.price * (100 - pgd.value)/100', | |
+ 'pgd.value' | |
+ ) | |
), | |
'p.price' | |
); | |
@@ -343,8 +351,22 @@ class Mage_CatalogRule_Model_Action_Index_Refresh | |
); | |
$priceColumn = $this->_connection->getIfNullSql( | |
$this->_connection->getIfNullSql( | |
- 'pg.value', | |
- 'pgd.value' | |
+ $this->_connection->getCheckSql( | |
+ 'pg.is_percent = 1', | |
+ $this->_connection->getIfNullSql( | |
+ 'p.value', | |
+ 'pd.value' | |
+ ) . ' * (100 - pg.value)/100', | |
+ 'pg.value' | |
+ ), | |
+ $this->_connection->getCheckSql( | |
+ 'pgd.is_percent = 1', | |
+ $this->_connection->getIfNullSql( | |
+ 'p.value', | |
+ 'pd.value' | |
+ ) . ' * (100 - pgd.value)/100', | |
+ 'pgd.value' | |
+ ) | |
), | |
$this->_connection->getIfNullSql( | |
'p.value', | |
diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Advanced.php b/app/code/core/Mage/CatalogSearch/Model/Resource/Advanced.php | |
index 6f04dbf..9680e42 100644 | |
--- a/app/code/core/Mage/CatalogSearch/Model/Resource/Advanced.php | |
+++ b/app/code/core/Mage/CatalogSearch/Model/Resource/Advanced.php | |
@@ -84,7 +84,7 @@ class Mage_CatalogSearch_Model_Resource_Advanced extends Mage_Core_Model_Resourc | |
if (is_array($value)) { | |
if (!empty($value['from']) || !empty($value['to'])) { // range | |
$condition = $value; | |
- } else if ($attribute->getBackendType() == 'varchar') { // multiselect | |
+ } else if (in_array($attribute->getBackendType(), array('varchar', 'text'))) { // multiselect | |
$condition = array('in_set' => $value); | |
} else if (!isset($value['from']) && !isset($value['to'])) { // select | |
$condition = array('in' => $value); | |
diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php b/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php | |
index 0c46266..20e9ffc 100644 | |
--- a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php | |
+++ b/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php | |
@@ -77,9 +77,10 @@ class Mage_CatalogSearch_Model_Resource_Fulltext extends Mage_Core_Model_Resourc | |
*/ | |
protected $_allowTableChanges = true; | |
- | |
- | |
- | |
+ /** | |
+ * @var array | |
+ */ | |
+ protected $_foundData = array(); | |
/** | |
* Init resource model | |
@@ -298,12 +299,7 @@ class Mage_CatalogSearch_Model_Resource_Fulltext extends Mage_Core_Model_Resourc | |
*/ | |
public function resetSearchResults() | |
{ | |
- $adapter = $this->_getWriteAdapter(); | |
- $adapter->update($this->getTable('catalogsearch/search_query'), array('is_processed' => 0)); | |
- $adapter->delete($this->getTable('catalogsearch/result')); | |
- | |
Mage::dispatchEvent('catalogsearch_reset_search_result'); | |
- | |
return $this; | |
} | |
@@ -334,39 +330,38 @@ class Mage_CatalogSearch_Model_Resource_Fulltext extends Mage_Core_Model_Resourc | |
public function prepareResult($object, $queryText, $query) | |
{ | |
$adapter = $this->_getWriteAdapter(); | |
- if (!$query->getIsProcessed()) { | |
- $searchType = $object->getSearchType($query->getStoreId()); | |
- | |
- $preparedTerms = Mage::getResourceHelper('catalogsearch') | |
- ->prepareTerms($queryText, $query->getMaxQueryWords()); | |
+ $searchType = $object->getSearchType($query->getStoreId()); | |
+ | |
+ $preparedTerms = Mage::getResourceHelper('catalogsearch') | |
+ ->prepareTerms($queryText, $query->getMaxQueryWords()); | |
+ | |
+ $bind = array(); | |
+ $like = array(); | |
+ $likeCond = ''; | |
+ if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE | |
+ || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE | |
+ ) { | |
+ $helper = Mage::getResourceHelper('core'); | |
+ $words = Mage::helper('core/string')->splitWords($queryText, true, $query->getMaxQueryWords()); | |
+ foreach ($words as $word) { | |
+ $like[] = $helper->getCILike('s.data_index', $word, array('position' => 'any')); | |
+ } | |
- $bind = array(); | |
- $like = array(); | |
- $likeCond = ''; | |
- if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE | |
- || $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE | |
- ) { | |
- $helper = Mage::getResourceHelper('core'); | |
- $words = Mage::helper('core/string')->splitWords($queryText, true, $query->getMaxQueryWords()); | |
- foreach ($words as $word) { | |
- $like[] = $helper->getCILike('s.data_index', $word, array('position' => 'any')); | |
- } | |
- if ($like) { | |
- $likeCond = '(' . join(' OR ', $like) . ')'; | |
- } | |
+ if ($like) { | |
+ $likeCond = '(' . join(' OR ', $like) . ')'; | |
} | |
+ | |
$mainTableAlias = 's'; | |
- $fields = array( | |
- 'query_id' => new Zend_Db_Expr($query->getId()), | |
- 'product_id', | |
- ); | |
+ $fields = array('product_id'); | |
+ | |
$select = $adapter->select() | |
->from(array($mainTableAlias => $this->getMainTable()), $fields) | |
->joinInner(array('e' => $this->getTable('catalog/product')), | |
'e.entity_id = s.product_id', | |
array()) | |
- ->where($mainTableAlias.'.store_id = ?', (int)$query->getStoreId()); | |
+ ->where($mainTableAlias . '.store_id = ?', (int)$query->getStoreId()); | |
+ $where = ""; | |
if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_FULLTEXT | |
|| $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE | |
) { | |
@@ -374,11 +369,10 @@ class Mage_CatalogSearch_Model_Resource_Fulltext extends Mage_Core_Model_Resourc | |
$where = Mage::getResourceHelper('catalogsearch') | |
->chooseFulltext($this->getMainTable(), $mainTableAlias, $select); | |
} | |
- | |
if ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE) { | |
- $where .= ($where ? ' OR ' : '') . $likeCond; | |
+ $where .= ($where ? ' OR ' : '') . $likeCond; | |
} elseif ($likeCond != '' && $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE) { | |
- $select->columns(array('relevance' => new Zend_Db_Expr(0))); | |
+ $select->columns(array('relevance' => new Zend_Db_Expr(0))); | |
$where = $likeCond; | |
} | |
@@ -386,19 +380,23 @@ class Mage_CatalogSearch_Model_Resource_Fulltext extends Mage_Core_Model_Resourc | |
$select->where($where); | |
} | |
- $sql = $adapter->insertFromSelect($select, | |
- $this->getTable('catalogsearch/result'), | |
- array(), | |
- Varien_Db_Adapter_Interface::INSERT_ON_DUPLICATE); | |
- $adapter->query($sql, $bind); | |
- | |
- $query->setIsProcessed(1); | |
+ $this->_foundData = $adapter->fetchPairs($select, $bind); | |
} | |
return $this; | |
} | |
/** | |
+ * Retrieve found data | |
+ * | |
+ * @return array | |
+ */ | |
+ public function getFoundData() | |
+ { | |
+ return $this->_foundData; | |
+ } | |
+ | |
+ /** | |
* Retrieve EAV Config Singleton | |
* | |
* @return Mage_Eav_Model_Config | |
diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php b/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php | |
index 23d5e81..bb364f2 100644 | |
--- a/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php | |
+++ b/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php | |
@@ -35,6 +35,39 @@ | |
class Mage_CatalogSearch_Model_Resource_Fulltext_Collection extends Mage_Catalog_Model_Resource_Product_Collection | |
{ | |
/** | |
+ * Name for relevance order | |
+ */ | |
+ const RELEVANCE_ORDER_NAME = 'relevance'; | |
+ | |
+ /** | |
+ * Found data | |
+ * | |
+ * @var array | |
+ */ | |
+ protected $_foundData = null; | |
+ | |
+ /** | |
+ * Sort order by relevance | |
+ * | |
+ * @var null | |
+ */ | |
+ protected $_relevanceSortOrder = SORT_DESC; | |
+ | |
+ /** | |
+ * Sort by relevance flag | |
+ * | |
+ * @var bool | |
+ */ | |
+ protected $_sortByRelevance = false; | |
+ | |
+ /** | |
+ * Is search filter applied flag | |
+ * | |
+ * @var bool | |
+ */ | |
+ protected $_isSearchFiltersApplied = false; | |
+ | |
+ /** | |
* Retrieve query model object | |
* | |
* @return Mage_CatalogSearch_Model_Query | |
@@ -47,22 +80,101 @@ class Mage_CatalogSearch_Model_Resource_Fulltext_Collection extends Mage_Catalog | |
/** | |
* Add search query filter | |
* | |
- * @param string $query | |
+ * @param $query | |
* @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection | |
*/ | |
public function addSearchFilter($query) | |
{ | |
- Mage::getSingleton('catalogsearch/fulltext')->prepareResult(); | |
- | |
- $this->getSelect()->joinInner( | |
- array('search_result' => $this->getTable('catalogsearch/result')), | |
- $this->getConnection()->quoteInto( | |
- 'search_result.product_id=e.entity_id AND search_result.query_id=?', | |
- $this->_getQuery()->getId() | |
- ), | |
- array('relevance' => 'relevance') | |
- ); | |
+ return $this; | |
+ } | |
+ /** | |
+ * Before load handler | |
+ * | |
+ * @return Mage_Catalog_Model_Resource_Product_Collection | |
+ */ | |
+ protected function _beforeLoad() | |
+ { | |
+ if (!$this->_isSearchFiltersApplied) { | |
+ $this->_applySearchFilters(); | |
+ } | |
+ | |
+ return parent::_beforeLoad(); | |
+ } | |
+ | |
+ /** | |
+ * Get collection size | |
+ * | |
+ * @return int | |
+ */ | |
+ public function getSize() | |
+ { | |
+ if (!$this->_isSearchFiltersApplied) { | |
+ $this->_applySearchFilters(); | |
+ } | |
+ | |
+ return parent::getSize(); | |
+ } | |
+ | |
+ /** | |
+ * Apply collection search filter | |
+ * | |
+ * @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection | |
+ */ | |
+ protected function _applySearchFilters() | |
+ { | |
+ $foundIds = $this->getFoundIds(); | |
+ if (!empty($foundIds)) { | |
+ $this->addIdFilter($foundIds); | |
+ } else { | |
+ $this->getSelect()->orWhere('FALSE'); | |
+ } | |
+ $this->_isSearchFiltersApplied = true; | |
+ | |
+ return $this; | |
+ } | |
+ | |
+ /** | |
+ * Get found products ids | |
+ * | |
+ * @return array | |
+ */ | |
+ public function getFoundIds() | |
+ { | |
+ if (is_null($this->_foundData)) { | |
+ /** @var Mage_CatalogSearch_Model_Fulltext $preparedResult */ | |
+ $preparedResult = Mage::getSingleton('catalogsearch/fulltext'); | |
+ $preparedResult->prepareResult(); | |
+ $this->_foundData = $preparedResult->getResource()->getFoundData(); | |
+ } | |
+ if (isset($this->_orders[self::RELEVANCE_ORDER_NAME])) { | |
+ $this->_resortFoundDataByRelevance(); | |
+ } | |
+ return array_keys($this->_foundData); | |
+ } | |
+ | |
+ /** | |
+ * Resort found data by relevance | |
+ * | |
+ * @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection | |
+ */ | |
+ protected function _resortFoundDataByRelevance() | |
+ { | |
+ if (is_array($this->_foundData)) { | |
+ $data = array(); | |
+ foreach ($this->_foundData as $id => $relevance) { | |
+ $this->_foundData[$id] = $relevance . '_' . $id; | |
+ } | |
+ natsort($this->_foundData); | |
+ if ($this->_relevanceSortOrder == SORT_DESC) { | |
+ $this->_foundData = array_reverse($this->_foundData); | |
+ } | |
+ foreach ($this->_foundData as $dataString) { | |
+ list ($relevance, $id) = explode('_', $dataString); | |
+ $data[$id] = $relevance; | |
+ } | |
+ $this->_foundData = $data; | |
+ } | |
return $this; | |
} | |
@@ -76,7 +188,8 @@ class Mage_CatalogSearch_Model_Resource_Fulltext_Collection extends Mage_Catalog | |
public function setOrder($attribute, $dir = 'desc') | |
{ | |
if ($attribute == 'relevance') { | |
- $this->getSelect()->order("relevance {$dir}"); | |
+ $this->_relevanceSortOrder = ($dir == 'asc') ? SORT_ASC : SORT_DESC; | |
+ $this->addOrder(self::RELEVANCE_ORDER_NAME); | |
} else { | |
parent::setOrder($attribute, $dir); | |
} | |
@@ -84,7 +197,34 @@ class Mage_CatalogSearch_Model_Resource_Fulltext_Collection extends Mage_Catalog | |
} | |
/** | |
- * Stub method for campatibility with other search engines | |
+ * Add sorting by relevance to select | |
+ * | |
+ * @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection | |
+ */ | |
+ protected function _addRelevanceSorting() | |
+ { | |
+ $foundIds = $this->getFoundIds(); | |
+ if (!$foundIds) { | |
+ return $this; | |
+ } | |
+ | |
+ /** @var Mage_CatalogSearch_Model_Resource_Helper_Mysql4 $resourceHelper */ | |
+ $resourceHelper = Mage::getResourceHelper('catalogsearch'); | |
+ $this->_select->order( | |
+ new Zend_Db_Expr( | |
+ $resourceHelper->getFieldOrderExpression( | |
+ 'e.' . $this->getResource()->getIdFieldName(), | |
+ $foundIds | |
+ ) | |
+ . ' ' . Zend_Db_Select::SQL_ASC | |
+ ) | |
+ ); | |
+ | |
+ return $this; | |
+ } | |
+ | |
+ /** | |
+ * Stub method for compatibility with other search engines | |
* | |
* @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection | |
*/ | |
@@ -92,4 +232,24 @@ class Mage_CatalogSearch_Model_Resource_Fulltext_Collection extends Mage_Catalog | |
{ | |
return $this; | |
} | |
+ | |
+ /** | |
+ * Render sql select orders | |
+ * | |
+ * @return Varien_Data_Collection_Db | |
+ */ | |
+ protected function _renderOrders() | |
+ { | |
+ if (!$this->_isOrdersRendered) { | |
+ foreach ($this->_orders as $attribute => $direction) { | |
+ if ($attribute == self::RELEVANCE_ORDER_NAME) { | |
+ $this->_addRelevanceSorting(); | |
+ } else { | |
+ $this->addAttributeToSort($attribute, $direction); | |
+ } | |
+ } | |
+ $this->_isOrdersRendered = true; | |
+ } | |
+ return $this; | |
+ } | |
} | |
diff --git a/app/code/core/Mage/CatalogSearch/Model/Resource/Helper/Mysql4.php b/app/code/core/Mage/CatalogSearch/Model/Resource/Helper/Mysql4.php | |
index 02f7324..0ca1cc4 100644 | |
--- a/app/code/core/Mage/CatalogSearch/Model/Resource/Helper/Mysql4.php | |
+++ b/app/code/core/Mage/CatalogSearch/Model/Resource/Helper/Mysql4.php | |
@@ -52,6 +52,7 @@ class Mage_CatalogSearch_Model_Resource_Helper_Mysql4 extends Mage_Eav_Model_Res | |
* Prepare Terms | |
* | |
* @param string $str The source string | |
+ * @param int $maxWordLength | |
* @return array(0=>words, 1=>terms) | |
*/ | |
function prepareTerms($str, $maxWordLength = 0) | |
@@ -112,10 +113,24 @@ class Mage_CatalogSearch_Model_Resource_Helper_Mysql4 extends Mage_Eav_Model_Res | |
* | |
* @param mixed $table The table to insert data into. | |
* @param array $data Column-value pairs or array of column-value pairs. | |
- * @param arrat $fields update fields pairs or values | |
+ * @param array $fields update fields pairs or values | |
* @return int The number of affected rows. | |
*/ | |
public function insertOnDuplicate($table, array $data, array $fields = array()) { | |
return $this->_getWriteAdapter()->insertOnDuplicate($table, $data, $fields); | |
} | |
+ | |
+ /** | |
+ * Get field expression for order by | |
+ * | |
+ * @param string $fieldName | |
+ * @param array $orderedIds | |
+ * | |
+ * @return string | |
+ */ | |
+ public function getFieldOrderExpression($fieldName, array $orderedIds) | |
+ { | |
+ $fieldName = $this->_getWriteAdapter()->quoteIdentifier($fieldName); | |
+ return "FIELD({$fieldName}, {$this->_getReadAdapter()->quote($orderedIds)})"; | |
+ } | |
} | |
diff --git a/app/code/core/Mage/Centinel/Model/Api/Client.php b/app/code/core/Mage/Centinel/Model/Api/Client.php | |
index e91a482..4493ad3 100644 | |
--- a/app/code/core/Mage/Centinel/Model/Api/Client.php | |
+++ b/app/code/core/Mage/Centinel/Model/Api/Client.php | |
@@ -20,7 +20,7 @@ | |
* | |
* @category Mage | |
* @package Mage_Centinel | |
- * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com) | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
*/ | |
diff --git a/app/code/core/Mage/Checkout/Model/Cart.php b/app/code/core/Mage/Checkout/Model/Cart.php | |
index 49154f0..186078a 100644 | |
--- a/app/code/core/Mage/Checkout/Model/Cart.php | |
+++ b/app/code/core/Mage/Checkout/Model/Cart.php | |
@@ -229,10 +229,6 @@ class Mage_Checkout_Model_Cart extends Varien_Object implements Mage_Checkout_Mo | |
$request = new Varien_Object($requestInfo); | |
} | |
- if (!$request->hasQty()) { | |
- $request->setQty(1); | |
- } | |
- | |
return $request; | |
} | |
@@ -248,14 +244,21 @@ class Mage_Checkout_Model_Cart extends Varien_Object implements Mage_Checkout_Mo | |
$product = $this->_getProduct($productInfo); | |
$request = $this->_getProductRequest($requestInfo); | |
+ /** @var Mage_Catalog_Helper_Product $helper */ | |
+ $helper = Mage::helper('catalog/product'); | |
+ | |
+ if (!$request->hasQty()) { | |
+ $request->setQty($helper->getDefaultQty($product)); | |
+ } | |
+ | |
$productId = $product->getId(); | |
- if ($product->getStockItem()) { | |
+ if (!$product->isConfigurable() && $product->getStockItem()) { | |
$minimumQty = $product->getStockItem()->getMinSaleQty(); | |
//If product was not found in cart and there is set minimal qty for it | |
if ($minimumQty && $minimumQty > 0 && $request->getQty() < $minimumQty | |
&& !$this->getQuote()->hasProductId($productId) | |
- ){ | |
+ ) { | |
$request->setQty($minimumQty); | |
} | |
} | |
diff --git a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php | |
index 29f0edc..a682c76 100644 | |
--- a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php | |
+++ b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php | |
@@ -308,6 +308,9 @@ class Mage_Checkout_Model_Type_Multishipping extends Mage_Checkout_Model_Type_Ab | |
if (!$quoteAddress = $this->getQuote()->getShippingAddressByCustomerAddressId($address->getId())) { | |
$quoteAddress = Mage::getModel('sales/quote_address')->importCustomerAddress($address); | |
$this->getQuote()->addShippingAddress($quoteAddress); | |
+ if ($couponCode = $this->getCheckoutSession()->getCartCouponCode()) { | |
+ $this->getQuote()->setCouponCode($couponCode); | |
+ } | |
} | |
$quoteAddress = $this->getQuote()->getShippingAddressByCustomerAddressId($address->getId()); | |
diff --git a/app/code/core/Mage/Checkout/Model/Type/Onepage.php b/app/code/core/Mage/Checkout/Model/Type/Onepage.php | |
index d673dc0..5cc305d 100644 | |
--- a/app/code/core/Mage/Checkout/Model/Type/Onepage.php | |
+++ b/app/code/core/Mage/Checkout/Model/Type/Onepage.php | |
@@ -362,6 +362,7 @@ class Mage_Checkout_Model_Type_Onepage | |
->setShippingMethod($shippingMethod) | |
->setCollectShippingRates(true); | |
$this->getCheckout()->setStepData('shipping', 'complete', true); | |
+ $this->_setCartCouponCode(); | |
break; | |
} | |
} | |
@@ -592,6 +593,8 @@ class Mage_Checkout_Model_Type_Onepage | |
return array('error' => 1, 'message' => $validateRes); | |
} | |
+ $this->_setCartCouponCode(); | |
+ | |
$this->getQuote()->collectTotals()->save(); | |
$this->getCheckout() | |
@@ -946,4 +949,17 @@ class Mage_Checkout_Model_Type_Onepage | |
} | |
return $orderId; | |
} | |
+ | |
+ /** | |
+ * Sets cart coupon code from checkout to quote | |
+ * | |
+ * @return $this | |
+ */ | |
+ protected function _setCartCouponCode() | |
+ { | |
+ if ($couponCode = $this->getCheckout()->getCartCouponCode()) { | |
+ $this->getQuote()->setCouponCode($couponCode); | |
+ } | |
+ return $this; | |
+ } | |
} | |
diff --git a/app/code/core/Mage/Checkout/controllers/CartController.php b/app/code/core/Mage/Checkout/controllers/CartController.php | |
index 2aa0e09..5b07975 100644 | |
--- a/app/code/core/Mage/Checkout/controllers/CartController.php | |
+++ b/app/code/core/Mage/Checkout/controllers/CartController.php | |
@@ -89,7 +89,10 @@ class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action | |
) { | |
$this->getResponse()->setRedirect($backUrl); | |
} else { | |
- if ((strtolower($this->getRequest()->getActionName()) == 'add') && !$this->getRequest()->getParam('in_cart')) { | |
+ if ( | |
+ (strtolower($this->getRequest()->getActionName()) == 'add') | |
+ && !$this->getRequest()->getParam('in_cart') | |
+ ) { | |
$this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl()); | |
} | |
$this->_redirect('checkout/cart'); | |
@@ -141,6 +144,20 @@ class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action | |
$cart = $this->_getCart(); | |
if ($cart->getQuote()->getItemsCount()) { | |
$cart->init(); | |
+ if ( | |
+ $cart->getQuote()->getShippingAddress() | |
+ && $this->_getSession()->getEstimatedShippingAddressData() | |
+ && $couponCode = $this->_getSession()->getCartCouponCode() | |
+ ) { | |
+ $estimatedSessionAddressData = $this->_getSession()->getEstimatedShippingAddressData(); | |
+ $cart->getQuote()->getShippingAddress() | |
+ ->setCountryId($estimatedSessionAddressData['country_id']) | |
+ ->setCity($estimatedSessionAddressData['city']) | |
+ ->setPostcode($estimatedSessionAddressData['postcode']) | |
+ ->setRegionId($estimatedSessionAddressData['region_id']) | |
+ ->setRegion($estimatedSessionAddressData['region']); | |
+ $cart->getQuote()->setCouponCode($couponCode); | |
+ } | |
$cart->save(); | |
if (!$this->_getQuote()->validateMinimumAmount()) { | |
@@ -526,6 +543,13 @@ class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action | |
->setRegion($region) | |
->setCollectShippingRates(true); | |
$this->_getQuote()->save(); | |
+ $this->_getSession()->setEstimatedShippingAddressData(array( | |
+ 'country_id' => $country, | |
+ 'postcode' => $postcode, | |
+ 'city' => $city, | |
+ 'region_id' => $regionId, | |
+ 'region' => $region | |
+ )); | |
$this->_goBack(); | |
} | |
@@ -581,6 +605,7 @@ class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action | |
$this->_getSession()->addSuccess( | |
$this->__('Coupon code "%s" was applied.', Mage::helper('core')->escapeHtml($couponCode)) | |
); | |
+ $this->_getSession()->setCartCouponCode($couponCode); | |
} else { | |
$this->_getSession()->addError( | |
$this->__('Coupon code "%s" is not valid.', Mage::helper('core')->escapeHtml($couponCode)) | |
diff --git a/app/code/core/Mage/Checkout/controllers/OnepageController.php b/app/code/core/Mage/Checkout/controllers/OnepageController.php | |
index 5517fbb..0f1879e 100644 | |
--- a/app/code/core/Mage/Checkout/controllers/OnepageController.php | |
+++ b/app/code/core/Mage/Checkout/controllers/OnepageController.php | |
@@ -334,8 +334,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
$address = $this->getOnepage()->getAddress($addressId); | |
if (Mage::getSingleton('customer/session')->getCustomer()->getId() == $address->getCustomerId()) { | |
- $this->getResponse()->setHeader('Content-type', 'application/x-json'); | |
- $this->getResponse()->setBody($address->toJson()); | |
+ $this->_prepareDataJSON($address->toArray()); | |
} else { | |
$this->getResponse()->setHeader('HTTP/1.1','403 Forbidden'); | |
} | |
@@ -353,7 +352,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
if ($this->getRequest()->isPost()) { | |
$method = $this->getRequest()->getPost('method'); | |
$result = $this->getOnepage()->saveCheckoutMethod($method); | |
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
+ $this->_prepareDataJSON($result); | |
} | |
} | |
@@ -395,7 +394,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
} | |
} | |
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
+ $this->_prepareDataJSON($result); | |
} | |
} | |
@@ -419,7 +418,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
'html' => $this->_getShippingMethodsHtml() | |
); | |
} | |
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
+ $this->_prepareDataJSON($result); | |
} | |
} | |
@@ -442,7 +441,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
'request' => $this->getRequest(), | |
'quote' => $this->getOnepage()->getQuote())); | |
$this->getOnepage()->getQuote()->collectTotals(); | |
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
+ $this->_prepareDataJSON($result); | |
$result['goto_section'] = 'payment'; | |
$result['update_section'] = array( | |
@@ -451,7 +450,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
); | |
} | |
$this->getOnepage()->getQuote()->collectTotals()->save(); | |
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
+ $this->_prepareDataJSON($result); | |
} | |
} | |
@@ -498,7 +497,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
Mage::logException($e); | |
$result['error'] = $this->__('Unable to set Payment Method.'); | |
} | |
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
+ $this->_prepareDataJSON($result); | |
} | |
/** | |
@@ -561,7 +560,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
$result['success'] = false; | |
$result['error'] = true; | |
$result['error_messages'] = $this->__('Please agree to all the terms and conditions before placing the order.'); | |
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
+ $this->_prepareDataJSON($result); | |
return; | |
} | |
} | |
@@ -630,7 +629,7 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
$result['redirect'] = $redirectUrl; | |
} | |
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
+ $this->_prepareDataJSON($result); | |
} | |
/** | |
@@ -657,4 +656,17 @@ class Mage_Checkout_OnepageController extends Mage_Checkout_Controller_Action | |
|| Mage::helper('checkout')->isAllowedGuestCheckout($this->getOnepage()->getQuote()) | |
|| !Mage::helper('checkout')->isCustomerMustBeLogged(); | |
} | |
+ | |
+ /** | |
+ * Prepare JSON formatted data for response to client | |
+ * | |
+ * @param $response | |
+ * @return Zend_Controller_Response_Abstract | |
+ */ | |
+ protected function _prepareDataJSON($response) | |
+ { | |
+ $this->getResponse()->setHeader('Content-type', 'application/json', true); | |
+ return $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response)); | |
+ } | |
+ | |
} | |
diff --git a/app/code/core/Mage/Cms/Block/Page.php b/app/code/core/Mage/Cms/Block/Page.php | |
index 9da2ce6..0fb0f0c 100644 | |
--- a/app/code/core/Mage/Cms/Block/Page.php | |
+++ b/app/code/core/Mage/Cms/Block/Page.php | |
@@ -63,14 +63,28 @@ class Mage_Cms_Block_Page extends Mage_Core_Block_Abstract | |
protected function _prepareLayout() | |
{ | |
$page = $this->getPage(); | |
+ $breadcrumbsArray = array(); | |
// show breadcrumbs | |
if (Mage::getStoreConfig('web/default/show_cms_breadcrumbs') | |
&& ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) | |
&& ($page->getIdentifier()!==Mage::getStoreConfig('web/default/cms_home_page')) | |
&& ($page->getIdentifier()!==Mage::getStoreConfig('web/default/cms_no_route'))) { | |
- $breadcrumbs->addCrumb('home', array('label'=>Mage::helper('cms')->__('Home'), 'title'=>Mage::helper('cms')->__('Go to Home Page'), 'link'=>Mage::getBaseUrl())); | |
- $breadcrumbs->addCrumb('cms_page', array('label'=>$page->getTitle(), 'title'=>$page->getTitle())); | |
+ $breadcrumbsArray[] = array( | |
+ 'crumbName' => 'home', | |
+ 'crumbInfo' => array( | |
+ 'label' => Mage::helper('cms')->__('Home'), | |
+ 'title' => Mage::helper('cms')->__('Go to Home Page'), | |
+ 'link' => Mage::getBaseUrl() | |
+ ) | |
+ ); | |
+ $breadcrumbsArray[] = array( | |
+ 'crumbName' => 'cms_page', | |
+ 'crumbInfo' => array( | |
+ 'label' => $page->getTitle(), | |
+ 'title' => $page->getTitle() | |
+ ) | |
+ ); | |
} | |
$root = $this->getLayout()->getBlock('root'); | |
@@ -85,6 +99,14 @@ class Mage_Cms_Block_Page extends Mage_Core_Block_Abstract | |
$head->setDescription($page->getMetaDescription()); | |
} | |
+ $breadcrumbsObject = new Varien_Object(); | |
+ $breadcrumbsObject->setCrumbs($breadcrumbsArray); | |
+ | |
+ Mage::dispatchEvent('cms_generate_breadcrumbs', array('breadcrumbs' => $breadcrumbsObject)); | |
+ | |
+ foreach ($breadcrumbsObject->getCrumbs() as $breadcrumbsItem) { | |
+ $breadcrumbs->addCrumb($breadcrumbsItem['crumbName'], $breadcrumbsItem['crumbInfo']); | |
+ } | |
return parent::_prepareLayout(); | |
} | |
diff --git a/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php b/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php | |
index 82d538e..c8b38bc 100644 | |
--- a/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php | |
+++ b/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php | |
@@ -222,7 +222,8 @@ class Mage_Cms_Helper_Wysiwyg_Images extends Mage_Core_Helper_Abstract | |
} | |
$io = new Varien_Io_File(); | |
if (!$io->isWriteable($currentPath) && !$io->mkdir($currentPath)) { | |
- $message = Mage::helper('cms')->__('The directory %s is not writable by server.',$currentPath); | |
+ $message = Mage::helper('cms')->__('The directory %s is not writable by server.', | |
+ $io->getFilteredPath($currentPath)); | |
Mage::throwException($message); | |
} | |
$this->_currentPath = $currentPath; | |
diff --git a/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php | |
index e28e1ea..572817b 100644 | |
--- a/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php | |
+++ b/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php | |
@@ -227,17 +227,18 @@ class Mage_Cms_Model_Wysiwyg_Images_Storage extends Varien_Object | |
$rootCmp = rtrim($this->getHelper()->getStorageRoot(), DS); | |
$pathCmp = rtrim($path, DS); | |
+ $io = new Varien_Io_File(); | |
+ | |
if ($rootCmp == $pathCmp) { | |
- Mage::throwException(Mage::helper('cms')->__('Cannot delete root directory %s.', $path)); | |
+ Mage::throwException(Mage::helper('cms')->__('Cannot delete root directory %s.', | |
+ $io->getFilteredPath($path))); | |
} | |
- $io = new Varien_Io_File(); | |
- | |
if (Mage::helper('core/file_storage_database')->checkDbUsage()) { | |
Mage::getModel('core/file_storage_directory_database')->deleteDirectory($path); | |
} | |
if (!$io->rmdir($path, true)) { | |
- Mage::throwException(Mage::helper('cms')->__('Cannot delete directory %s.', $path)); | |
+ Mage::throwException(Mage::helper('cms')->__('Cannot delete directory %s.', $io->getFilteredPath($path))); | |
} | |
if (strpos($pathCmp, $rootCmp) === 0) { | |
diff --git a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/List/Price.php b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/List/Price.php | |
new file mode 100644 | |
index 0000000..020a7b3 | |
--- /dev/null | |
+++ b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/List/Price.php | |
@@ -0,0 +1,95 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_ConfigurableSwatches | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+ | |
+class Mage_ConfigurableSwatches_Block_Catalog_Product_List_Price extends Mage_Core_Block_Template | |
+{ | |
+ /** | |
+ * @var string | |
+ */ | |
+ protected $_template = 'configurableswatches/catalog/product/list/price/js.phtml'; | |
+ | |
+ /** | |
+ * Get target product IDs from product collection | |
+ * which was set on block | |
+ * | |
+ * @return Mage_Eav_Model_Entity_Collection_Abstract | |
+ */ | |
+ protected function getProducts() | |
+ { | |
+ return $this->getProductCollection(); | |
+ } | |
+ | |
+ /** | |
+ * Get configuration for configurable swatches price change | |
+ * | |
+ * @return string | |
+ */ | |
+ public function getJsonConfig() | |
+ { | |
+ /** @var Mage_Catalog_Helper_Product_Type_Composite $compositeProductHelper */ | |
+ $compositeProductHelper = $this->helper('catalog/product_type_composite'); | |
+ | |
+ $config = array( | |
+ 'generalConfig' => $compositeProductHelper->prepareJsonGeneralConfig() | |
+ ); | |
+ foreach ($this->getProducts() as $product) { | |
+ /** @var $product Mage_Catalog_Model_Product */ | |
+ if (!$product->getSwatchPrices()) { | |
+ continue; | |
+ } | |
+ | |
+ $config['products'][$product->getId()] = $compositeProductHelper->prepareJsonProductConfig($product); | |
+ $config['products'][$product->getId()]['swatchPrices'] = $product->getSwatchPrices(); | |
+ | |
+ $responseObject = new Varien_Object(); | |
+ Mage::dispatchEvent('catalog_product_view_config', array( | |
+ 'response_object' => $responseObject, | |
+ 'product' => $product, | |
+ )); | |
+ if (is_array($responseObject->getAdditionalOptions())) { | |
+ foreach ($responseObject->getAdditionalOptions() as $option => $value) { | |
+ $config['products'][$product->getId()][$option] = $value; | |
+ } | |
+ } | |
+ } | |
+ return $this->helper('core')->jsonEncode($config); | |
+ } | |
+ | |
+ /** | |
+ * Disable output if all preconditions doesn't meet | |
+ * | |
+ * @return string | |
+ */ | |
+ protected function _toHtml() | |
+ { | |
+ if (!$this->helper('configurableswatches/list_price')->isEnabled()) { | |
+ return ''; | |
+ } | |
+ | |
+ return parent::_toHtml(); | |
+ } | |
+ | |
+} | |
diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php | |
index 203a48c..540caf0 100644 | |
--- a/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php | |
+++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php | |
@@ -92,7 +92,10 @@ class Mage_ConfigurableSwatches_Helper_Data extends Mage_Core_Helper_Abstract | |
public function getSwatchAttributeIds() | |
{ | |
if (is_null($this->_configAttributeIds)) { | |
- $this->_configAttributeIds = explode(',', Mage::getStoreConfig(self::CONFIG_PATH_SWATCH_ATTRIBUTES)); | |
+ $this->_configAttributeIds = array(); | |
+ if (Mage::getStoreConfig(self::CONFIG_PATH_SWATCH_ATTRIBUTES)) { | |
+ $this->_configAttributeIds = explode(',', Mage::getStoreConfig(self::CONFIG_PATH_SWATCH_ATTRIBUTES)); | |
+ } | |
} | |
return $this->_configAttributeIds; | |
} | |
@@ -111,4 +114,27 @@ class Mage_ConfigurableSwatches_Helper_Data extends Mage_Core_Helper_Abstract | |
$configAttrs = $this->getSwatchAttributeIds(); | |
return in_array($attr, $configAttrs); | |
} | |
+ | |
+ /** | |
+ * Get swatches product javascript | |
+ * | |
+ * @return string | |
+ */ | |
+ public function getSwatchesProductJs() | |
+ { | |
+ /** | |
+ * @var $product Mage_Catalog_Model_Product | |
+ */ | |
+ $product = Mage::registry('current_product'); | |
+ if ($this->isEnabled() && $product) { | |
+ $configAttrs = $this->getSwatchAttributeIds(); | |
+ $configurableAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product); | |
+ foreach ($configurableAttributes as $configurableAttribute) { | |
+ if (in_array($configurableAttribute['attribute_id'], $configAttrs)) { | |
+ return 'js/configurableswatches/swatches-product.js'; | |
+ } | |
+ } | |
+ } | |
+ return ''; | |
+ } | |
} | |
diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/List/Price.php b/app/code/core/Mage/ConfigurableSwatches/Helper/List/Price.php | |
new file mode 100644 | |
index 0000000..c4ec318 | |
--- /dev/null | |
+++ b/app/code/core/Mage/ConfigurableSwatches/Helper/List/Price.php | |
@@ -0,0 +1,118 @@ | |
+<?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@magento.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.magento.com for more information. | |
+ * | |
+ * @category Mage | |
+ * @package Mage_ConfigurableSwatches | |
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com) | |
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
+ */ | |
+ | |
+/** | |
+ * Class implementing price change for swatches in product listing pages | |
+ */ | |
+class Mage_ConfigurableSwatches_Helper_List_Price extends Mage_Core_Helper_Abstract | |
+{ | |
+ /** | |
+ * Path to to check is it required to change prices | |
+ */ | |
+ const XML_PATH_SWATCH_PRICE = 'configswatches/general/product_list_price_change'; | |
+ | |
+ /** | |
+ * Set swatch_price on products where swatch option_id is set | |
+ * Depends on following product data: | |
+ * - product must have children products attached and be configurable by type | |
+ * | |
+ * @param array $products | |
+ * @param int $storeId | |
+ * @return void | |
+ */ | |
+ public function attachConfigurableProductChildrenPricesMapping(array $products, $storeId = null) | |
+ { | |
+ $listSwatchAttrId = Mage::helper('configurableswatches/productlist')->getSwatchAttributeId(); | |
+ $result = array(); | |
+ | |
+ foreach ($products as $product) { | |
+ /** @var $product Mage_Catalog_Model_Product */ | |
+ if ($product->getTypeId() !== Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE | |
+ && !is_array($product->getChildrenProducts()) | |
+ ) { | |
+ continue; | |
+ } | |
+ | |
+ /** @var Mage_Catalog_Model_Product_Type_Configurable $typeInstance */ | |
+ $typeInstance = $product->getTypeInstance(); | |
+ $allowedAttributes = $typeInstance->getConfigurableAttributeCollection($product); | |
+ foreach ($allowedAttributes as $attribute) { | |
+ /** @var $attribute Mage_Catalog_Model_Product_Type_Configurable_Attribute */ | |
+ if ($attribute->getAttributeId() !== $listSwatchAttrId) { | |
+ continue; | |
+ } | |
+ | |
+ foreach ($attribute->getPrices() as $attributePrice) { | |
+ $product->setConfigurablePrice( | |
+ $this->_getHelper()->preparePrice( | |
+ $product, | |
+ $attributePrice['pricing_value'], | |
+ $attributePrice['is_percent'], | |
+ $storeId | |
+ ) | |
+ ); | |
+ Mage::dispatchEvent( | |
+ 'catalog_product_type_configurable_price', | |
+ array('product' => $product) | |
+ ); | |
+ $configurablePrice = $product->getConfigurablePrice(); | |
+ $cofigurableSwatchesHelper = Mage::helper('configurableswatches'); | |
+ $result[$cofigurableSwatchesHelper::normalizeKey($attributePrice['store_label'])] = array( | |
+ 'price' => $configurablePrice, | |
+ 'oldPrice' => $this->_getHelper()->prepareOldPrice( | |
+ $product, | |
+ $attributePrice['pricing_value'], | |
+ $attributePrice['is_percent'], | |
+ $storeId | |
+ ), | |
+ ); | |
+ } | |
+ } | |
+ $product->setSwatchPrices($result); | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * Get helper for calculation purposes | |
+ * | |
+ * @return Mage_Catalog_Helper_Product_Type_Composite | |
+ */ | |
+ protected function _getHelper() | |
+ { | |
+ return Mage::helper('catalog/product_type_composite'); | |
+ } | |
+ | |
+ /** | |
+ * Check if option for swatches price change is enabled | |
+ * | |
+ * @return bool | |
+ */ | |
+ public function isEnabled() | |
+ { | |
+ return Mage::getStoreConfigFlag(self::XML_PATH_SWATCH_PRICE); | |
+ } | |
+ | |
+} | |
diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php | |
index f257b37..d078ee8 100644 | |
--- a/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php | |
+++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php | |
@@ -37,12 +37,39 @@ class Mage_ConfigurableSwatches_Helper_Mediafallback extends Mage_Core_Helper_Ab | |
* - product must have children products attached | |
* | |
* @param array $parentProducts | |
+ * @deprecated use $this->attachProductChildrenAttributeMapping() instead | |
* @param $storeId | |
* @return void | |
*/ | |
public function attachConfigurableProductChildrenAttributeMapping(array $parentProducts, $storeId) | |
{ | |
+ return $this->attachProductChildrenAttributeMapping($parentProducts, $storeId); | |
+ } | |
+ | |
+ /** | |
+ * Set child_attribute_label_mapping on products with attribute label -> product mapping | |
+ * Depends on following product data: | |
+ * - product must have children products attached | |
+ * | |
+ * @param array $parentProducts | |
+ * @param $storeId | |
+ * @param bool $onlyListAttributes | |
+ * @return void | |
+ */ | |
+ public function attachProductChildrenAttributeMapping(array $parentProducts, $storeId, $onlyListAttributes = false) | |
+ { | |
+ /** @var $listSwatchAttr Mage_Eav_Model_Attribute */ | |
$listSwatchAttr = Mage::helper('configurableswatches/productlist')->getSwatchAttribute(); | |
+ $swatchAttributeIds = array(); | |
+ if (!$onlyListAttributes) { | |
+ $swatchAttributeIds = Mage::helper('configurableswatches')->getSwatchAttributeIds(); | |
+ } | |
+ if ($listSwatchAttr->getId()) { | |
+ $swatchAttributeIds[] = $listSwatchAttr->getId(); | |
+ } | |
+ if (empty($swatchAttributeIds)) { | |
+ return; | |
+ } | |
$parentProductIds = array(); | |
/* @var $parentProduct Mage_Catalog_Model_Product */ | |
@@ -53,6 +80,7 @@ class Mage_ConfigurableSwatches_Helper_Mediafallback extends Mage_Core_Helper_Ab | |
$configAttributes = Mage::getResourceModel('configurableswatches/catalog_product_attribute_super_collection') | |
->addParentProductsFilter($parentProductIds) | |
->attachEavAttributes() | |
+ ->addFieldToFilter('eav_attributes.attribute_id', array('in' => $swatchAttributeIds)) | |
->setStoreId($storeId) | |
; | |
@@ -61,9 +89,15 @@ class Mage_ConfigurableSwatches_Helper_Mediafallback extends Mage_Core_Helper_Ab | |
$optionLabels += $attribute->getOptionLabels(); | |
} | |
+ // normalize to all lower case before we start using them | |
+ $optionLabels = array_map(function ($value) { | |
+ return array_map('Mage_ConfigurableSwatches_Helper_Data::normalizeKey', $value); | |
+ }, $optionLabels); | |
+ | |
foreach ($parentProducts as $parentProduct) { | |
$mapping = array(); | |
$listSwatchValues = array(); | |
+ $listSwatchStockValues = array(); | |
/* @var $attribute Mage_Catalog_Model_Product_Type_Configurable_Attribute */ | |
foreach ($configAttributes as $attribute) { | |
@@ -74,8 +108,10 @@ class Mage_ConfigurableSwatches_Helper_Mediafallback extends Mage_Core_Helper_Ab | |
foreach ($parentProduct->getChildrenProducts() as $childProduct) { | |
- // product has no value for attribute, we can't process it | |
- if (!$childProduct->hasData($attribute->getAttributeCode())) { | |
+ // product has no value for attribute or not available, we can't process it | |
+ $isInStock = $childProduct->getStockItem()->getIsInStock(); | |
+ if (!$childProduct->hasData($attribute->getAttributeCode()) | |
+ || (!$isInStock && !Mage::helper('cataloginventory')->isShowOutOfStock())) { | |
continue; | |
} | |
$optionId = $childProduct->getData($attribute->getAttributeCode()); | |
@@ -85,11 +121,6 @@ class Mage_ConfigurableSwatches_Helper_Mediafallback extends Mage_Core_Helper_Ab | |
continue; | |
} | |
- // normalize to all lower case before we start using them | |
- $optionLabels = array_map(function ($value) { | |
- return array_map('Mage_ConfigurableSwatches_Helper_Data::normalizeKey', $value); | |
- }, $optionLabels); | |
- | |
// using default value as key unless store-specific label is present | |
$optionLabel = $optionLabels[$optionId][0]; | |
if (isset($optionLabels[$optionId][$storeId])) { | |
@@ -110,7 +141,8 @@ class Mage_ConfigurableSwatches_Helper_Mediafallback extends Mage_Core_Helper_Ab | |
if ($attribute->getAttributeId() == $listSwatchAttr->getAttributeId() | |
&& !in_array($mapping[$optionLabel]['label'], $listSwatchValues) | |
) { | |
- $listSwatchValues[$optionId] = $mapping[$optionLabel]['label']; | |
+ $listSwatchValues[$optionId] = $mapping[$optionLabel]['label']; | |
+ $listSwatchStockValues[$optionId] = $isInStock; | |
} | |
} // end looping child products | |
} // end looping attributes | |
@@ -120,8 +152,13 @@ class Mage_ConfigurableSwatches_Helper_Mediafallback extends Mage_Core_Helper_Ab | |
$mapping[$key]['product_ids'] = array_unique($mapping[$key]['product_ids']); | |
} | |
+ if (count($listSwatchValues)) { | |
+ $listSwatchValues = array_replace(array_intersect_key($optionLabels, $listSwatchValues), | |
+ $listSwatchValues); | |
+ } | |
$parentProduct->setChildAttributeLabelMapping($mapping) | |
- ->setListSwatchAttrValues($listSwatchValues); | |
+ ->setListSwatchAttrValues($listSwatchValues) | |
+ ->setListSwatchAttrStockValues($listSwatchStockValues); | |
} // end looping parent products | |
} | |
@@ -201,7 +238,12 @@ class Mage_ConfigurableSwatches_Helper_Mediafallback extends Mage_Core_Helper_Ab | |
/* @var $childProduct Mage_Catalog_Model_Product */ | |
if ($product->hasChildrenProducts()) { | |
foreach ($product->getChildrenProducts() as $childProduct) { | |
- if ($image = $this->_resizeProductImage($childProduct, $imageType, $keepFrame)) { | |
+ $image = $this->_resizeProductImage($childProduct, $imageType, $keepFrame); | |
+ if (!$image) { | |
+ $image = $this->_resizeProductImage($childProduct, 'image', $keepFrame); | |
+ } | |
+ | |
+ if ($image) { | |
$imagesByType[$imageType][$childProduct->getId()] = $image; | |
} | |
} | |
diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php b/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php | |
index 3165e90..cd4c9cb 100644 | |
--- a/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php | |
+++ b/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php | |
@@ -37,8 +37,11 @@ class Mage_ConfigurableSwatches_Model_Observer extends Mage_Core_Model_Abstract | |
return; // exit without loading swatch functionality | |
} | |
- /* @var $helper Mage_ConfigurableSwatches_Helper_Mediafallback */ | |
- $helper = Mage::helper('configurableswatches/mediafallback'); | |
+ /* @var $mediaHelper Mage_ConfigurableSwatches_Helper_Mediafallback */ | |
+ $mediaHelper = Mage::helper('configurableswatches/mediafallback'); | |
+ | |
+ /** @var $priceHelper Mage_ConfigurableSwatches_Helper_List_Price */ | |
+ $priceHelper = Mage::helper('configurableswatches/list_price'); | |
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */ | |
$collection = $observer->getCollection(); | |
@@ -51,15 +54,19 @@ class Mage_ConfigurableSwatches_Model_Observer extends Mage_Core_Model_Abstract | |
$products = $collection->getItems(); | |
- $helper->attachChildrenProducts($products, $collection->getStoreId()); | |
+ $mediaHelper->attachChildrenProducts($products, $collection->getStoreId()); | |
- $helper->attachConfigurableProductChildrenAttributeMapping($products, $collection->getStoreId()); | |
+ $mediaHelper->attachProductChildrenAttributeMapping($products, $collection->getStoreId()); | |
+ | |
+ if ($priceHelper->isEnabled()) { | |
+ $priceHelper->attachConfigurableProductChildrenPricesMapping($products, $collection->getStoreId()); | |
+ } | |
- $helper->attachGallerySetToCollection($products, $collection->getStoreId()); | |
+ $mediaHelper->attachGallerySetToCollection($products, $collection->getStoreId()); | |
/* @var $product Mage_Catalog_Model_Product */ | |
foreach ($products as $product) { | |
- $helper->groupMediaGalleryImages($product); | |
+ $mediaHelper->groupMediaGalleryImages($product); | |
Mage::helper('configurableswatches/productimg') | |
->indexProductImages($product, $product->getListSwatchAttrValues()); | |
} | |
@@ -90,7 +97,7 @@ class Mage_ConfigurableSwatches_Model_Observer extends Mage_Core_Model_Abstract | |
$helper->groupMediaGalleryImages($product); | |
- $helper->attachConfigurableProductChildrenAttributeMapping(array($product), $product->getStoreId()); | |
+ $helper->attachProductChildrenAttributeMapping(array($product), $product->getStoreId(), false); | |
} | |
/** | |
diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php b/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php | |
index 9a62561..708c729 100644 | |
--- a/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php | |
+++ b/app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Attribute/Super/Collection.php | |
@@ -99,40 +99,59 @@ class Mage_ConfigurableSwatches_Model_Resource_Catalog_Product_Attribute_Super_C | |
*/ | |
protected function _loadOptionLabels() | |
{ | |
- if ($this->count()) { | |
- $select = $this->getConnection()->select() | |
- ->from( | |
- array('attr' => $this->getTable('catalog/product_super_attribute')), | |
- array( | |
- 'product_super_attribute_id' => 'attr.product_super_attribute_id', | |
- )) | |
- ->join( | |
- array('opt' => $this->getTable('eav/attribute_option')), | |
- 'opt.attribute_id = attr.attribute_id', | |
- array( | |
- 'attribute_id' => 'opt.attribute_id', | |
- 'option_id' => 'opt.option_id', | |
- )) | |
- ->join( | |
- array('lab' => $this->getTable('eav/attribute_option_value')), | |
- 'lab.option_id = opt.option_id', | |
- array( | |
- 'label' => 'lab.value', | |
- 'store_id' => 'lab.store_id', | |
- )) | |
- ->where('attr.product_super_attribute_id IN (?)', array_keys($this->_items)) | |
- ; | |
- | |
- $result = $this->getConnection()->fetchAll($select); | |
- foreach ($result as $data) { | |
- $item = $this->getItemById($data['product_super_attribute_id']); | |
- if (!is_array($labels = $item->getOptionLabels())) { | |
- $labels = array(); | |
- } | |
- $labels[$data['option_id']][$data['store_id']] = $data['label']; | |
- $item->setOptionLabels($labels); | |
- } | |
+ $labels = $this->_getOptionLabels(); | |
+ foreach ($this->getItems() as $item) { | |
+ $item->setOptionLabels($labels); | |
} | |
return $this; | |
} | |
+ | |
+ /** | |
+ * Get Option Labels | |
+ * | |
+ * @return array | |
+ */ | |
+ protected function _getOptionLabels() | |
+ { | |
+ $attributeIds = $this->_getAttributeIds(); | |
+ | |
+ $select = $this->getConnection()->select(); | |
+ $select->from(array('options' => $this->getTable('eav/attribute_option'))) | |
+ ->join( | |
+ array('labels' => $this->getTable('eav/attribute_option_value')), | |
+ 'labels.option_id = options.option_id', | |
+ array( | |
+ 'label' => 'labels.value', | |
+ 'store_id' => 'labels.store_id', | |
+ ) | |
+ ) | |
+ ->where('options.attribute_id IN (?)', $attributeIds) | |
+ ->where( | |
+ 'labels.store_id IN (?)', | |
+ array(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID, $this->getStoreId()) | |
+ ); | |
+ | |
+ $resultSet = $this->getConnection()->query($select); | |
+ $labels = array(); | |
+ while ($option = $resultSet->fetch()) { | |
+ $labels[$option['option_id']][$option['store_id']] = $option['label']; | |
+ } | |
+ return $labels; | |
+ } | |
+ | |
+ /** | |
+ * Get Attribute IDs | |
+ * | |
+ * @return array | |
+ */ | |
+ protected function _getAttributeIds() | |
+ { | |
+ $attributeIds = array(); | |
+ foreach ($this->getItems() as $item) { | |
+ $attributeIds[] = $item->getAttributeId(); | |
+ } | |
+ $attributeIds = array_unique($attributeIds); | |
+ | |