diff --git a/app/Mage.php b/app/Mage.php
index 6702f50c6a..68be8b1bd8 100644
--- a/app/Mage.php
+++ b/app/Mage.php
@@ -130,13 +130,32 @@ final class Mage
static private $_isInstalled;
/**
- * Retrieve current Magento version
+ * Gets the current Magento version string
+ * @link http://www.magentocommerce.com/blog/new-community-edition-release-process/
*
* @return string
*/
public static function getVersion()
{
- return '1.4.0.0-alpha1';
+ return '1.4.0.0-alpha2';
+ }
+
+ /**
+ * Gets the detailed Magento version information
+ * @link http://www.magentocommerce.com/blog/new-community-edition-release-process/
+ *
+ * @return array
+ */
+ public static function getVersionInfo()
+ {
+ return array(
+ 'major' => '1',
+ 'minor' => '4',
+ 'revision' => '0',
+ 'patch' => '0',
+ 'stability' => 'alpha',
+ 'number' => '2',
+ );
}
/**
@@ -312,7 +331,7 @@ public static function getStoreConfig($path, $store = null)
public static function getStoreConfigFlag($path, $store = null)
{
$flag = strtolower(self::getStoreConfig($path, $store));
- if (!empty($flag) && 'false'!==$flag && '0'!==$flag) {
+ if (!empty($flag) && 'false' !== $flag) {
return true;
} else {
return false;
@@ -665,8 +684,11 @@ public static function log($message, $level = null, $file = '')
if (!self::getConfig()) {
return;
}
- if (!self::getStoreConfig('dev/log/active')) {
- return;
+
+ if (!self::$_isDeveloperMode) {
+ if (!self::getStoreConfig('dev/log/active')) {
+ return;
+ }
}
static $loggers = array();
@@ -768,6 +790,9 @@ public static function printException(Exception $e, $extra = '')
!empty($extra) ? $extra . "\n\n" : '' . $e->getMessage(),
$e->getTraceAsString()
);
+ if (isset($_SERVER) && isset($_SERVER['REQUEST_URI'])) {
+ $reportData[] = $_SERVER['REQUEST_URI'];
+ }
$reportData = serialize($reportData);
file_put_contents($reportFile, $reportData);
diff --git a/app/code/core/Mage/Admin/Model/Config.php b/app/code/core/Mage/Admin/Model/Config.php
index 8681c43321..088f72a1e8 100644
--- a/app/code/core/Mage/Admin/Model/Config.php
+++ b/app/code/core/Mage/Admin/Model/Config.php
@@ -34,11 +34,46 @@
*/
class Mage_Admin_Model_Config extends Varien_Simplexml_Config
{
+ /**
+ * adminhtml.xml merged config
+ *
+ * @var Varien_Simplexml_Config
+ */
+ protected $_adminhtmlConfig;
+
+ /**
+ * Load config from merged adminhtml.xml files
+ */
public function __construct()
{
parent::__construct();
- #$this->_elementClass = 'Mage_Core_Model_Config_Element';
- #$this->loadFile(Mage::getModuleDir('etc', 'Mage_Admin').DS.'admin.xml');
+ $this->setCacheId('adminhtml_acl_menu_config');
+ /* @var $adminhtmlConfig Varien_Simplexml_Config */
+ $adminhtmlConfig = Mage::app()->loadCache($this->getCacheId());
+ if ($adminhtmlConfig) {
+ $this->_adminhtmlConfig = new Varien_Simplexml_Config($adminhtmlConfig);
+ } else {
+ $adminhtmlConfig = new Varien_Simplexml_Config;
+ $adminhtmlConfig->loadString(' ');
+ Mage::getConfig()->loadModulesConfiguration('adminhtml.xml', $adminhtmlConfig);
+ $this->_adminhtmlConfig = $adminhtmlConfig;
+
+ // support back compatibility with base config
+ $aclConfig = Mage::getConfig()->getNode('adminhtml/acl');
+ if ($aclConfig) {
+ $adminhtmlConfig->getNode()->extendChild($aclConfig, true);
+ }
+
+ $menuConfig = Mage::getConfig()->getNode('adminhtml/menu');
+ if ($menuConfig) {
+ $adminhtmlConfig->getNode()->extendChild($menuConfig, true);
+ }
+
+ if (Mage::app()->useCache('config')) {
+ Mage::app()->saveCache($adminhtmlConfig->getXmlString(), $this->getCacheId(),
+ array(Mage_Core_Model_Config::CACHE_TAG));
+ }
+ }
}
/**
@@ -52,7 +87,7 @@ public function __construct()
public function loadAclResources(Mage_Admin_Model_Acl $acl, $resource=null, $parentName=null)
{
if (is_null($resource)) {
- $resource = Mage::getConfig()->getNode("adminhtml/acl/resources");
+ $resource = $this->getAdminhtmlConfig()->getNode("acl/resources");
$resourceName = null;
} else {
$resourceName = (is_null($parentName) ? '' : $parentName.'/').$resource->getName();
@@ -121,4 +156,13 @@ public function getAclPrivilegeSet($name='')
return false;
}
+ /**
+ * Retrieve xml config
+ *
+ * @return Varien_Simplexml_Config
+ */
+ public function getAdminhtmlConfig()
+ {
+ return $this->_adminhtmlConfig;
+ }
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Admin/Model/Mysql4/Rules.php b/app/code/core/Mage/Admin/Model/Mysql4/Rules.php
index 257dde77b3..b3fa0a20ba 100644
--- a/app/code/core/Mage/Admin/Model/Mysql4/Rules.php
+++ b/app/code/core/Mage/Admin/Model/Mysql4/Rules.php
@@ -30,38 +30,47 @@ protected function _construct() {
$this->_init('admin/rule', 'rule_id');
}
- public function saveRel(Mage_Admin_Model_Rules $rule) {
- $this->_getWriteAdapter()->beginTransaction();
-
+ /**
+ * Save ACL resources
+ *
+ * @param Mage_Admin_Model_Rules $rule
+ */
+ public function saveRel(Mage_Admin_Model_Rules $rule)
+ {
try {
+ $this->_getWriteAdapter()->beginTransaction();
$roleId = $rule->getRoleId();
$this->_getWriteAdapter()->delete($this->getMainTable(), "role_id = {$roleId}");
- $masterResources = Mage::getModel('admin/roles')->getResourcesList2D();
- $masterAdmin = false;
- if ( $postedResources = $rule->getResources() ) {
- foreach ($masterResources as $index => $resName) {
- if ( !$masterAdmin ) {
- $permission = ( in_array($resName, $postedResources) )? 'allow' : 'deny';
- $this->_getWriteAdapter()->insert($this->getMainTable(), array(
- 'role_type' => 'G',
- 'resource_id' => trim($resName, '/'),
- 'privileges' => '', # FIXME !!!
- 'assert_id' => 0,
- 'role_id' => $roleId,
- 'permission' => $permission
- ));
- }
- if ( $resName == 'all' && $permission == 'allow' ) {
- $masterAdmin = true;
+ $postedResources = $rule->getResources();
+ if ($postedResources) {
+ $row = array(
+ 'role_type' => 'G',
+ 'resource_id' => 'all',
+ 'privileges' => '', // not used yet
+ 'assert_id' => 0,
+ 'role_id' => $roleId,
+ 'permission' => 'allow'
+ );
+
+ // If all was selected save it only and nothing else.
+ if ($postedResources === array('all')) {
+ $this->_getWriteAdapter()->insert($this->getMainTable(), $row);
+ } else {
+ foreach (Mage::getModel('admin/roles')->getResourcesList2D() as $index => $resName) {
+ $row['permission'] = (in_array($resName, $postedResources) ? 'allow' : 'deny');
+ $row['resource_id'] = trim($resName, '/');
+ $this->_getWriteAdapter()->insert($this->getMainTable(), $row);
}
}
}
$this->_getWriteAdapter()->commit();
} catch (Mage_Core_Exception $e) {
+ $this->_getWriteAdapter()->rollBack();
throw $e;
} catch (Exception $e){
$this->_getWriteAdapter()->rollBack();
+ Mage::logException($e);
}
}
}
diff --git a/app/code/core/Mage/Admin/Model/Roles.php b/app/code/core/Mage/Admin/Model/Roles.php
index 1902ee42f9..fe49529e22 100644
--- a/app/code/core/Mage/Admin/Model/Roles.php
+++ b/app/code/core/Mage/Admin/Model/Roles.php
@@ -71,7 +71,7 @@ protected function _buildResourcesArray(Varien_Simplexml_Element $resource=null,
{
static $result;
if (is_null($resource)) {
- $resource = Mage::getConfig()->getNode('adminhtml/acl/resources');
+ $resource = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('acl/resources');
$resourceName = null;
$level = -1;
} else {
@@ -89,12 +89,6 @@ protected function _buildResourcesArray(Varien_Simplexml_Element $resource=null,
$resource->addAttribute("module_c", $module);
}
- //if (!(string)$resource->title) {
- // return array();
- //}
-
- //$resource->title = Mage::helper($module)->__((string)$resource->title);
-
if ( is_null($represent2Darray) ) {
$result[$resourceName]['name'] = Mage::helper($module)->__((string)$resource->title);
$result[$resourceName]['level'] = $level;
diff --git a/app/code/core/Mage/Admin/Model/User.php b/app/code/core/Mage/Admin/Model/User.php
index aee3ccb533..8c6407f349 100644
--- a/app/code/core/Mage/Admin/Model/User.php
+++ b/app/code/core/Mage/Admin/Model/User.php
@@ -56,13 +56,12 @@ protected function _construct()
}
/**
- * Save user
+ * Processing data before model save
*
* @return Mage_Admin_Model_User
*/
- public function save()
+ protected function _beforeSave()
{
- $this->_beforeSave();
$data = array(
'firstname' => $this->getFirstname(),
'lastname' => $this->getLastname(),
@@ -85,8 +84,7 @@ public function save()
if ($this->getNewPassword()) {
$data['password'] = $this->_getEncodedPassword($this->getNewPassword());
- }
- elseif ($this->getPassword()) {
+ } elseif ($this->getPassword()) {
$data['new_password'] = $this->getPassword();
}
@@ -95,9 +93,8 @@ public function save()
}
$this->addData($data);
- $this->_getResource()->save($this);
- $this->_afterSave();
- return $this;
+
+ return parent::_beforeSave();
}
/**
@@ -115,17 +112,6 @@ public function saveExtra($data)
return $this;
}
- /**
- * Delete user
- *
- * @return Mage_Admin_Model_User
- */
- public function delete()
- {
- $this->_getResource()->delete($this);
- return $this;
- }
-
/**
* Save user roles
*
@@ -323,7 +309,7 @@ protected function _getEncodedPassword($pwd)
public function findFirstAvailableMenu($parent=null, $path='', $level=0)
{
if ($parent == null) {
- $parent = Mage::getConfig()->getNode('adminhtml/menu');
+ $parent = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu');
}
foreach ($parent->children() as $childName=>$child) {
$aclResource = 'admin/' . $path . $childName;
@@ -372,8 +358,9 @@ public function getStartupPageUrl()
$startupPage = Mage::getStoreConfig(self::XML_PATH_STARTUP_PAGE);
$aclResource = 'admin/' . $startupPage;
if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) {
- $nodePath = 'adminhtml/menu/' . join('/children/', explode('/', $startupPage)) . '/action';
- if ($url = Mage::getConfig()->getNode($nodePath)) {
+ $nodePath = 'menu/' . join('/children/', explode('/', $startupPage)) . '/action';
+ $url = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode($nodePath);
+ if ($url) {
return $url;
}
}
diff --git a/app/code/core/Mage/Admin/etc/config.xml b/app/code/core/Mage/Admin/etc/config.xml
index 2a7e371ce3..686d5b1291 100644
--- a/app/code/core/Mage/Admin/etc/config.xml
+++ b/app/code/core/Mage/Admin/etc/config.xml
@@ -54,16 +54,7 @@
Mage_Admin
-
- core_setup
-
-
- core_write
-
-
- core_read
-
Mage_Admin_Block
diff --git a/app/code/core/Mage/AdminNotification/Model/Observer.php b/app/code/core/Mage/AdminNotification/Model/Observer.php
index fb56f37380..fdfac46446 100644
--- a/app/code/core/Mage/AdminNotification/Model/Observer.php
+++ b/app/code/core/Mage/AdminNotification/Model/Observer.php
@@ -41,9 +41,15 @@ class Mage_AdminNotification_Model_Observer
*/
public function preDispatch(Varien_Event_Observer $observer)
{
- $feedModel = Mage::getModel('adminnotification/feed');
- /* @var $feedModel Mage_AdminNotification_Model_Feed */
- $feedModel->checkUpdate();
+ if (Mage::getSingleton('admin/session')->isLoggedIn()) {
+
+ $feedModel = Mage::getModel('adminnotification/feed');
+ /* @var $feedModel Mage_AdminNotification_Model_Feed */
+
+ $feedModel->checkUpdate();
+
+ }
+
}
}
\ No newline at end of file
diff --git a/app/code/core/Mage/AdminNotification/etc/config.xml b/app/code/core/Mage/AdminNotification/etc/config.xml
index b5673be53d..62404ad191 100644
--- a/app/code/core/Mage/AdminNotification/etc/config.xml
+++ b/app/code/core/Mage/AdminNotification/etc/config.xml
@@ -57,20 +57,7 @@
Mage_AdminNotification
-
- core_setup
-
-
-
- core_setup
-
-
-
-
- core_setup
-
-
@@ -80,51 +67,6 @@
-
-
-
-
-
-
-
- Notifications
- 10
-
-
- Show Toolbar
- 10
-
-
- Show List
- 20
-
-
- Mark as read
- 30
-
-
- Remove
- 40
-
-
-
-
-
-
-
-
-
-
-
-
-
- Notifications
- adminhtml/notification
- 15
-
-
-
-
@@ -138,7 +80,6 @@
- singleton
adminnotification/observer
preDispatch
diff --git a/app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php b/app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php
index 54f186078e..b02f24424c 100644
--- a/app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php
+++ b/app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php
@@ -94,7 +94,7 @@ protected function _prepareForm()
'label' => Mage::helper('adminhtml')->__('New Api Key'),
'id' => 'new_pass',
'title' => Mage::helper('adminhtml')->__('New Api Key'),
- 'class' => 'input-text validate-admin-password',
+ 'class' => 'input-text validate-password',
));
$fieldset->addField('confirmation', 'password', array(
@@ -110,7 +110,7 @@ protected function _prepareForm()
'label' => Mage::helper('adminhtml')->__('Api Key'),
'id' => 'customer_pass',
'title' => Mage::helper('adminhtml')->__('Api Key'),
- 'class' => 'input-text required-entry validate-admin-password',
+ 'class' => 'input-text required-entry validate-password',
'required' => true,
));
$fieldset->addField('confirmation', 'password', array(
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php
index c79ba06c52..5b608bf301 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php
@@ -145,6 +145,9 @@ public function getAdditionalButtonsHtml()
*/
public function addAdditionalButton($alias, $config)
{
+ if (isset($config['name'])) {
+ $config['element_name'] = $config['name'];
+ }
$this->setChild($alias . '_button',
$this->getLayout()->createBlock('adminhtml/widget_button')->addData($config));
$this->_additionalButtons[$alias] = $alias . '_button';
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php
index 180b6f3b1c..a0edfb0af7 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Form/Renderer/Fieldset/Element.php
@@ -97,7 +97,7 @@ public function canDisplayUseDefault()
public function usedDefault()
{
$devaultValue = $this->getDataObject()->getAttributeDefaultValue($this->getAttribute()->getAttributeCode());
- return is_null($devaultValue);
+ return $devaultValue === false;
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php
index 8526e7d60b..c8edeaf5f4 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php
@@ -30,70 +30,45 @@
*
* @category Mage
* @package Mage_Adminhtml
- * @author Magento Core Team
+ * @author Magento Core Team
*/
-class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
+class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract
{
-
+ /**
+ * Adding product form elements for editing attribute
+ *
+ * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main
+ */
protected function _prepareForm()
{
- $model = Mage::registry('entity_attribute');
-
- $form = new Varien_Data_Form(array(
- 'id' => 'edit_form',
- 'action' => $this->getData('action'),
- 'method' => 'post'
- ));
-
- $disableAttributeFields = array(
- 'sku' => array(
- 'is_global',
- 'is_unique',
- ),
- 'url_key' => array(
- 'is_unique',
- ),
- 'status' => array(
- 'is_configurable',
- 'is_filterable',
- 'is_filterable_in_search'
- ),
- 'visibility' => array(
- 'is_configurable',
- 'is_filterable',
- 'is_filterable_in_search'
- ),
- );
-
- $fieldset = $form->addFieldset('base_fieldset',
- array('legend'=>Mage::helper('catalog')->__('Attribute Properties'))
- );
- if ($model->getAttributeId()) {
- $fieldset->addField('attribute_id', 'hidden', array(
- 'name' => 'attribute_id',
- ));
- }
-
- $this->_addElementTypes($fieldset);
-
- $yesno = array(
+ parent::_prepareForm();
+ $attributeObject = $this->getAttributeObject();
+ /* @var $form Varien_Data_Form */
+ $form = $this->getForm();
+ /* @var $fieldset Varien_Data_Form_Element_Fieldset */
+ $fieldset = $form->getElement('base_fieldset');
+
+ $frontendInputElm = $form->getElement('frontend_input');
+ $additionalTypes = array(
array(
- 'value' => 0,
- 'label' => Mage::helper('catalog')->__('No')
+ 'value' => 'price',
+ 'label' => Mage::helper('catalog')->__('Price')
),
array(
- 'value' => 1,
- 'label' => Mage::helper('catalog')->__('Yes')
- ));
+ 'value' => 'media_image',
+ 'label' => Mage::helper('catalog')->__('Media Image')
+ )
+ );
+ if ($attributeObject->getFrontendInput() == 'gallery') {
+ $inputTypes[] = array(
+ 'value' => 'gallery',
+ 'label' => Mage::helper('catalog')->__('Gallery')
+ );
+ }
+ $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
+ $frontendInputElm->setValues($frontendInputValues);
- $fieldset->addField('attribute_code', 'text', array(
- 'name' => 'attribute_code',
- 'label' => Mage::helper('catalog')->__('Attribute Code'),
- 'title' => Mage::helper('catalog')->__('Attribute Code'),
- 'note' => Mage::helper('catalog')->__('For internal use. Must be unique with no spaces'),
- 'class' => 'validate-code',
- 'required' => true,
- ));
+ $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
$scopes = array(
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('catalog')->__('Store View'),
@@ -101,7 +76,7 @@ protected function _prepareForm()
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('catalog')->__('Global'),
);
- if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') {
+ if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id') {
unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]);
}
@@ -111,165 +86,7 @@ protected function _prepareForm()
'title' => Mage::helper('catalog')->__('Scope'),
'note' => Mage::helper('catalog')->__('Declare attribute value saving scope'),
'values'=> $scopes
- ));
-
- $inputTypes = array(
- array(
- 'value' => 'text',
- 'label' => Mage::helper('catalog')->__('Text Field')
- ),
- array(
- 'value' => 'textarea',
- 'label' => Mage::helper('catalog')->__('Text Area')
- ),
- array(
- 'value' => 'date',
- 'label' => Mage::helper('catalog')->__('Date')
- ),
- array(
- 'value' => 'boolean',
- 'label' => Mage::helper('catalog')->__('Yes/No')
- ),
- array(
- 'value' => 'multiselect',
- 'label' => Mage::helper('catalog')->__('Multiple Select')
- ),
- array(
- 'value' => 'select',
- 'label' => Mage::helper('catalog')->__('Dropdown')
- ),
- array(
- 'value' => 'price',
- 'label' => Mage::helper('catalog')->__('Price')
- ),
- array(
- 'value' => 'media_image',
- 'label' => Mage::helper('catalog')->__('Media Image')
- ),
- );
-
- if ($model->getFrontendInput() == 'gallery') {
- $inputTypes[] = array(
- 'value' => 'gallery',
- 'label' => Mage::helper('catalog')->__('Gallery')
- );
- }
-
- $response = new Varien_Object();
- $response->setTypes(array());
- Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response));
-
- $_disabledTypes = array();
- $_hiddenFields = array();
- foreach ($response->getTypes() as $type) {
- $inputTypes[] = $type;
- if (isset($type['hide_fields'])) {
- $_hiddenFields[$type['value']] = $type['hide_fields'];
- }
- if (isset($type['disabled_types'])) {
- $_disabledTypes[$type['value']] = $type['disabled_types'];
- }
- }
- Mage::register('attribute_type_hidden_fields', $_hiddenFields);
- Mage::register('attribute_type_disabled_types', $_disabledTypes);
-
-
- $fieldset->addField('frontend_input', 'select', array(
- 'name' => 'frontend_input',
- 'label' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'),
- 'title' => Mage::helper('catalog')->__('Catalog Input Type for Store Owner'),
- 'value' => 'text',
- 'values'=> $inputTypes
- ));
-
- $fieldset->addField('default_value_text', 'text', array(
- 'name' => 'default_value_text',
- 'label' => Mage::helper('catalog')->__('Default value'),
- 'title' => Mage::helper('catalog')->__('Default value'),
- 'value' => $model->getDefaultValue(),
- ));
-
- $fieldset->addField('default_value_yesno', 'select', array(
- 'name' => 'default_value_yesno',
- 'label' => Mage::helper('catalog')->__('Default value'),
- 'title' => Mage::helper('catalog')->__('Default value'),
- 'values' => $yesno,
- 'value' => $model->getDefaultValue(),
- ));
-
- $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
- $fieldset->addField('default_value_date', 'date', array(
- 'name' => 'default_value_date',
- 'label' => Mage::helper('catalog')->__('Default value'),
- 'title' => Mage::helper('catalog')->__('Default value'),
- 'image' => $this->getSkinUrl('images/grid-cal.gif'),
- 'value' => $model->getDefaultValue(),
- 'format' => $dateFormatIso
- ));
-
- $fieldset->addField('default_value_textarea', 'textarea', array(
- 'name' => 'default_value_textarea',
- 'label' => Mage::helper('catalog')->__('Default value'),
- 'title' => Mage::helper('catalog')->__('Default value'),
- 'value' => $model->getDefaultValue(),
- ));
-
- $fieldset->addField('is_unique', 'select', array(
- 'name' => 'is_unique',
- 'label' => Mage::helper('catalog')->__('Unique Value'),
- 'title' => Mage::helper('catalog')->__('Unique Value (not shared with other products)'),
- 'note' => Mage::helper('catalog')->__('Not shared with other products'),
- 'values' => $yesno,
- ));
-
- $fieldset->addField('is_required', 'select', array(
- 'name' => 'is_required',
- 'label' => Mage::helper('catalog')->__('Values Required'),
- 'title' => Mage::helper('catalog')->__('Values Required'),
- 'values' => $yesno,
- ));
-
- $fieldset->addField('frontend_class', 'select', array(
- 'name' => 'frontend_class',
- 'label' => Mage::helper('catalog')->__('Input Validation for Store Owner'),
- 'title' => Mage::helper('catalog')->__('Input Validation for Store Owner'),
- 'values'=> array(
- array(
- 'value' => '',
- 'label' => Mage::helper('catalog')->__('None')
- ),
- array(
- 'value' => 'validate-number',
- 'label' => Mage::helper('catalog')->__('Decimal Number')
- ),
- array(
- 'value' => 'validate-digits',
- 'label' => Mage::helper('catalog')->__('Integer Number')
- ),
- array(
- 'value' => 'validate-email',
- 'label' => Mage::helper('catalog')->__('Email')
- ),
- array(
- 'value' => 'validate-url',
- 'label' => Mage::helper('catalog')->__('Url')
- ),
- array(
- 'value' => 'validate-alpha',
- 'label' => Mage::helper('catalog')->__('Letters')
- ),
- array(
- 'value' => 'validate-alphanum',
- 'label' => Mage::helper('catalog')->__('Letters(a-zA-Z) or Numbers(0-9)')
- ),
- )
- ));
-/*
- $fieldset->addField('use_in_super_product', 'select', array(
- 'name' => 'use_in_super_product',
- 'label' => Mage::helper('catalog')->__('Apply To Configurable/Grouped Product'),
- 'values' => $yesno,
- )); */
+ ), 'attribute_code');
$fieldset->addField('apply_to', 'apply', array(
'name' => 'apply_to[]',
@@ -280,15 +97,13 @@ protected function _prepareForm()
'custom' => Mage::helper('catalog')->__('Selected Product Types')
),
'required' => true
- ));
+ ), 'frontend_class');
$fieldset->addField('is_configurable', 'select', array(
'name' => 'is_configurable',
'label' => Mage::helper('catalog')->__('Use To Create Configurable Product'),
- 'values' => $yesno,
- ));
- // -----
-
+ 'values' => $yesnoSource,
+ ), 'apply_to');
// frontend properties fieldset
$fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('catalog')->__('Frontend Properties')));
@@ -297,24 +112,23 @@ protected function _prepareForm()
'name' => 'is_searchable',
'label' => Mage::helper('catalog')->__('Use in quick search'),
'title' => Mage::helper('catalog')->__('Use in quick search'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
$fieldset->addField('is_visible_in_advanced_search', 'select', array(
'name' => 'is_visible_in_advanced_search',
'label' => Mage::helper('catalog')->__('Use in advanced search'),
'title' => Mage::helper('catalog')->__('Use in advanced search'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
$fieldset->addField('is_comparable', 'select', array(
'name' => 'is_comparable',
'label' => Mage::helper('catalog')->__('Comparable on Front-end'),
'title' => Mage::helper('catalog')->__('Comparable on Front-end'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
-
$fieldset->addField('is_filterable', 'select', array(
'name' => 'is_filterable',
'label' => Mage::helper('catalog')->__("Use In Layered Navigation"),
@@ -332,14 +146,14 @@ protected function _prepareForm()
'label' => Mage::helper('catalog')->__("Use In Search Results Layered Navigation"),
'title' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
'note' => Mage::helper('catalog')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
$fieldset->addField('is_used_for_price_rules', 'select', array(
'name' => 'is_used_for_price_rules',
'label' => Mage::helper('catalog')->__('Use for Price Rule Conditions'),
'title' => Mage::helper('catalog')->__('Use for Price Rule Conditions'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
$fieldset->addField('position', 'text', array(
@@ -354,9 +168,9 @@ protected function _prepareForm()
'name' => 'is_html_allowed_on_front',
'label' => Mage::helper('catalog')->__('Allow HTML-tags on Front-end'),
'title' => Mage::helper('catalog')->__('Allow HTML-tags on Front-end'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
- if (!$model->getId()) {
+ if (!$attributeObject->getId()) {
$htmlAllowed->setValue(1);
}
@@ -364,7 +178,7 @@ protected function _prepareForm()
'name' => 'is_visible_on_front',
'label' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'),
'title' => Mage::helper('catalog')->__('Visible on Product View Page on Front-end'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
$fieldset->addField('used_in_product_listing', 'select', array(
@@ -372,52 +186,54 @@ protected function _prepareForm()
'label' => Mage::helper('catalog')->__('Used in product listing'),
'title' => Mage::helper('catalog')->__('Used in product listing'),
'note' => Mage::helper('catalog')->__('Depends on design theme'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
$fieldset->addField('used_for_sort_by', 'select', array(
'name' => 'used_for_sort_by',
'label' => Mage::helper('catalog')->__('Used for sorting in product listing'),
'title' => Mage::helper('catalog')->__('Used for sorting in product listing'),
'note' => Mage::helper('catalog')->__('Depends on design theme'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
- if ($model->getId()) {
- $form->getElement('attribute_code')->setDisabled(1);
- $form->getElement('frontend_input')->setDisabled(1);
-
- if (isset($disableAttributeFields[$model->getAttributeCode()])) {
- foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) {
- $form->getElement($field)->setDisabled(1);
- $form->getElement($field)->setReadonly(1);
- }
- }
- }
- if (!$model->getIsUserDefined() && $model->getId()) {
- $form->getElement('is_unique')->setDisabled(1);
- }
-
- $form->addValues($model->getData());
-
$form->getElement('apply_to')->setSize(5);
- if ($applyTo = $model->getApplyTo()) {
+ if ($applyTo = $attributeObject->getApplyTo()) {
$applyTo = is_array($applyTo) ? $applyTo : explode(',', $applyTo);
$form->getElement('apply_to')->setValue($applyTo);
} else {
$form->getElement('apply_to')->addClass('no-display ignore-validate');
}
- $this->setForm($form);
+ $response = new Varien_Object();
+ $response->setTypes(array());
+ Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response));
+ $_disabledTypes = array();
+ $_hiddenFields = array();
+ foreach ($response->getTypes() as $type) {
+ $inputTypes[] = $type;
+ if (isset($type['hide_fields'])) {
+ $_hiddenFields[$type['value']] = $type['hide_fields'];
+ }
+ if (isset($type['disabled_types'])) {
+ $_disabledTypes[$type['value']] = $type['disabled_types'];
+ }
+ }
+ Mage::register('attribute_type_hidden_fields', $_hiddenFields);
+ Mage::register('attribute_type_disabled_types', $_disabledTypes);
- return parent::_prepareForm();
+ return $this;
}
+ /**
+ * Retrieve additional element types for product attributes
+ *
+ * @return array
+ */
protected function _getAdditionalElementTypes()
{
return array(
'apply' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_product_helper_form_apply')
);
}
-
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php
index 0e3d17b042..637333b377 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php
@@ -31,155 +31,6 @@
* @package Mage_Adminhtml
* @author Magento Core Team
*/
-class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options extends Mage_Adminhtml_Block_Widget
+class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
{
-
- public function __construct()
- {
- parent::__construct();
- $this->setTemplate('catalog/product/attribute/options.phtml');
- }
-
- protected function _prepareLayout()
- {
- $this->setChild('delete_button',
- $this->getLayout()->createBlock('adminhtml/widget_button')
- ->setData(array(
- 'label' => Mage::helper('catalog')->__('Delete'),
- 'class' => 'delete delete-option'
- )));
-
- $this->setChild('add_button',
- $this->getLayout()->createBlock('adminhtml/widget_button')
- ->setData(array(
- 'label' => Mage::helper('catalog')->__('Add Option'),
- 'class' => 'add',
- 'id' => 'add_new_option_button'
- )));
- return parent::_prepareLayout();
- }
-
- public function getDeleteButtonHtml()
- {
- return $this->getChildHtml('delete_button');
- }
-
- public function getAddNewButtonHtml()
- {
- return $this->getChildHtml('add_button');
- }
-
- public function getStores()
- {
- $stores = $this->getData('stores');
- if (is_null($stores)) {
- $stores = Mage::getModel('core/store')
- ->getResourceCollection()
- ->setLoadDefault(true)
- ->load();
- $this->setData('stores', $stores);
- }
- return $stores;
- }
-
- public function getOptionValues()
- {
- $attributeType = $this->getAttributeObject()->getFrontendInput();
- $defaultValues = $this->getAttributeObject()->getDefaultValue();
- if ($attributeType == 'select' || $attributeType == 'multiselect') {
- $defaultValues = explode(',', $defaultValues);
- } else {
- $defaultValues = array();
- }
-
- switch ($attributeType) {
- case 'select':
- $inputType = 'radio';
- break;
- case 'multiselect':
- $inputType = 'checkbox';
- break;
- default:
- $inputType = '';
- break;
- }
-
- $values = $this->getData('option_values');
- if (is_null($values)) {
- $values = array();
- $optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
- ->setAttributeFilter($this->getAttributeObject()->getId())
- ->setPositionOrder('desc', true)
- ->load();
-
- foreach ($optionCollection as $option) {
- $value = array();
- if (in_array($option->getId(), $defaultValues)) {
- $value['checked'] = 'checked="checked"';
- } else {
- $value['checked'] = '';
- }
-
- $value['intype'] = $inputType;
- $value['id'] = $option->getId();
- $value['sort_order'] = $option->getSortOrder();
- foreach ($this->getStores() as $store) {
- $storeValues = $this->getStoreOptionValues($store->getId());
- if (isset($storeValues[$option->getId()])) {
- $value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
- }
- else {
- $value['store'.$store->getId()] = '';
- }
- }
- $values[] = new Varien_Object($value);
- }
- $this->setData('option_values', $values);
- }
-
- return $values;
- }
-
- public function getLabelValues()
- {
- $values = array();
- $values[0] = $this->getAttributeObject()->getFrontend()->getLabel();
- // it can be array and cause bug
- $frontendLabel = $this->getAttributeObject()->getFrontend()->getLabel();
- if (is_array($frontendLabel)) {
- $frontendLabel = array_shift($frontendLabel);
- }
- $translations = Mage::getModel('core/translate_string')
- ->load(Mage_Catalog_Model_Entity_Attribute::MODULE_NAME.Mage_Core_Model_Translate::SCOPE_SEPARATOR.$frontendLabel)
- ->getStoreTranslations();
- foreach ($this->getStores() as $store) {
- if ($store->getId() != 0) {
- $values[$store->getId()] = isset($translations[$store->getId()]) ? $translations[$store->getId()] : '';
- }
- }
- return $values;
- }
-
- public function getStoreOptionValues($storeId)
- {
- $values = $this->getData('store_option_values_'.$storeId);
- if (is_null($values)) {
- $values = array();
- $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
- ->setAttributeFilter($this->getAttributeObject()->getId())
- ->setStoreFilter($storeId, false)
- ->load();
- foreach ($valuesCollection as $item) {
- $values[$item->getId()] = $item->getValue();
- }
- $this->setData('store_option_values_'.$storeId, $values);
- }
- return $values;
- }
-
- public function getAttributeObject()
- {
- return Mage::registry('entity_attribute');
- }
-
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php
index 6b7a39d803..2137742cc2 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php
@@ -29,54 +29,34 @@
*
* @category Mage
* @package Mage_Adminhtml
- * @author Magento Core Team
+ * @author Magento Core Team
*/
-class Mage_Adminhtml_Block_Catalog_Product_Attribute_Grid extends Mage_Adminhtml_Block_Widget_Grid
+class Mage_Adminhtml_Block_Catalog_Product_Attribute_Grid extends Mage_Eav_Block_Adminhtml_Attribute_Grid_Abstract
{
-
- public function __construct()
- {
- parent::__construct();
- $this->setId('attributeGrid');
- $this->setDefaultSort('attribute_code');
- $this->setDefaultDir('ASC');
- }
-
+ /**
+ * Prepare product attributes grid collection object
+ *
+ * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Grid
+ */
protected function _prepareCollection()
{
- $collection = Mage::getResourceModel('eav/entity_attribute_collection')
- ->setEntityTypeFilter( Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId() )
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
->addVisibleFilter();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+ /**
+ * Prepare product attributes grid columns
+ *
+ * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Grid
+ */
protected function _prepareColumns()
{
- /*
- $this->addColumn('attribute_id', array(
- 'header'=>Mage::helper('catalog')->__('ID'),
- 'align'=>'right',
- 'sortable'=>true,
- 'width' => '50px',
- 'index'=>'attribute_id'
- ));
- */
-
- $this->addColumn('attribute_code', array(
- 'header'=>Mage::helper('catalog')->__('Attribute Code'),
- 'sortable'=>true,
- 'index'=>'attribute_code'
- ));
+ parent::_prepareColumns();
- $this->addColumn('frontend_label', array(
- 'header'=>Mage::helper('catalog')->__('Attribute Label'),
- 'sortable'=>true,
- 'index'=>'frontend_label'
- ));
-
- $this->addColumn('is_visible', array(
+ $this->addColumnAfter('is_visible', array(
'header'=>Mage::helper('catalog')->__('Visible'),
'sortable'=>true,
'index'=>'is_visible_on_front',
@@ -86,9 +66,9 @@ protected function _prepareColumns()
'0' => Mage::helper('catalog')->__('No'),
),
'align' => 'center',
- ));
+ ), 'frontend_label');
- $this->addColumn('is_global', array(
+ $this->addColumnAfter('is_global', array(
'header'=>Mage::helper('catalog')->__('Scope'),
'sortable'=>true,
'index'=>'is_global',
@@ -99,31 +79,7 @@ protected function _prepareColumns()
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('catalog')->__('Global'),
),
'align' => 'center',
- ));
-
- $this->addColumn('is_required', array(
- 'header'=>Mage::helper('catalog')->__('Required'),
- 'sortable'=>true,
- 'index'=>'is_required',
- 'type' => 'options',
- 'options' => array(
- '1' => Mage::helper('catalog')->__('Yes'),
- '0' => Mage::helper('catalog')->__('No'),
- ),
- 'align' => 'center',
- ));
-
- $this->addColumn('is_user_defined', array(
- 'header'=>Mage::helper('catalog')->__('System'),
- 'sortable'=>true,
- 'index'=>'is_user_defined',
- 'type' => 'options',
- 'align' => 'center',
- 'options' => array(
- '0' => Mage::helper('catalog')->__('Yes'), // intended reverted use
- '1' => Mage::helper('catalog')->__('No'), // intended reverted use
- ),
- ));
+ ), 'is_visible');
$this->addColumn('is_searchable', array(
'header'=>Mage::helper('catalog')->__('Searchable'),
@@ -135,9 +91,9 @@ protected function _prepareColumns()
'0' => Mage::helper('catalog')->__('No'),
),
'align' => 'center',
- ));
+ ), 'is_user_defined');
- $this->addColumn('is_filterable', array(
+ $this->addColumnAfter('is_filterable', array(
'header'=>Mage::helper('catalog')->__('Use In Layered Navigation'),
'sortable'=>true,
'index'=>'is_filterable',
@@ -148,9 +104,9 @@ protected function _prepareColumns()
'0' => Mage::helper('catalog')->__('No'),
),
'align' => 'center',
- ));
+ ), 'is_searchable');
- $this->addColumn('is_comparable', array(
+ $this->addColumnAfter('is_comparable', array(
'header'=>Mage::helper('catalog')->__('Comparable'),
'sortable'=>true,
'index'=>'is_comparable',
@@ -160,14 +116,8 @@ protected function _prepareColumns()
'0' => Mage::helper('catalog')->__('No'),
),
'align' => 'center',
- ));
-
- return parent::_prepareColumns();
- }
+ ), 'is_filterable');
- public function getRowUrl($row)
- {
- return $this->getUrl('*/*/edit', array('attribute_id' => $row->getAttributeId()));
+ return $this;
}
-
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php
index bca0c3bbcb..91a083cd99 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php
@@ -187,8 +187,7 @@ public function getGroupTreeJson()
$item['allowDrop'] = true;
$item['allowDrag'] = true;
- $nodeChildren = Mage::getModel('eav/entity_attribute')
- ->getResourceCollection()
+ $nodeChildren = Mage::getResourceModel('catalog/product_attribute_collection')
->setAttributeGroupFilter($node->getId())
->addVisibleFilter()
->checkConfigurableProducts()
@@ -207,7 +206,7 @@ public function getGroupTreeJson()
'leaf' => true,
'is_user_defined' => $child->getIsUserDefined(),
'is_configurable' => (int)in_array($child->getAttributeId(), $configurable),
- 'entity_id' => $child->getEntityId()
+ 'entity_id' => $child->getEntityAttributeId()
);
$item['children'][] = $attr;
@@ -230,8 +229,7 @@ public function getAttributeTreeJson()
$items = array();
$setId = $this->_getSetId();
- $collection = Mage::getModel('eav/entity_attribute')
- ->getResourceCollection()
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
->setAttributeSetFilter($setId)
->load();
@@ -241,9 +239,7 @@ public function getAttributeTreeJson()
$attributesIds[] = $item->getAttributeId();
}
- $attributes = Mage::getModel('eav/entity_attribute')
- ->getResourceCollection()
- ->setEntityTypeFilter(Mage::registry('entityType'))
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
->setAttributesExcludeFilter($attributesIds)
->addVisibleFilter()
->load();
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php
index ea29de7b9e..c5678f1440 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php
@@ -43,7 +43,7 @@ protected function _prepareForm()
->load($this->getRequest()->getParam('id'));
$form = new Varien_Data_Form();
- $fieldset = $form->addFieldset('set_name', array('legend'=>__('Edit Set Name')));
+ $fieldset = $form->addFieldset('set_name', array('legend'=> Mage::helper('catalog')->__('Edit Set Name')));
$fieldset->addField('attribute_set_name', 'text',
array(
'label' => Mage::helper('catalog')->__('Name (For internal use)'),
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.php
index 7200b4bbd8..3a48bb52ac 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Ajax/Serializer.php
@@ -52,4 +52,20 @@ public function getProductsJSON()
}
return $result ? Zend_Json_Encoder::encode($result) : '{}';
}
+
+ /**
+ * Initialize grid block under the "Related Products", "Up-sells", "Cross-sells" sections
+ *
+ * @param string $blockName
+ * @param string $getProductFunction
+ * @param string $inputName
+ */
+ public function initSerializerBlock($blockName, $getProductFunction, $inputName)
+ {
+ if ($block = $this->getLayout()->getBlock($blockName)) {
+ $this->setGridBlock($block)
+ ->setProducts(Mage::registry('current_product')->$getProductFunction())
+ ->setInputElementName($inputName);
+ }
+ }
}
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 bf7d8330ed..08e8578211 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
@@ -33,6 +33,10 @@
*/
class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Crosssell extends Mage_Adminhtml_Block_Widget_Grid
{
+ /**
+ * Set grid params
+ *
+ */
public function __construct()
{
parent::__construct();
@@ -54,6 +58,12 @@ protected function _getProduct()
return Mage::registry('current_product');
}
+ /**
+ * Add filter
+ *
+ * @param object $column
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Crosssell
+ */
protected function _addColumnFilterToCollection($column)
{
// Set custom filter for in product flag
@@ -64,19 +74,22 @@ protected function _addColumnFilterToCollection($column)
}
if ($column->getFilter()->getValue()) {
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
- }
- else {
+ } else {
if($productIds) {
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
}
}
- }
- else {
+ } else {
parent::_addColumnFilterToCollection($column);
}
return $this;
}
+ /**
+ * Prepare collection
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
protected function _prepareCollection()
{
$collection = Mage::getModel('catalog/product_link')->useCrossSellLinks()
@@ -107,37 +120,42 @@ public function isReadonly()
return $this->_getProduct()->getCrosssellReadonly();
}
+ /**
+ * Add columns to grid
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
protected function _prepareColumns()
{
if (!$this->isReadonly()) {
$this->addColumn('in_products', array(
- 'header_css_class' => 'a-center',
- 'type' => 'checkbox',
- 'name' => 'in_products',
- 'values' => $this->_getSelectedProducts(),
- 'align' => 'center',
- 'index' => 'entity_id'
+ 'header_css_class' => 'a-center',
+ 'type' => 'checkbox',
+ 'name' => 'in_products',
+ 'values' => $this->_getSelectedProducts(),
+ 'align' => 'center',
+ 'index' => 'entity_id'
));
}
$this->addColumn('entity_id', array(
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
- 'width' => '60px',
+ 'width' => 60,
'index' => 'entity_id'
));
+
$this->addColumn('name', array(
'header' => Mage::helper('catalog')->__('Name'),
'index' => 'name'
));
- $this->addColumn('type',
- array(
- 'header'=> Mage::helper('catalog')->__('Type'),
- 'width' => '100px',
- 'index' => 'type_id',
- 'type' => 'options',
- 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
+ $this->addColumn('type', array(
+ 'header' => Mage::helper('catalog')->__('Type'),
+ 'width' => 100,
+ 'index' => 'type_id',
+ 'type' => 'options',
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
));
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
@@ -145,73 +163,89 @@ protected function _prepareColumns()
->load()
->toOptionHash();
- $this->addColumn('set_name',
- array(
- 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
- 'width' => '130px',
- 'index' => 'attribute_set_id',
- 'type' => 'options',
- 'options' => $sets,
+ $this->addColumn('set_name', array(
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
+ 'width' => 130,
+ 'index' => 'attribute_set_id',
+ 'type' => 'options',
+ 'options' => $sets,
));
- $this->addColumn('status',
- array(
- 'header'=> Mage::helper('catalog')->__('Status'),
- 'width' => '90px',
- 'index' => 'status',
- 'type' => 'options',
- 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
+ $this->addColumn('status', array(
+ 'header' => Mage::helper('catalog')->__('Status'),
+ 'width' => 90,
+ 'index' => 'status',
+ 'type' => 'options',
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
));
- $this->addColumn('visibility',
- array(
- 'header'=> Mage::helper('catalog')->__('Visibility'),
- 'width' => '90px',
- 'index' => 'visibility',
- 'type' => 'options',
- 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
+ $this->addColumn('visibility', array(
+ 'header' => Mage::helper('catalog')->__('Visibility'),
+ 'width' => 90,
+ 'index' => 'visibility',
+ 'type' => 'options',
+ 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
));
$this->addColumn('sku', array(
'header' => Mage::helper('catalog')->__('SKU'),
- 'width' => '80px',
+ 'width' => 80,
'index' => 'sku'
));
+
$this->addColumn('price', array(
- 'header' => Mage::helper('catalog')->__('Price'),
- 'type' => 'currency',
+ 'header' => Mage::helper('catalog')->__('Price'),
+ 'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
- 'index' => 'price'
+ 'index' => 'price'
));
$this->addColumn('position', array(
- 'header' => Mage::helper('catalog')->__('Position'),
- 'name' => 'position',
- 'width' => '60px',
- '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()
));
-
-
return parent::_prepareColumns();
}
+ /**
+ * Rerieve grid URL
+ *
+ * @return string
+ */
public function getGridUrl()
{
- return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/crosssell', array('_current'=>true));
+ return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/crosssellGrid', array('_current'=>true));
}
+ /**
+ * Retrieve selected crosssell products
+ *
+ * @return array
+ */
protected function _getSelectedProducts()
{
- $products = $this->getRequest()->getPost('products', null);
+ $products = $this->getProductsCrossSell();
if (!is_array($products)) {
- $products = $this->_getProduct()->getCrossSellProductIds();
+ $products = $this->getSelectedCrossSellProducts();
}
return $products;
}
+
+ /**
+ * Retrieve crosssell products
+ *
+ * @return array
+ */
+ public function getSelectedCrossSellProducts()
+ {
+ return Mage::registry('current_product')->getCrossSellProductIds();
+ }
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php
index bdf569c05f..63c23c3bc8 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php
@@ -38,9 +38,6 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option extends Mage_
protected $_productInstance;
- protected $_name = 'product[options]';
- protected $_id = 'product_option';
-
protected $_values;
protected $_itemCount = 1;
@@ -86,14 +83,24 @@ public function setProduct($product)
return $this;
}
+ /**
+ * Retrieve options field name prefix
+ *
+ * @return string
+ */
public function getFieldName()
{
- return $this->_name;
+ return 'product[options]';
}
+ /**
+ * Retrieve options field id prefix
+ *
+ * @return string
+ */
public function getFieldId()
{
- return $this->_id;
+ return 'product_option';
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.php
index 3fb72af344..2d38dffe35 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Abstract.php
@@ -44,10 +44,12 @@ protected function _prepareLayout()
'id' => 'product_option_{{option_id}}_price_type',
'class' => 'select product-option-price-type'
))
- ->setName('product[options][{{option_id}}][price_type]')
- ->setOptions(Mage::getSingleton('adminhtml/system_config_source_product_options_price')->toOptionArray())
);
+ $this->getChild('option_price_type')->setName('product[options][{{option_id}}][price_type]')
+ ->setOptions(Mage::getSingleton('adminhtml/system_config_source_product_options_price')
+ ->toOptionArray());
+
return parent::_prepareLayout();
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php
index 10f9199c1d..654f4d8c54 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php
@@ -25,154 +25,273 @@
*/
/**
- * Adminhtml tier pricing item renderer
+ * Adminhtml tier price item renderer
*
* @category Mage
* @package Mage_Adminhtml
- * @author Magento Core Team
+ * @author Magento Core Team
*/
-class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier extends Mage_Adminhtml_Block_Widget implements Varien_Data_Form_Element_Renderer_Interface
+class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier
+ extends Mage_Adminhtml_Block_Widget
+ implements Varien_Data_Form_Element_Renderer_Interface
{
+ /**
+ * Form element instance
+ *
+ * @var Varien_Data_Form_Element
+ */
+ protected $_element;
+
+ /**
+ * Customer Groups cache
+ *
+ * @var array
+ */
+ protected $_customerGroups;
- protected $_element = null;
- protected $_customerGroups = null;
- protected $_websites = null;
+ /**
+ * Websites cache
+ *
+ * @var array
+ */
+ protected $_websites;
+ /**
+ * Define tier price template file
+ *
+ */
public function __construct()
{
$this->setTemplate('catalog/product/edit/price/tier.phtml');
}
+ /**
+ * Retrieve current edit product instance
+ *
+ * @return Mage_Catalog_Model_Product
+ */
public function getProduct()
{
return Mage::registry('product');
}
+ /**
+ * Render HTML
+ *
+ * @param Varien_Data_Form_Element_Abstract $element
+ * @return string
+ */
public function render(Varien_Data_Form_Element_Abstract $element)
{
$this->setElement($element);
return $this->toHtml();
}
+ /**
+ * Set form element instance
+ *
+ * @param Varien_Data_Form_Element_Abstract $element
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier
+ */
public function setElement(Varien_Data_Form_Element_Abstract $element)
{
$this->_element = $element;
return $this;
}
+ /**
+ * Retrieve form element instance
+ *
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier
+ */
public function getElement()
{
return $this->_element;
}
+ /**
+ * Prepare Tier Price values
+ *
+ * @return array
+ */
public function getValues()
{
- $values =array();
- $data = $this->getElement()->getValue();
+ $values = array();
+ $data = $this->getElement()->getValue();
if (is_array($data)) {
usort($data, array($this, '_sortTierPrices'));
$values = $data;
}
+
+ foreach ($values as &$v) {
+ $v['readonly'] = $v['website_id'] == 0 && $this->isShowWebsiteColumn() && !$this->isAllowChangeWebsite();
+ }
+
return $values;
}
+ /**
+ * Sort tier price values callback method
+ *
+ * @param array $a
+ * @param array $b
+ * @return int
+ */
protected function _sortTierPrices($a, $b)
{
- if ($a['website_id']!=$b['website_id']) {
- return $a['website_id']<$b['website_id'] ? -1 : 1;
+ if ($a['website_id'] != $b['website_id']) {
+ return $a['website_id'] < $b['website_id'] ? -1 : 1;
}
- if ($a['cust_group']!=$b['cust_group']) {
- return $this->getCustomerGroups($a['cust_group'])<$this->getCustomerGroups($b['cust_group']) ? -1 : 1;
+ if ($a['cust_group'] != $b['cust_group']) {
+ return $this->getCustomerGroups($a['cust_group']) < $this->getCustomerGroups($b['cust_group']) ? -1 : 1;
}
- if ($a['price_qty']!=$b['price_qty']) {
- return $a['price_qty']<$b['price_qty'] ? -1 : 1;
+ if ($a['price_qty'] != $b['price_qty']) {
+ return $a['price_qty'] < $b['price_qty'] ? -1 : 1;
}
+
return 0;
}
- public function getCustomerGroups($groupId=null)
+ /**
+ * Retrieve allowed customer groups
+ *
+ * @param int $groupId return name by customer group id
+ * @return array|string
+ */
+ public function getCustomerGroups($groupId = null)
{
- if (!$this->_customerGroups) {
- $collection = Mage::getModel('customer/group')->getCollection()
- ->load();
+ if (is_null($this->_customerGroups)) {
+ $collection = Mage::getModel('customer/group')->getCollection();
$this->_customerGroups = array(
- Mage_Customer_Model_Group::CUST_GROUP_ALL => Mage::helper('catalog')->__('ALL GROUPS'),
+ Mage_Customer_Model_Group::CUST_GROUP_ALL => Mage::helper('catalog')->__('ALL GROUPS')
);
- foreach ($collection->getIterator() as $item) {
+
+ foreach ($collection as $item) {
+ /* @var $item Mage_Customer_Model_Group */
$this->_customerGroups[$item->getId()] = $item->getCustomerGroupCode();
}
}
- return is_null($groupId) ? $this->_customerGroups :
- (isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : null);
+
+ if (!is_null($groupId)) {
+ return isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : null;
+ }
+
+ return $this->_customerGroups;
}
+ /**
+ * Retrieve count of websites
+ *
+ * @return int
+ */
public function getWebsiteCount()
{
return count($this->getWebsites());
}
+ /**
+ * Show Website column and switcher for tier price table
+ *
+ * @return bool
+ */
public function isMultiWebsites()
{
return !Mage::app()->isSingleStoreMode();
}
+ /**
+ * Retrieve allowed for edit websites
+ *
+ * @return array
+ */
public function getWebsites()
{
if (!is_null($this->_websites)) {
return $this->_websites;
}
- $websites = array();
- $websites[0] = array(
- 'name' => $this->__('All Websites'),
- 'currency' => Mage::app()->getBaseCurrencyCode()
+
+ $this->_websites = array(
+ 0 => array(
+ 'name' => Mage::helper('catalog')->__('All Websites'),
+ 'currency' => Mage::app()->getBaseCurrencyCode()
+ )
);
- if (Mage::app()->isSingleStoreMode() || $this->getElement()->getEntityAttribute()->isScopeGlobal()) {
- return $websites;
- }
- elseif ($storeId = $this->getProduct()->getStoreId()) {
- $website = Mage::app()->getStore($storeId)->getWebsite();
- $websites[$website->getId()] = array(
+
+ if (!$this->isScopeGlobal() && $this->getProduct()->getStoreId()) {
+ /* @var $website Mage_Core_Model_Website */
+ $website = Mage::app()->getStore($this->getProduct()->getStoreId())->getWebsite();
+
+ $this->_websites[$website->getId()] = array(
'name' => $website->getName(),
- 'currency' => $website->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
- );
- }
- else {
- $websites[0] = array(
- 'name' => $this->__('All Websites'),
- 'currency' => Mage::app()->getBaseCurrencyCode()
+ 'currency' => $website->getBaseCurrencyCode()
);
- foreach (Mage::app()->getWebsites() as $website) {
- if (!in_array($website->getId(), $this->getProduct()->getWebsiteIds())) {
+ } else if (!$this->isScopeGlobal()) {
+ $websites = Mage::app()->getWebsites(false);
+ $productWebsiteIds = $this->getProduct()->getWebsiteIds();
+ foreach ($websites as $website) {
+ /* @var $website Mage_Core_Model_Website */
+ if (!in_array($website->getId(), $productWebsiteIds)) {
continue;
}
- $websites[$website->getId()] = array(
+ $this->_websites[$website->getId()] = array(
'name' => $website->getName(),
- 'currency' => $website->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
+ 'currency' => $website->getBaseCurrencyCode()
);
}
}
- $this->_websites = $websites;
+
return $this->_websites;
}
+ /**
+ * Retrieve default value for customer group
+ *
+ * @return int
+ */
public function getDefaultCustomerGroup()
{
return Mage_Customer_Model_Group::CUST_GROUP_ALL;
}
+ /**
+ * Retrieve default value for website
+ *
+ * @return int
+ */
+ public function getDefaultWebsite()
+ {
+ if ($this->isShowWebsiteColumn() && !$this->isAllowChangeWebsite()) {
+ return Mage::app()->getStore($this->getProduct()->getStoreId())->getWebsiteId();
+ }
+ return 0;
+ }
+
+ /**
+ * Prepare global layout
+ * Add "Add tier" button to layout
+ *
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier
+ */
protected function _prepareLayout()
{
- $this->setChild('add_button',
- $this->getLayout()->createBlock('adminhtml/widget_button')
- ->setData(array(
- 'label' => Mage::helper('catalog')->__('Add Tier'),
- 'onclick' => 'tierPriceControl.addItem()',
- 'class' => 'add'
- )));
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
+ ->setData(array(
+ 'label' => Mage::helper('catalog')->__('Add Tier'),
+ 'onclick' => 'return tierPriceControl.addItem()',
+ 'class' => 'add'
+ ));
+ $button->setName('add_tier_price_item_button');
+
+ $this->setChild('add_button', $button);
return parent::_prepareLayout();
}
+ /**
+ * Retrieve Add Tier Price Item button HTML
+ *
+ * @return string
+ */
public function getAddButtonHtml()
{
return $this->getChildHtml('add_button');
@@ -193,4 +312,52 @@ public function getPriceColumnHeader($default)
return $default;
}
}
-}
\ No newline at end of file
+
+ /**
+ * Retrieve Tier Price entity attribute
+ *
+ * @return Mage_Catalog_Model_Resource_Eav_Attribute
+ */
+ public function getAttribute()
+ {
+ return $this->getElement()->getEntityAttribute();
+ }
+
+ /**
+ * Check tier price attribute scope is global
+ *
+ * @return bool
+ */
+ public function isScopeGlobal()
+ {
+ return $this->getAttribute()->isScopeGlobal();
+ }
+
+ /**
+ * Show tier prices grid website column
+ *
+ * @return bool
+ */
+ public function isShowWebsiteColumn()
+ {
+ if ($this->isScopeGlobal()) {
+ return false;
+ } else if (Mage::app()->isSingleStoreMode()) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check is allow change website value for combination
+ *
+ * @return bool
+ */
+ public function isAllowChangeWebsite()
+ {
+ if (!$this->isShowWebsiteColumn() || $this->getProduct()->getStoreId()) {
+ return false;
+ }
+ return true;
+ }
+}
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 5f957300ea..50d351ad84 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
@@ -33,6 +33,10 @@
*/
class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Related extends Mage_Adminhtml_Block_Widget_Grid
{
+ /**
+ * Set grid params
+ *
+ */
public function __construct()
{
parent::__construct();
@@ -54,6 +58,12 @@ protected function _getProduct()
return Mage::registry('current_product');
}
+ /**
+ * Add filter
+ *
+ * @param object $column
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Related
+ */
protected function _addColumnFilterToCollection($column)
{
// Set custom filter for in product flag
@@ -64,19 +74,22 @@ protected function _addColumnFilterToCollection($column)
}
if ($column->getFilter()->getValue()) {
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
- }
- else {
+ } else {
if($productIds) {
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
}
}
- }
- else {
+ } else {
parent::_addColumnFilterToCollection($column);
}
return $this;
}
+ /**
+ * Prepare collection
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
protected function _prepareCollection()
{
$collection = Mage::getModel('catalog/product_link')->useRelatedLinks()
@@ -106,24 +119,28 @@ public function isReadonly()
return $this->_getProduct()->getRelatedReadonly();
}
-
+ /**
+ * Add columns to grid
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
protected function _prepareColumns()
{
if (!$this->isReadonly()) {
$this->addColumn('in_products', array(
- 'header_css_class' => 'a-center',
- 'type' => 'checkbox',
- 'name' => 'in_products',
- 'values' => $this->_getSelectedProducts(),
- 'align' => 'center',
- 'index' => 'entity_id'
+ 'header_css_class' => 'a-center',
+ 'type' => 'checkbox',
+ 'name' => 'in_products',
+ 'values' => $this->_getSelectedProducts(),
+ 'align' => 'center',
+ 'index' => 'entity_id'
));
}
$this->addColumn('entity_id', array(
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
- 'width' => '60px',
+ 'width' => 60,
'index' => 'entity_id'
));
$this->addColumn('name', array(
@@ -131,13 +148,12 @@ protected function _prepareColumns()
'index' => 'name'
));
- $this->addColumn('type',
- array(
- 'header'=> Mage::helper('catalog')->__('Type'),
- 'width' => '100px',
- 'index' => 'type_id',
- 'type' => 'options',
- 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
+ $this->addColumn('type', array(
+ 'header' => Mage::helper('catalog')->__('Type'),
+ 'width' => 100,
+ 'index' => 'type_id',
+ 'type' => 'options',
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
));
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
@@ -145,81 +161,88 @@ protected function _prepareColumns()
->load()
->toOptionHash();
- $this->addColumn('set_name',
- array(
- 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
- 'width' => '130px',
- 'index' => 'attribute_set_id',
- 'type' => 'options',
- 'options' => $sets,
+ $this->addColumn('set_name', array(
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
+ 'width' => 130,
+ 'index' => 'attribute_set_id',
+ 'type' => 'options',
+ 'options' => $sets,
));
- $this->addColumn('status',
- array(
- 'header'=> Mage::helper('catalog')->__('Status'),
- 'width' => '90px',
- 'index' => 'status',
- 'type' => 'options',
- 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
+ $this->addColumn('status', array(
+ 'header' => Mage::helper('catalog')->__('Status'),
+ 'width' => 90,
+ 'index' => 'status',
+ 'type' => 'options',
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
));
- $this->addColumn('visibility',
- array(
- 'header'=> Mage::helper('catalog')->__('Visibility'),
- 'width' => '90px',
- 'index' => 'visibility',
- 'type' => 'options',
- 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
+ $this->addColumn('visibility', array(
+ 'header' => Mage::helper('catalog')->__('Visibility'),
+ 'width' => 90,
+ 'index' => 'visibility',
+ 'type' => 'options',
+ 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
));
$this->addColumn('sku', array(
'header' => Mage::helper('catalog')->__('SKU'),
- 'width' => '80px',
+ 'width' => 80,
'index' => 'sku'
));
+
$this->addColumn('price', array(
- 'header' => Mage::helper('catalog')->__('Price'),
- 'type' => 'currency',
+ 'header' => Mage::helper('catalog')->__('Price'),
+ 'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
- 'index' => 'price'
+ 'index' => 'price'
));
- /*$this->addColumn('qty', array(
- 'header' => Mage::helper('catalog')->__('Default Qty'),
- 'name' => 'qty',
- 'align' => 'center',
- 'type' => 'number',
- 'validate_class' => 'validate-number',
- 'index' => 'qty',
- 'width' => '60px',
- 'editable' => true
- ));*/
-
$this->addColumn('position', array(
- 'header' => Mage::helper('catalog')->__('Position'),
- 'name' => 'position',
- 'type' => 'number',
- 'validate_class' => 'validate-number',
- 'index' => 'position',
- 'width' => '60px',
- 'editable' => !$this->isReadonly(),
- 'edit_only' => !$this->_getProduct()->getId()
+ 'header' => Mage::helper('catalog')->__('Position'),
+ 'name' => 'position',
+ 'type' => 'number',
+ 'validate_class' => 'validate-number',
+ 'index' => 'position',
+ 'width' => 60,
+ 'editable' => !$this->isReadonly(),
+ 'edit_only' => !$this->_getProduct()->getId()
));
return parent::_prepareColumns();
}
+ /**
+ * Rerieve grid URL
+ *
+ * @return string
+ */
public function getGridUrl()
{
- return $this->getData('grid_url') ? $this->getData('grid_url') : $this->getUrl('*/*/related', array('_current'=>true));
+ return $this->getData('grid_url') ? $this->getData('grid_url') : $this->getUrl('*/*/relatedGrid', array('_current'=>true));
}
+ /**
+ * Retrieve selected related products
+ *
+ * @return array
+ */
protected function _getSelectedProducts()
{
- $products = $this->getRequest()->getPost('products', null);
+ $products = $this->getProductsRelated();
if (!is_array($products)) {
- $products = $this->_getProduct()->getRelatedProductIds();
+ $products = $this->getSelectedRelatedProducts();
}
return $products;
}
+
+ /**
+ * Retrieve related products
+ *
+ * @return array
+ */
+ public function getSelectedRelatedProducts()
+ {
+ return Mage::registry('current_product')->getRelatedProductIds();
+ }
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php
index 732a343b8e..a948597e47 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php
@@ -40,7 +40,7 @@ protected function _getOptions()
return array(
array(
'value' => '',
- 'label' => Mage::helper('catalog')->__('')
+ 'label' => ''
),
array(
'value' => 1,
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 551b07c022..9d2bd64756 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
@@ -164,18 +164,34 @@ protected function _prepareColumns()
public function getGridUrl()
{
- return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/superGroup', array('_current'=>true));
+ return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/superGroupGridOnly', array('_current'=>true));
}
+ /**
+ * Retrieve selected grouped products
+ *
+ * @return array
+ */
protected function _getSelectedProducts()
{
- $products = $this->getRequest()->getPost('products', null);
+ $products = $this->getProductsGrouped();
if (!is_array($products)) {
- $products = $this->_getProduct()->getTypeInstance(true)->getAssociatedProductIds($this->_getProduct());
+ $products = $this->getSelectedGroupedProducts();
}
return $products;
}
+ /**
+ * Retrieve grouped products
+ *
+ * @return array
+ */
+ public function getSelectedGroupedProducts()
+ {
+ return Mage::registry('current_product')->getTypeInstance(true)
+ ->getAssociatedProductIds(Mage::registry('current_product'));
+ }
+
public function getTabLabel()
{
return Mage::helper('catalog')->__('Associated Products');
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag.php
index f46288f744..caa5f4df25 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag.php
@@ -45,11 +45,10 @@ public function __construct()
protected function _prepareCollection()
{
- $tagId = Mage::registry('tagId');
$collection = Mage::getModel('tag/tag')
->getResourceCollection()
->addProductFilter($this->getProductId())
- ->addPopularity($tagId);
+ ->addPopularity();
$this->setCollection($collection);
return parent::_prepareCollection();
@@ -80,7 +79,7 @@ protected function _prepareColumns()
'width' => '90px',
'index' => 'status',
'type' => 'options',
- 'options' => array(
+ 'options' => array(
Mage_Tag_Model_Tag::STATUS_DISABLED => Mage::helper('catalog')->__('Disabled'),
Mage_Tag_Model_Tag::STATUS_PENDING => Mage::helper('catalog')->__('Pending'),
Mage_Tag_Model_Tag::STATUS_APPROVED => Mage::helper('catalog')->__('Approved'),
@@ -93,17 +92,17 @@ protected function _prepareColumns()
protected function getRowUrl($row)
{
return $this->getUrl('*/tag/edit', array(
- 'tag_id' => $row->getId(),
- 'product_id' => $this->getProductId(),
+ 'tag_id' => $row->getId(),
+ 'product_id' => $this->getProductId(),
));
}
public function getGridUrl()
{
return $this->getUrl('*/catalog_product/tagGrid', array(
- '_current' => true,
- 'id' => $this->getProductId(),
- 'product_id' => $this->getProductId(),
+ '_current' => true,
+ 'id' => $this->getProductId(),
+ 'product_id' => $this->getProductId(),
));
}
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag/Customer.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag/Customer.php
index 2688a679dc..648bdb37df 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag/Customer.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Tag/Customer.php
@@ -49,7 +49,8 @@ protected function _prepareCollection()
$collection = Mage::getModel('tag/tag')
->getCustomerCollection()
->addProductFilter($this->getProductId())
- ->addGroupByTag();
+ ->addGroupByTag()
+ ->addDescOrder();
$this->setCollection($collection);
return parent::_prepareCollection();
@@ -87,10 +88,7 @@ protected function _prepareColumns()
protected function getRowUrl($row)
{
- return $this->getUrl('*/tag/edit', array(
- 'tag_id' => $row->getTagId(),
- 'product_id' => $this->getProductId(),
- ));
+ return $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId()));
}
public function getGridUrl()
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 ba48494b5b..c3c0920305 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
@@ -34,6 +34,10 @@
class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Upsell extends Mage_Adminhtml_Block_Widget_Grid
{
+ /**
+ * Set grid params
+ *
+ */
public function __construct()
{
parent::__construct();
@@ -55,6 +59,12 @@ protected function _getProduct()
return Mage::registry('current_product');
}
+ /**
+ * Add filter
+ *
+ * @param object $column
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Upsell
+ */
protected function _addColumnFilterToCollection($column)
{
// Set custom filter for in product flag
@@ -65,14 +75,12 @@ protected function _addColumnFilterToCollection($column)
}
if ($column->getFilter()->getValue()) {
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
- }
- else {
+ } else {
if($productIds) {
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
}
}
- }
- else {
+ } else {
parent::_addColumnFilterToCollection($column);
}
return $this;
@@ -88,6 +96,11 @@ public function isReadonly()
return $this->_getProduct()->getUpsellReadonly();
}
+ /**
+ * Prepare collection
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
protected function _prepareCollection()
{
$collection = Mage::getModel('catalog/product_link')->useUpSellLinks()
@@ -107,6 +120,11 @@ protected function _prepareCollection()
return parent::_prepareCollection();
}
+ /**
+ * Add columns to grid
+ *
+ * @return Mage_Adminhtml_Block_Widget_Grid
+ */
protected function _prepareColumns()
{
if (!$this->_getProduct()->getUpsellReadonly()) {
@@ -123,7 +141,7 @@ protected function _prepareColumns()
$this->addColumn('entity_id', array(
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
- 'width' => '60px',
+ 'width' => 60,
'index' => 'entity_id'
));
$this->addColumn('name', array(
@@ -131,13 +149,12 @@ protected function _prepareColumns()
'index' => 'name'
));
- $this->addColumn('type',
- array(
- 'header'=> Mage::helper('catalog')->__('Type'),
- 'width' => '100px',
- 'index' => 'type_id',
- 'type' => 'options',
- 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
+ $this->addColumn('type', array(
+ 'header' => Mage::helper('catalog')->__('Type'),
+ 'width' => 100,
+ 'index' => 'type_id',
+ 'type' => 'options',
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
));
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
@@ -145,71 +162,89 @@ protected function _prepareColumns()
->load()
->toOptionHash();
- $this->addColumn('set_name',
- array(
- 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
- 'width' => '130px',
- 'index' => 'attribute_set_id',
- 'type' => 'options',
- 'options' => $sets,
+ $this->addColumn('set_name', array(
+ 'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
+ 'width' => 130,
+ 'index' => 'attribute_set_id',
+ 'type' => 'options',
+ 'options' => $sets,
));
- $this->addColumn('status',
- array(
- 'header'=> Mage::helper('catalog')->__('Status'),
- 'width' => '90px',
- 'index' => 'status',
- 'type' => 'options',
- 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
+ $this->addColumn('status', array(
+ 'header' => Mage::helper('catalog')->__('Status'),
+ 'width' => 90,
+ 'index' => 'status',
+ 'type' => 'options',
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
));
- $this->addColumn('visibility',
- array(
- 'header'=> Mage::helper('catalog')->__('Visibility'),
- 'width' => '90px',
- 'index' => 'visibility',
- 'type' => 'options',
- 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
+ $this->addColumn('visibility', array(
+ 'header' => Mage::helper('catalog')->__('Visibility'),
+ 'width' => 90,
+ 'index' => 'visibility',
+ 'type' => 'options',
+ 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
));
$this->addColumn('sku', array(
'header' => Mage::helper('catalog')->__('SKU'),
- 'width' => '80px',
+ 'width' => 80,
'index' => 'sku'
));
+
$this->addColumn('price', array(
- 'header' => Mage::helper('catalog')->__('Price'),
- 'type' => 'currency',
+ 'header' => Mage::helper('catalog')->__('Price'),
+ 'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
- 'index' => 'price'
+ 'index' => 'price'
));
$this->addColumn('position', array(
- 'header' => Mage::helper('catalog')->__('Position'),
- 'name' => 'position',
- 'type' => 'number',
- 'width' => '60px',
- '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()
));
return parent::_prepareColumns();
}
+ /**
+ * Rerieve grid URL
+ *
+ * @return string
+ */
public function getGridUrl()
{
- return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/upsell', array('_current'=>true));
+ return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/upsellGrid', array('_current'=>true));
}
+ /**
+ * Retrieve selected upsell products
+ *
+ * @return array
+ */
protected function _getSelectedProducts()
{
- $products = $this->getRequest()->getPost('products', null);
+ $products = $this->getProductsUpsell();
if (!is_array($products)) {
- $products = $this->_getProduct()->getUpSellProductIds();
+ $products = $this->getSelectedUpsellProducts();
}
return $products;
}
+ /**
+ * Retrieve upsell products
+ *
+ * @return array
+ */
+ public function getSelectedUpsellProducts()
+ {
+ return Mage::registry('current_product')->getUpSellProductIds();
+ }
+
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php
index a7271a0a5f..da9e6eaf91 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Edit/Form.php
@@ -122,8 +122,8 @@ protected function _prepareForm()
. Mage::helper('catalog')->__('(Will make search for the query above return results for this search.)')
. '
';
- $fieldset->addField('synonim_for', 'text', array(
- 'name' => 'synonim_for',
+ $fieldset->addField('synonym_for', 'text', array(
+ 'name' => 'synonym_for',
'label' => Mage::helper('catalog')->__('Synonym For'),
'title' => Mage::helper('catalog')->__('Synonym For'),
'after_element_html' => $afterElementHtml,
@@ -137,6 +137,7 @@ protected function _prepareForm()
'name' => 'redirect',
'label' => Mage::helper('catalog')->__('Redirect URL'),
'title' => Mage::helper('catalog')->__('Redirect URL'),
+ 'class' => 'validate-url',
'after_element_html' => $afterElementHtml,
));
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Grid.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Grid.php
index c03b8a9965..67d8ed9526 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Search/Grid.php
@@ -100,10 +100,10 @@ protected function _prepareColumns()
'type' => 'number'
));
- $this->addColumn('synonim_for', array(
+ $this->addColumn('synonym_for', array(
'header' => Mage::helper('catalog')->__('Synonym for'),
'align' => 'left',
- 'index' => 'synonim_for',
+ 'index' => 'synonym_for',
'width' => '160px'
));
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php
index 3c162c8fc2..86de942ba2 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php
@@ -45,6 +45,17 @@ public function __construct()
$this->setTitle(Mage::helper('cms')->__('Block Information'));
}
+ /**
+ * Load Wysiwyg on demand and Prepare layout
+ */
+ protected function _prepareLayout()
+ {
+ parent::_prepareLayout();
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
+ }
+ }
+
protected function _prepareForm()
{
$model = Mage::registry('cms_block');
@@ -112,8 +123,8 @@ protected function _prepareForm()
'label' => Mage::helper('cms')->__('Content'),
'title' => Mage::helper('cms')->__('Content'),
'style' => 'height:36em',
- 'wysiwyg' => false,
'required' => true,
+ 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()
));
$form->setValues($model->getData());
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page.php
index 81af057660..b0a439dd18 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Page.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page.php
@@ -42,8 +42,26 @@ public function __construct()
{
$this->_controller = 'cms_page';
$this->_headerText = Mage::helper('cms')->__('Manage Pages');
- $this->_addButtonLabel = Mage::helper('cms')->__('Add New Page');
+
parent::__construct();
+
+ if ($this->_isAllowedAction('save')) {
+ $this->_updateButton('add', 'label', Mage::helper('cms')->__('Add New Page'));
+ } else {
+ $this->_removeButton('add');
+ }
+
+ }
+
+ /**
+ * Check permission for passed action
+ *
+ * @param string $action
+ * @return bool
+ */
+ protected function _isAllowedAction($action)
+ {
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php
index 7f96bebac9..55f0ec0bf4 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php
@@ -41,14 +41,22 @@ public function __construct()
parent::__construct();
- $this->_updateButton('save', 'label', Mage::helper('cms')->__('Save Page'));
- $this->_updateButton('delete', 'label', Mage::helper('cms')->__('Delete Page'));
+ if ($this->_isAllowedAction('save')) {
+ $this->_updateButton('save', 'label', Mage::helper('cms')->__('Save Page'));
+ $this->_addButton('saveandcontinue', array(
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
+ 'onclick' => 'saveAndContinueEdit()',
+ 'class' => 'save',
+ ), -100);
+ } else {
+ $this->_removeButton('save');
+ }
- $this->_addButton('saveandcontinue', array(
- 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
- 'onclick' => 'saveAndContinueEdit()',
- 'class' => 'save',
- ), -100);
+ if ($this->_isAllowedAction('delete')) {
+ $this->_updateButton('delete', 'label', Mage::helper('cms')->__('Delete Page'));
+ } else {
+ $this->_removeButton('delete');
+ }
$this->_formScripts[] = "
function toggleEditor() {
@@ -65,6 +73,11 @@ function saveAndContinueEdit(){
";
}
+ /**
+ * Retrieve text for header element depending on loaded page
+ *
+ * @return string
+ */
public function getHeaderText()
{
if (Mage::registry('cms_page')->getId()) {
@@ -75,4 +88,14 @@ public function getHeaderText()
}
}
-}
\ No newline at end of file
+ /**
+ * Check permission for passed action
+ *
+ * @param string $action
+ * @return bool
+ */
+ protected function _isAllowedAction($action)
+ {
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
+ }
+}
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php
index 63c7e1c207..ae4efb32ec 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php
@@ -23,7 +23,9 @@
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Design extends Mage_Adminhtml_Block_Widget_Form
+class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Design
+ extends Mage_Adminhtml_Block_Widget_Form
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
public function __construct()
{
@@ -31,53 +33,94 @@ public function __construct()
$this->setShowGlobalIcon(true);
}
- public function _prepareForm()
+ protected function _prepareForm()
{
+ /*
+ * Checking if user have permissions to save information
+ */
+ if ($this->_isAllowedAction('save')) {
+ $isElementDisabled = false;
+ } else {
+ $isElementDisabled = true;
+ }
+
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('page_');
$model = Mage::registry('cms_page');
- $fieldset = $form->addFieldset('design_fieldset', array(
- 'legend' => Mage::helper('cms')->__('Custom Design'),
+ $layoutFieldset = $form->addFieldset('layout_fieldset', array(
+ 'legend' => Mage::helper('cms')->__('Page Layout'),
'class' => 'fieldset-wide',
+ 'disabled' => $isElementDisabled
));
- $fieldset->addField('custom_theme', 'select', array(
- 'name' => 'custom_theme',
- 'label' => Mage::helper('cms')->__('Custom Theme'),
- 'values' => Mage::getModel('core/design_source_design')->getAllOptions(),
+ $layoutFieldset->addField('root_template', 'select', array(
+ 'name' => 'root_template',
+ 'label' => Mage::helper('cms')->__('Layout'),
+ 'required' => true,
+ 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(),
+ 'disabled' => $isElementDisabled
+ ));
+
+ $layoutFieldset->addField('layout_update_xml', 'textarea', array(
+ 'name' => 'layout_update_xml',
+ 'label' => Mage::helper('cms')->__('Layout Update XML'),
+ 'style' => 'height:24em;',
+ 'disabled' => $isElementDisabled
+ ));
+
+ $designFieldset = $form->addFieldset('design_fieldset', array(
+ 'legend' => Mage::helper('cms')->__('Custom Design'),
+ 'class' => 'fieldset-wide',
+ 'disabled' => $isElementDisabled
));
- $fieldset->addField('custom_theme_from', 'date', array(
+ $dateFormatIso = Mage::app()->getLocale()->getDateFormat(
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
+ );
+
+ $designFieldset->addField('custom_theme_from', 'date', array(
'name' => 'custom_theme_from',
- 'label' => Mage::helper('cms')->__('Custom Theme From'),
+ 'label' => Mage::helper('cms')->__('Custom Design From'),
'image' => $this->getSkinUrl('images/grid-cal.gif'),
- 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
+ 'format' => $dateFormatIso,
+ 'disabled' => $isElementDisabled
));
- $fieldset->addField('custom_theme_to', 'date', array(
+ $designFieldset->addField('custom_theme_to', 'date', array(
'name' => 'custom_theme_to',
- 'label' => Mage::helper('cms')->__('Custom Theme To'),
+ 'label' => Mage::helper('cms')->__('Custom Design To'),
'image' => $this->getSkinUrl('images/grid-cal.gif'),
- 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
+ 'format' => $dateFormatIso,
+ 'disabled' => $isElementDisabled
+ ));
+
+ $designFieldset->addField('custom_theme', 'select', array(
+ 'name' => 'custom_theme',
+ 'label' => Mage::helper('cms')->__('Custom Theme'),
+ 'values' => Mage::getModel('core/design_source_design')->getAllOptions(),
+ 'disabled' => $isElementDisabled
));
- $fieldset->addField('root_template', 'select', array(
- 'name' => 'root_template',
- 'label' => Mage::helper('cms')->__('Layout'),
- 'required' => true,
- 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(),
+ $designFieldset->addField('custom_root_template', 'select', array(
+ 'name' => 'custom_root_template',
+ 'label' => Mage::helper('cms')->__('Custom Layout'),
+ 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(true),
+ 'disabled' => $isElementDisabled
));
- $fieldset->addField('layout_update_xml', 'editor', array(
- 'name' => 'layout_update_xml',
- 'label' => Mage::helper('cms')->__('Layout Update XML'),
- 'style' => 'height:24em;'
+ $designFieldset->addField('custom_layout_update_xml', 'textarea', array(
+ 'name' => 'custom_layout_update_xml',
+ 'label' => Mage::helper('cms')->__('Custom Layout Update XML'),
+ 'style' => 'height:24em;',
+ 'disabled' => $isElementDisabled
));
+ Mage::dispatchEvent('adminhtml_cms_page_edit_tab_design_prepare_form', array('form' => $form));
+
$form->setValues($model->getData());
$this->setForm($form);
@@ -85,4 +128,54 @@ public function _prepareForm()
return parent::_prepareForm();
}
+ /**
+ * Prepare label for tab
+ *
+ * @return string
+ */
+ public function getTabLabel()
+ {
+ return Mage::helper('cms')->__('Design');
+ }
+
+ /**
+ * Prepare title for tab
+ *
+ * @return string
+ */
+ public function getTabTitle()
+ {
+ return Mage::helper('cms')->__('Design');
+ }
+
+ /**
+ * Returns status flag about this tab can be showen or not
+ *
+ * @return true
+ */
+ public function canShowTab()
+ {
+ return true;
+ }
+
+ /**
+ * Returns status flag about this tab hidden or not
+ *
+ * @return true
+ */
+ public function isHidden()
+ {
+ return false;
+ }
+
+ /**
+ * Check permission for passed action
+ *
+ * @param string $action
+ * @return bool
+ */
+ protected function _isAllowedAction($action)
+ {
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
+ }
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php
index aa584e3dff..8e76726d8a 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php
@@ -32,39 +32,53 @@
* @author Magento Core Team
*/
-class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
+class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Main
+ extends Mage_Adminhtml_Block_Widget_Form
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
-
protected function _prepareForm()
- {/** @var Cms_Model_Page */
+ {
+ /* @var $model Mage_Cms_Model_Page */
$model = Mage::registry('cms_page');
+ /*
+ * Checking if user have permissions to save information
+ */
+ if ($this->_isAllowedAction('save')) {
+ $isElementDisabled = false;
+ } else {
+ $isElementDisabled = true;
+ }
+
+
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('page_');
- $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('cms')->__('General Information'),'class'=>'fieldset-wide'));
+ $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('cms')->__('Page Information'),'class'=>'fieldset-wide'));
if ($model->getPageId()) {
- $fieldset->addField('page_id', 'hidden', array(
+ $fieldset->addField('page_id', 'hidden', array(
'name' => 'page_id',
));
}
- $fieldset->addField('title', 'text', array(
+ $fieldset->addField('title', 'text', array(
'name' => 'title',
'label' => Mage::helper('cms')->__('Page Title'),
'title' => Mage::helper('cms')->__('Page Title'),
'required' => true,
+ 'disabled' => $isElementDisabled
));
- $fieldset->addField('identifier', 'text', array(
+ $fieldset->addField('identifier', 'text', array(
'name' => 'identifier',
- 'label' => Mage::helper('cms')->__('SEF URL Identifier'),
- 'title' => Mage::helper('cms')->__('SEF URL Identifier'),
+ 'label' => Mage::helper('cms')->__('URL Key'),
+ 'title' => Mage::helper('cms')->__('URL Key'),
'required' => true,
'class' => 'validate-identifier',
'after_element_html' => '' . Mage::helper('cms')->__('(eg: domain.com/identifier)') . '
',
+ 'disabled' => $isElementDisabled
));
/**
@@ -77,6 +91,7 @@ protected function _prepareForm()
'title' => Mage::helper('cms')->__('Store View'),
'required' => true,
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
+ 'disabled' => $isElementDisabled
));
}
else {
@@ -87,30 +102,71 @@ protected function _prepareForm()
$model->setStoreId(Mage::app()->getStore(true)->getId());
}
- $fieldset->addField('is_active', 'select', array(
+ $fieldset->addField('is_active', 'select', array(
'label' => Mage::helper('cms')->__('Status'),
'title' => Mage::helper('cms')->__('Page Status'),
'name' => 'is_active',
'required' => true,
- 'options' => array(
- '1' => Mage::helper('cms')->__('Enabled'),
- '0' => Mage::helper('cms')->__('Disabled'),
- ),
- ));
-
- $fieldset->addField('content', 'editor', array(
- 'name' => 'content',
- 'label' => Mage::helper('cms')->__('Content'),
- 'title' => Mage::helper('cms')->__('Content'),
- 'style' => 'height:36em;',
- 'wysiwyg' => false,
- 'required' => true,
+ 'options' => $model->getAvailableStatuses(),
+ 'disabled' => $isElementDisabled
));
+ Mage::dispatchEvent('adminhtml_cms_page_edit_tab_main_prepare_form', array('form' => $form));
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
+
+ /**
+ * Prepare label for tab
+ *
+ * @return string
+ */
+ public function getTabLabel()
+ {
+ return Mage::helper('cms')->__('Page Information');
+ }
+
+ /**
+ * Prepare title for tab
+ *
+ * @return string
+ */
+ public function getTabTitle()
+ {
+ return Mage::helper('cms')->__('Page Information');
+ }
+
+ /**
+ * Returns status flag about this tab can be shown or not
+ *
+ * @return true
+ */
+ public function canShowTab()
+ {
+ return true;
+ }
+
+ /**
+ * Returns status flag about this tab hidden or not
+ *
+ * @return true
+ */
+ public function isHidden()
+ {
+ return false;
+ }
+
+ /**
+ * Check permission for passed action
+ *
+ * @param string $action
+ * @return bool
+ */
+ protected function _isAllowedAction($action)
+ {
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
+ }
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php
index d4eab819a2..a0f2121633 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php
@@ -31,7 +31,9 @@
* @package Mage_Adminhtml
* @author Magento Core Team
*/
-class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Meta extends Mage_Adminhtml_Block_Widget_Form
+class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Meta
+ extends Mage_Adminhtml_Block_Widget_Form
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
public function __construct()
{
@@ -40,6 +42,15 @@ public function __construct()
protected function _prepareForm()
{
+ /*
+ * Checking if user have permissions to save information
+ */
+ if ($this->_isAllowedAction('save')) {
+ $isElementDisabled = false;
+ } else {
+ $isElementDisabled = true;
+ }
+
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('page_');
@@ -48,18 +59,22 @@ protected function _prepareForm()
$fieldset = $form->addFieldset('meta_fieldset', array('legend' => Mage::helper('cms')->__('Meta Data'), 'class' => 'fieldset-wide'));
- $fieldset->addField('meta_keywords', 'editor', array(
+ $fieldset->addField('meta_keywords', 'textarea', array(
'name' => 'meta_keywords',
'label' => Mage::helper('cms')->__('Keywords'),
'title' => Mage::helper('cms')->__('Meta Keywords'),
+ 'disabled' => $isElementDisabled
));
- $fieldset->addField('meta_description', 'editor', array(
+ $fieldset->addField('meta_description', 'textarea', array(
'name' => 'meta_description',
'label' => Mage::helper('cms')->__('Description'),
'title' => Mage::helper('cms')->__('Meta Description'),
+ 'disabled' => $isElementDisabled
));
+ Mage::dispatchEvent('adminhtml_cms_page_edit_tab_meta_prepare_form', array('form' => $form));
+
$form->setValues($model->getData());
$this->setForm($form);
@@ -67,4 +82,54 @@ protected function _prepareForm()
return parent::_prepareForm();
}
+ /**
+ * Prepare label for tab
+ *
+ * @return string
+ */
+ public function getTabLabel()
+ {
+ return Mage::helper('cms')->__('Meta Data');
+ }
+
+ /**
+ * Prepare title for tab
+ *
+ * @return string
+ */
+ public function getTabTitle()
+ {
+ return Mage::helper('cms')->__('Meta Data');
+ }
+
+ /**
+ * Returns status flag about this tab can be showen or not
+ *
+ * @return true
+ */
+ public function canShowTab()
+ {
+ return true;
+ }
+
+ /**
+ * Returns status flag about this tab hidden or not
+ *
+ * @return true
+ */
+ public function isHidden()
+ {
+ return false;
+ }
+
+ /**
+ * Check permission for passed action
+ *
+ * @param string $action
+ * @return bool
+ */
+ protected function _isAllowedAction($action)
+ {
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
+ }
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php
index bbb99b93b6..c2f85ff3e5 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tabs.php
@@ -41,36 +41,4 @@ public function __construct()
$this->setDestElementId('edit_form');
$this->setTitle(Mage::helper('cms')->__('Page Information'));
}
-
- protected function _beforeToHtml()
- {
- $this->addTab('main_section', array(
- 'label' => Mage::helper('cms')->__('General Information'),
- 'title' => Mage::helper('cms')->__('General Information'),
- 'content' => $this->getLayout()->createBlock('adminhtml/cms_page_edit_tab_main')->toHtml(),
- 'active' => true
- ));
-
- $this->addTab('design_section', array(
- 'label' => Mage::helper('cms')->__('Custom Design'),
- 'title' => Mage::helper('cms')->__('Custom Design'),
- 'content' => $this->getLayout()->createBlock('adminhtml/cms_page_edit_tab_design')->toHtml(),
- ));
-
- $this->addTab('meta_section', array(
- 'label' => Mage::helper('cms')->__('Meta Data'),
- 'title' => Mage::helper('cms')->__('Meta Data'),
- 'content' => $this->getLayout()->createBlock('adminhtml/cms_page_edit_tab_meta')->toHtml(),
- ));
- if (Mage::app()->getConfig()->getModuleConfig('Mage_GoogleOptimizer')->is('active', true)
- && Mage::helper('googleoptimizer')->isOptimizerActiveForCms()) {
- $this->addTab('googleoptimizer_section', array(
- 'label' => Mage::helper('googleoptimizer')->__('Page View Optimization'),
- 'title' => Mage::helper('googleoptimizer')->__('Page View Optimization'),
- 'content' => $this->getLayout()->createBlock('googleoptimizer/adminhtml_cms_page_edit_tab_googleoptimizer')->toHtml(),
- ));
- }
- return parent::_beforeToHtml();
- }
-
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php
index 6ff54640df..768e066c42 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php
@@ -97,10 +97,7 @@ protected function _prepareColumns()
'header' => Mage::helper('cms')->__('Status'),
'index' => 'is_active',
'type' => 'options',
- 'options' => array(
- 0 => Mage::helper('cms')->__('Disabled'),
- 1 => Mage::helper('cms')->__('Enabled')
- ),
+ 'options' => Mage::getSingleton('cms/page')->getAvailableStatuses()
));
$this->addColumn('creation_time', array(
diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php
index 586c120073..ad540f93f3 100644
--- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php
+++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php
@@ -31,7 +31,12 @@
*/
class Mage_Adminhtml_Block_Customer_Edit_Renderer_Region extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
{
-
+ /**
+ * Output the region element and javasctipt that makes it dependent from country element
+ *
+ * @param Varien_Data_Form_Element_Abstract $element
+ * @return string
+ */
public function render(Varien_Data_Form_Element_Abstract $element)
{
if ($country = $element->getForm()->getElement('country_id')) {
@@ -42,7 +47,6 @@ public function render(Varien_Data_Form_Element_Abstract $element)
}
$regionId = $element->getForm()->getElement('region_id')->getValue();
- $postcode = $element->getForm()->getElement('postcode');
$html = '';
$element->setClass('input-text');
@@ -54,27 +58,12 @@ public function render(Varien_Data_Form_Element_Abstract $element)
$html.= '';
$html.= ''.Mage::helper('customer')->__('Please select').' ';
$html.= ' ';
- $html.= '';
+
+ $html.= ''."\n";
+
$html.= ' '."\n";
return $html;
}
-
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php
index bcde34a2d9..c0626b55d5 100644
--- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php
+++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php
@@ -133,23 +133,23 @@ public function initForm()
'id' => 'sendemail',
));
if (!Mage::app()->isSingleStoreMode()) {
- $fieldset->addField('store_id', 'select', array(
+ $fieldset->addField('sendemail_store_id', 'select', array(
'label' => $this->helper('customer')->__('Send From'),
- 'name' => 'store_id',
+ 'name' => 'sendemail_store_id',
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm()
));
}
}
- // make sendemail and store_id disabled, if website_id has empty value
- if ($sendemail = $form->getElement('store_id')) {
+ // make sendemail and sendmail_store_id disabled, if website_id has empty value
+ if ($sendemail = $form->getElement('sendemail_store_id')) {
$prefix = $form->getHtmlIdPrefix();
$sendemail->setAfterElementHtml(
'';
diff --git a/app/code/core/Mage/Core/Block/Messages.php b/app/code/core/Mage/Core/Block/Messages.php
index 732fd6020f..51657b7be0 100644
--- a/app/code/core/Mage/Core/Block/Messages.php
+++ b/app/code/core/Mage/Core/Block/Messages.php
@@ -40,13 +40,30 @@ class Mage_Core_Block_Messages extends Mage_Core_Block_Template
*/
protected $_messages;
+ /**
+ * Flag which require message text escape
+ *
+ * @var bool
+ */
+ protected $_escapeMessageFlag = false;
+
public function _prepareLayout()
{
$this->addMessages(Mage::getSingleton('core/session')->getMessages(true));
-
parent::_prepareLayout();
}
+ /**
+ * Set message escape flag
+ * @param bool $flag
+ * @return Mage_Core_Block_Messages
+ */
+ public function setEscapeMessageFlag($flag)
+ {
+ $this->_escapeMessageFlag = $flag;
+ return $this;
+ }
+
/**
* Set messages collection
*
@@ -59,6 +76,12 @@ public function setMessages(Mage_Core_Model_Message_Collection $messages)
return $this;
}
+ /**
+ * Add messages to display
+ *
+ * @param Mage_Core_Model_Message_Collection $messages
+ * @return Mage_Core_Block_Messages
+ */
public function addMessages(Mage_Core_Model_Message_Collection $messages)
{
foreach ($messages->getItems() as $message) {
@@ -161,7 +184,9 @@ public function getHtml($type=null)
{
$html = '';
foreach ($this->getMessages($type) as $message) {
- $html.= ''.$message->getText().' ';
+ $html.= ''
+ . ($this->_escapeMessageFlag) ? $this->htmlEscape($message->getText()) : $message->getText()
+ . ' ';
}
$html .= ' ';
return $html;
@@ -192,7 +217,7 @@ public function getGroupedHtml()
foreach ( $messages as $message ) {
$html.= '';
- $html.= $message->getText();
+ $html.= ($this->_escapeMessageFlag) ? $this->htmlEscape($message->getText()) : $message->getText();
$html.= ' ';
}
$html .= '';
diff --git a/app/code/core/Mage/Core/Block/Template.php b/app/code/core/Mage/Core/Block/Template.php
index 6421d66b1f..65086f8f0f 100644
--- a/app/code/core/Mage/Core/Block/Template.php
+++ b/app/code/core/Mage/Core/Block/Template.php
@@ -56,9 +56,53 @@ class Mage_Core_Block_Template extends Mage_Core_Block_Abstract
protected static $_showTemplateHints;
protected static $_showTemplateHintsBlocks;
+ /**
+ * Path to template file in theme.
+ *
+ * @var string
+ */
+ protected $_template;
+
+ /**
+ * Internal constructor, that is called from real constructor
+ *
+ */
+ protected function _construct()
+ {
+ parent::_construct();
+
+ /*
+ * In case template was passed through constructor
+ * we assign it to block's property _template
+ * Mainly for those cases when block created
+ * not via Mage_Core_Model_Layout::addBlock()
+ */
+ if ($this->hasData('template')) {
+ $this->setTemplate($this->getData('template'));
+ }
+ }
+
+ /**
+ * Retrieve path to template used for generating block's output.
+ *
+ * @return string
+ */
public function getTemplate()
{
- return $this->_getData('template');
+ return $this->_template;
+ }
+
+ /**
+ * Set path to template used for generating block's output.
+ *
+ * @param string $template
+ * @return Mage_Core_Block_Template
+ */
+ public function setTemplate($template)
+ {
+ $this->_template = $template;
+
+ return $this;
}
public function getArea()
diff --git a/app/code/core/Mage/Core/Controller/Front/Action.php b/app/code/core/Mage/Core/Controller/Front/Action.php
index 81a36e3f7b..9d5aff916e 100644
--- a/app/code/core/Mage/Core/Controller/Front/Action.php
+++ b/app/code/core/Mage/Core/Controller/Front/Action.php
@@ -33,6 +33,20 @@
*/
class Mage_Core_Controller_Front_Action extends Mage_Core_Controller_Varien_Action
{
+ /**
+ * Currently used area
+ *
+ * @var string
+ */
+ protected $_currentArea = 'frontend';
+
+ /**
+ * Namespace for session.
+ *
+ * @var string
+ */
+ protected $_sessionNamespace = 'frontend';
+
/**
* Predispatch: shoud set layout area
*
@@ -40,7 +54,7 @@ class Mage_Core_Controller_Front_Action extends Mage_Core_Controller_Varien_Acti
*/
public function preDispatch()
{
- $this->getLayout()->setArea('frontend');
+ $this->getLayout()->setArea($this->_currentArea);
parent::preDispatch();
return $this;
diff --git a/app/code/core/Mage/Core/Controller/Request/Http.php b/app/code/core/Mage/Core/Controller/Request/Http.php
index 269151b7cf..ef29372fba 100644
--- a/app/code/core/Mage/Core/Controller/Request/Http.php
+++ b/app/code/core/Mage/Core/Controller/Request/Http.php
@@ -57,6 +57,13 @@ class Mage_Core_Controller_Request_Http extends Zend_Controller_Request_Http
protected $_directFrontNames = array();
protected $_controllerModule = null;
+ /**
+ * Request's original information before forward.
+ *
+ * @var array
+ */
+ protected $_beforeForwardInfo = array();
+
public function __construct($uri = null)
{
parent::__construct($uri);
@@ -391,4 +398,43 @@ public function getRequestedActionName()
}
return $this->getActionName();
}
+
+ /**
+ * Collect properties changed by _forward in protected storage
+ * before _forward was called first time.
+ *
+ * @return Mage_Core_Controller_Varien_Action
+ */
+ public function initForward()
+ {
+ if (empty($this->_beforeForwardInfo)) {
+ $this->_beforeForwardInfo = array(
+ 'params' => $this->getParams(),
+ 'action_name' => $this->getActionName(),
+ 'controller_name' => $this->getControllerName(),
+ 'module_name' => $this->getModuleName()
+ );
+ }
+
+ return $this;
+ }
+
+ /**
+ * Retrieve property's value which was before _forward call.
+ * If property was not changed during _forward call null will be returned.
+ * If passed name will be null whole state array will be returned.
+ *
+ * @param string $name
+ * @return array|string|null
+ */
+ public function getBeforeForwardInfo($name = null)
+ {
+ if (is_null($name)) {
+ return $this->_beforeForwardInfo;
+ } elseif (isset($this->_beforeForwardInfo[$name])) {
+ return $this->_beforeForwardInfo[$name];
+ }
+
+ return null;
+ }
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php
index e3ec66df0d..5b12422e7f 100644
--- a/app/code/core/Mage/Core/Controller/Varien/Action.php
+++ b/app/code/core/Mage/Core/Controller/Varien/Action.php
@@ -89,6 +89,21 @@ abstract class Mage_Core_Controller_Varien_Action
*/
protected $_cookieCheckActions = array();
+ /**
+ * Currently used area
+ *
+ * @var string
+ */
+ protected $_currentArea;
+
+ /**
+ * Namespace for session.
+ * Should be defined for proper working session.
+ *
+ * @var string
+ */
+ protected $_sessionNamespace;
+
/**
* Constructor
*
@@ -432,14 +447,13 @@ public function preDispatch()
}
if (!$this->getFlag('', self::FLAG_NO_START_SESSION)) {
- $namespace = $this->getLayout()->getArea();
$checkCookie = in_array($this->getRequest()->getActionName(), $this->_cookieCheckActions);
$checkCookie = $checkCookie && !$this->getRequest()->getParam('nocookie', false);
$cookies = Mage::getSingleton('core/cookie')->get();
if ($checkCookie && empty($cookies)) {
$this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true);
}
- Mage::getSingleton('core/session', array('name' => $namespace))->start();
+ Mage::getSingleton('core/session', array('name' => $this->_sessionNamespace))->start();
}
Mage::app()->loadArea($this->getLayout()->getArea());
@@ -530,10 +544,20 @@ public function noCookiesAction()
$this->getRequest()->setDispatched(true);
}
+ /**
+ * Throw control to different action (control and module if was specified).
+ *
+ * @param string $action
+ * @param string|null $controller
+ * @param string|null $module
+ * @param string|null $params
+ */
protected function _forward($action, $controller = null, $module = null, array $params = null)
{
$request = $this->getRequest();
+ $request->initForward();
+
if (!is_null($params)) {
$request->setParams($params);
}
@@ -555,6 +579,9 @@ protected function _initLayoutMessages($messagesStorage)
{
if ($storage = Mage::getSingleton($messagesStorage)) {
$this->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
+ $this->getLayout()->getMessagesBlock()->setEscapeMessageFlag(
+ $storage->getEscapeMessages(true)
+ );
}
else {
Mage::throwException(
@@ -577,7 +604,7 @@ protected function _redirectUrl($url)
}
/**
- * Set redirect into responce
+ * Set redirect into response
*
* @param string $path
* @param array $arguments
diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
index 917dd09225..1eea173cd4 100644
--- a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
+++ b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
@@ -104,7 +104,7 @@ protected function _afterModuleMatch()
public function match(Zend_Controller_Request_Http $request)
{
- //checkings before even try to findout that current module
+ //checking before even try to find out that current module
//should use this router
if (!$this->_beforeModuleMatch()) {
return false;
@@ -198,7 +198,7 @@ public function match(Zend_Controller_Request_Http $request)
}
// instantiate controller class
- $controllerInstance = new $controllerClassName($request, $front->getResponse());
+ $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
if (!$controllerInstance->hasAction($action)) {
continue;
@@ -222,7 +222,7 @@ public function match(Zend_Controller_Request_Http $request)
}
// instantiate controller class
- $controllerInstance = Mage::getControllerInstance($request, $front->getResponse());
+ $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
if (!$controllerInstance->hasAction($action)) {
return false;
@@ -251,7 +251,7 @@ public function match(Zend_Controller_Request_Http $request)
}
/**
- * Allow to control if we need to enable norout functionality in current router
+ * Allow to control if we need to enable no route functionality in current router
*
* @return bool
*/
diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php
index 5a64ae7fb4..03780a5d2e 100644
--- a/app/code/core/Mage/Core/Helper/String.php
+++ b/app/code/core/Mage/Core/Helper/String.php
@@ -51,20 +51,20 @@ public function truncate($string, $length = 80, $etc = '...', &$remainder = '',
return '';
}
- $originalLength = iconv_strlen($string, self::ICONV_CHARSET);
+ $originalLength = $this->strlen($string);
if ($originalLength > $length) {
- $length -= iconv_strlen($etc, self::ICONV_CHARSET);
+ $length -= $this->strlen($etc);
if ($length <= 0) {
return '';
}
$preparedString = $string;
$preparedlength = $length;
if (!$breakWords) {
- $preparedString = preg_replace('/\s+?(\S+)?$/', '', iconv_substr($string, 0, $length + 1, self::ICONV_CHARSET));
- $preparedlength = iconv_strlen($preparedString, self::ICONV_CHARSET);
+ $preparedString = preg_replace('/\s+?(\S+)?$/', '', $this->substr($string, 0, $length + 1));
+ $preparedlength = $this->strlen($preparedString);
}
- $remainder = iconv_substr($string, $preparedlength, $originalLength, self::ICONV_CHARSET);
- return iconv_substr($preparedString, 0, $length, self::ICONV_CHARSET) . $etc;
+ $remainder = $this->substr($string, $preparedlength, $originalLength);
+ return $this->substr($preparedString, 0, $length) . $etc;
}
return $string;
@@ -92,7 +92,7 @@ public function strlen($str)
public function substr($str, $offset, $length = null)
{
if (is_null($length)) {
- $length = iconv_strlen($str, self::ICONV_CHARSET) - $offset;
+ $length = $this->strlen($str) - $offset;
}
return iconv_substr($str, $offset, $length, self::ICONV_CHARSET);
}
@@ -112,10 +112,10 @@ public function splitInjection($str, $length = 50, $needle = '-', $insert = ' ')
$newStr = '';
foreach ($str as $part) {
if ($this->strlen($part) >= $length) {
- $lastDelimetr = iconv_strpos(strrev($part), $needle, null, self::ICONV_CHARSET);
+ $lastDelimetr = iconv_strpos($this->strrev($part), $needle, null, self::ICONV_CHARSET);
$tmpNewStr = '';
- $tmpNewStr = $this->substr(strrev($part), 0, $lastDelimetr) . $insert . $this->substr(strrev($part), $lastDelimetr);
- $newStr .= strrev($tmpNewStr);
+ $tmpNewStr = $this->substr($this->strrev($part), 0, $lastDelimetr) . $insert . $this->substr($this->strrev($part), $lastDelimetr);
+ $newStr .= $this->strrev($tmpNewStr);
} else {
$newStr .= $part;
}
@@ -137,7 +137,7 @@ public function strrev($str)
return $result;
}
for ($i = $strlen-1; $i >= 0; $i--) {
- $result .= iconv_substr($str, $i, 1, self::ICONV_CHARSET);
+ $result .= $this->substr($str, $i, 1);
}
return $result;
}
@@ -169,7 +169,7 @@ public function str_split($str, $length = 1, $keepWords = false, $trim = false,
// do a usual str_split, but safe for our encoding
if ((!$keepWords) || ($length < 2)) {
for ($offset = 0; $offset < $strlen; $offset += $length) {
- $result[] = iconv_substr($str, $offset, $length, self::ICONV_CHARSET);
+ $result[] = $this->substr($str, $offset, $length);
}
}
// split smartly, keeping words
@@ -194,9 +194,9 @@ public function str_split($str, $length = 1, $keepWords = false, $trim = false,
$spaceLen = 0;
}
else {
- $currentLength = iconv_strlen($result[$i], self::ICONV_CHARSET);
+ $currentLength = $this->strlen($result[$i]);
}
- $partLength = iconv_strlen($part, self::ICONV_CHARSET);
+ $partLength = $this->strlen($part);
// add part to current last element
if (($currentLength + $spaceLen + $partLength) <= $length) {
$result[$i] .= $space . $part;
@@ -217,12 +217,12 @@ public function str_split($str, $length = 1, $keepWords = false, $trim = false,
}
// remove last element, if empty
if ($count = count($result)) {
- if (empty($result[$count - 1])) {
+ if ($result[$count - 1] === '') {
unset($result[$count - 1]);
}
}
// remove first element, if empty
- if (isset($result[0]) && empty($result[0])) {
+ if (isset($result[0]) && $result[0] === '') {
array_shift($result);
}
return $result;
@@ -233,11 +233,11 @@ public function str_split($str, $length = 1, $keepWords = false, $trim = false,
*
* @param string $str The source string
* @param bool $uniqueOnly Unique words only
- * @param int $maxWordLenght Limit words count
+ * @param int $maxWordLength Limit words count
* @param string $wordSeparatorRegexp
* @return array
*/
- function splitWords($str, $uniqueOnly = false, $maxWordLenght = 0, $wordSeparatorRegexp = '\s')
+ function splitWords($str, $uniqueOnly = false, $maxWordLength = 0, $wordSeparatorRegexp = '\s')
{
$result = array();
$split = preg_split('#' . $wordSeparatorRegexp . '#si', $str, null, PREG_SPLIT_NO_EMPTY);
@@ -249,8 +249,8 @@ function splitWords($str, $uniqueOnly = false, $maxWordLenght = 0, $wordSeparato
$result[] = $word;
}
}
- if ($maxWordLenght && count($result) > $maxWordLenght) {
- $result = array_slice($result, 0, $maxWordLenght);
+ if ($maxWordLength && count($result) > $maxWordLength) {
+ $result = array_slice($result, 0, $maxWordLength);
}
return $result;
}
diff --git a/app/code/core/Mage/Core/Model/Abstract.php b/app/code/core/Mage/Core/Model/Abstract.php
index 40e9e6084e..80e5b1d94f 100644
--- a/app/code/core/Mage/Core/Model/Abstract.php
+++ b/app/code/core/Mage/Core/Model/Abstract.php
@@ -89,6 +89,13 @@ abstract class Mage_Core_Model_Abstract extends Varien_Object
*/
protected $_dataSaveAllowed = true;
+ /**
+ * Flag which allow detect object state: is it new object (without id) or existing one (with id)
+ *
+ * @var bool
+ */
+ protected $_isObjectNew = null;
+
/**
* Standard model initialization
*
@@ -244,7 +251,14 @@ public function afterLoad()
*/
public function save()
{
+ /**
+ * Direct deleted items to delete method
+ */
+ if ($this->isDeleted()) {
+ return $this->delete();
+ }
$this->_getResource()->beginTransaction();
+ $dataCommited = false;
try {
$this->_beforeSave();
if ($this->_dataSaveAllowed) {
@@ -252,14 +266,49 @@ public function save()
$this->_afterSave();
}
$this->_getResource()->commit();
- }
- catch (Exception $e){
+ $dataCommited = true;
+ } catch (Exception $e) {
$this->_getResource()->rollBack();
throw $e;
}
+ if ($dataCommited) {
+ $this->_afterSaveCommit();
+ }
return $this;
}
+ /**
+ * Processing data save after main transaction commit
+ *
+ * @return Mage_Core_Model_Abstract
+ */
+ protected function _afterSaveCommit()
+ {
+ Mage::dispatchEvent('model_save_commit_after', array('object'=>$this));
+ Mage::dispatchEvent($this->_eventPrefix.'_save_commit_after', array($this->_eventObject=>$this));
+ return $this;
+ }
+
+ /**
+ * Check object state (true - if it is object without id on object just created)
+ * This method can help detect if object just created in _afterSave method
+ * problem is what in after save onject has id and we can't detect what object was
+ * created in this transaction
+ *
+ * @param bool $flag
+ * @return bool
+ */
+ public function isObjectNew($flag=null)
+ {
+ if ($flag !== null) {
+ $this->_isObjectNew = $flag;
+ }
+ if ($this->_isObjectNew !== null) {
+ return $this->_isObjectNew;
+ }
+ return !(bool)$this->getId();
+ }
+
/**
* Processing object before save data
*
@@ -267,6 +316,9 @@ public function save()
*/
protected function _beforeSave()
{
+ if (!$this->getId()) {
+ $this->isObjectNew(true);
+ }
Mage::dispatchEvent('model_save_before', array('object'=>$this));
Mage::dispatchEvent($this->_eventPrefix.'_save_before', array($this->_eventObject=>$this));
return $this;
@@ -282,8 +334,9 @@ protected function _afterSave()
if ($this->_cacheTag) {
if ($this->_cacheTag === true) {
$tags = array();
- }
- else {
+ } elseif (is_array($this->_cacheTag)) {
+ $tags = $this->_cacheTag;
+ } else {
$tags = array($this->_cacheTag);
}
Mage::app()->cleanCache($tags);
@@ -307,6 +360,7 @@ public function delete()
$this->_afterDelete();
$this->_getResource()->commit();
+ $this->_afterDeleteCommit();
}
catch (Exception $e){
$this->_getResource()->rollBack();
@@ -363,6 +417,18 @@ protected function _afterDelete()
return $this;
}
+ /**
+ * Processing manipulation after main transaction commit
+ *
+ * @return Mage_Core_Model_Abstract
+ */
+ protected function _afterDeleteCommit()
+ {
+ Mage::dispatchEvent('model_delete_commit_after', array('object'=>$this));
+ Mage::dispatchEvent($this->_eventPrefix.'_delete_commit_after', array($this->_eventObject=>$this));
+ return $this;
+ }
+
/**
* Retrieve model resource
*
diff --git a/app/code/core/Mage/Core/Model/App.php b/app/code/core/Mage/Core/Model/App.php
index a4f9c4004e..d4a7d6ebee 100644
--- a/app/code/core/Mage/Core/Model/App.php
+++ b/app/code/core/Mage/Core/Model/App.php
@@ -1197,10 +1197,10 @@ public function dispatchEvent($eventName, $args)
$observers = array();
foreach ($eventConfig->observers->children() as $obsName=>$obsConfig) {
$observers[$obsName] = array(
- 'type' => $obsConfig->type ? (string)$obsConfig->type : 'singleton',
+ 'type' => (string)$obsConfig->type,
'model' => $obsConfig->class ? (string)$obsConfig->class : $obsConfig->getClassName(),
- 'method' => (string)$obsConfig->method,
- 'args' => (array)$obsConfig->args,
+ 'method'=> (string)$obsConfig->method,
+ 'args' => (array)$obsConfig->args,
);
}
$events[$eventName]['observers'] = $observers;
@@ -1218,17 +1218,16 @@ public function dispatchEvent($eventName, $args)
$observer->setData(array('event'=>$event));
Varien_Profiler::start('OBSERVER: '.$obsName);
switch ($obs['type']) {
- case 'singleton':
+ case 'object': case 'model':
$method = $obs['method'];
$observer->addData($args);
- $object = Mage::getSingleton($obs['model']);
+ $object = Mage::getModel($obs['model']);
$object->$method($observer);
break;
-
- case 'object': case 'model':
+ default:
$method = $obs['method'];
$observer->addData($args);
- $object = Mage::getModel($obs['model']);
+ $object = Mage::getSingleton($obs['model']);
$object->$method($observer);
break;
}
diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php
index d23e252a1a..7c80eef899 100644
--- a/app/code/core/Mage/Core/Model/Config.php
+++ b/app/code/core/Mage/Core/Model/Config.php
@@ -310,7 +310,7 @@ protected function _canUseLocalModules()
$disableLocalModules = false;
}
- if ($disableLocalModules) {
+ if ($disableLocalModules && !defined('COMPILER_INCLUDE_PATH')) {
set_include_path(
// excluded '/app/code/local'
BP . DS . 'app' . DS . 'code' . DS . 'community' . PS .
@@ -1141,10 +1141,12 @@ public function getResourceConnectionConfig($name)
$config = $this->getResourceConfig($name);
if ($config) {
$conn = $config->connection;
- if (!empty($conn->use)) {
- return $this->getResourceConnectionConfig((string)$conn->use);
- } else {
- return $conn;
+ if ($conn) {
+ if (!empty($conn->use)) {
+ return $this->getResourceConnectionConfig((string)$conn->use);
+ } else {
+ return $conn;
+ }
}
}
return false;
diff --git a/app/code/core/Mage/Core/Model/Config/Data.php b/app/code/core/Mage/Core/Model/Config/Data.php
index 2df0086840..b08369d787 100644
--- a/app/code/core/Mage/Core/Model/Config/Data.php
+++ b/app/code/core/Mage/Core/Model/Config/Data.php
@@ -33,6 +33,22 @@
*/
class Mage_Core_Model_Config_Data extends Mage_Core_Model_Abstract
{
+ const ENTITY = 'core_config_data';
+ /**
+ * Prefix of model events names
+ *
+ * @var string
+ */
+ protected $_eventPrefix = 'core_config_data';
+
+ /**
+ * Parameter name in event
+ *
+ * In observe method you can use $observer->getEvent()->getObject() in this case
+ *
+ * @var string
+ */
+ protected $_eventObject = 'config_data';
/**
* Varien model constructor
diff --git a/app/code/core/Mage/Core/Model/Config/Element.php b/app/code/core/Mage/Core/Model/Config/Element.php
index 0bf57663d3..b61339e0ed 100644
--- a/app/code/core/Mage/Core/Model/Config/Element.php
+++ b/app/code/core/Mage/Core/Model/Config/Element.php
@@ -41,20 +41,20 @@ class Mage_Core_Model_Config_Element extends Varien_Simplexml_Element
* @param boolean $value
* @return boolean
*/
- public function is($var, $value=true)
+ public function is($var, $value = true)
{
$flag = $this->$var;
- if ($value===true) {
+ if ($value === true) {
$flag = strtolower((string)$flag);
- if (!empty($flag) && 'false'!==$flag && '0'!==$flag && 'off'!==$flag) {
+ if (!empty($flag) && 'false' !== $flag && 'off' !== $flag) {
return true;
} else {
return false;
}
}
- return !empty($flag) && (0===strcasecmp($value, (string)$flag));
+ return !empty($flag) && (0 === strcasecmp($value, (string)$flag));
}
/**
diff --git a/app/code/core/Mage/Core/Model/Config/Options.php b/app/code/core/Mage/Core/Model/Config/Options.php
index 766b11b620..84cf952648 100644
--- a/app/code/core/Mage/Core/Model/Config/Options.php
+++ b/app/code/core/Mage/Core/Model/Config/Options.php
@@ -68,7 +68,6 @@ protected function _construct()
public function getDir($type)
{
- $this->_construct();
$method = 'get'.ucwords($type).'Dir';
$dir = $this->$method();
if (!$dir) {
diff --git a/app/code/core/Mage/Core/Model/Cookie.php b/app/code/core/Mage/Core/Model/Cookie.php
index 8129085435..14d311d0f2 100644
--- a/app/code/core/Mage/Core/Model/Cookie.php
+++ b/app/code/core/Mage/Core/Model/Cookie.php
@@ -100,13 +100,23 @@ protected function _getResponse()
*/
public function getDomain()
{
- $domain = Mage::getStoreConfig(self::XML_PATH_COOKIE_DOMAIN, $this->getStore());
+ $domain = $this->getConfigDomain();
if (empty($domain)) {
$domain = $this->_getRequest()->getHttpHost();
}
return $domain;
}
+ /**
+ * Retrieve Config Domain for cookie
+ *
+ * @return string
+ */
+ public function getConfigDomain()
+ {
+ return (string)Mage::getStoreConfig(self::XML_PATH_COOKIE_DOMAIN, $this->getStore());
+ }
+
/**
* Retrieve Path for cookie
*
@@ -128,10 +138,9 @@ public function getPath()
*/
public function getLifetime()
{
- if (null !== $this->_lifetime) {
+ if (!is_null($this->_lifetime)) {
$lifetime = $this->_lifetime;
- }
- else {
+ } else {
$lifetime = Mage::getStoreConfig(self::XML_PATH_COOKIE_LIFETIME, $this->getStore());
}
if (!is_numeric($lifetime)) {
diff --git a/app/code/core/Mage/Core/Model/Design/Source/Design.php b/app/code/core/Mage/Core/Model/Design/Source/Design.php
index 954e47911b..fd920f911f 100644
--- a/app/code/core/Mage/Core/Model/Design/Source/Design.php
+++ b/app/code/core/Mage/Core/Model/Design/Source/Design.php
@@ -27,28 +27,62 @@
class Mage_Core_Model_Design_Source_Design extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{
+ protected $_isFullLabel = false;
+
+ /**
+ * Setter
+ * Add package name to label
+ *
+ * @param boolean $isFullLabel
+ * @return Mage_Core_Model_Design_Source_Design
+ */
+ public function setIsFulllabel($isFullLabel)
+ {
+ $this->_isFullLabel = $isFullLabel;
+ return $this;
+ }
+
+ /**
+ * Getter
+ *
+ * @return boolean
+ */
+ public function getIsFullLabel()
+ {
+ return $this->_isFullLabel;
+ }
+
+ /**
+ * Retrieve All Design Theme Options
+ *
+ * @param bool $withEmpty add empty (please select) values to result
+ * @return array
+ */
public function getAllOptions($withEmpty = true)
{
if (is_null($this->_options)) {
$design = Mage::getModel('core/design_package')->getThemeList();
$options = array();
- foreach ($design as $package=>$themes){
- $packageOption = array('label'=>$package);
+ foreach ($design as $package => $themes){
+ $packageOption = array('label' => $package);
$themeOptions = array();
foreach ($themes as $theme) {
- $themeOptions[] = array('label'=>$theme, 'value'=>$package . '/' . $theme);
+ $themeOptions[] = array(
+ 'label' => ($this->getIsFullLabel() ? $package . ' / ' : '') . $theme,
+ 'value' => $package . '/' . $theme
+ );
}
-
$packageOption['value'] = $themeOptions;
-
$options[] = $packageOption;
}
$this->_options = $options;
}
-
$options = $this->_options;
if ($withEmpty) {
- array_unshift($options, array('value'=>'', 'label'=>Mage::helper('core')->__('-- Please Select --')));
+ array_unshift($options, array(
+ 'value'=>'',
+ 'label'=>Mage::helper('core')->__('-- Please Select --'))
+ );
}
return $options;
}
diff --git a/app/code/core/Mage/Core/Model/Email/Template.php b/app/code/core/Mage/Core/Model/Email/Template.php
index 86776fbfc2..659ae977bf 100644
--- a/app/code/core/Mage/Core/Model/Email/Template.php
+++ b/app/code/core/Mage/Core/Model/Email/Template.php
@@ -54,7 +54,8 @@ class Mage_Core_Model_Email_Template extends Varien_Object
* Configuration path for default email templates
*
*/
- const XML_PATH_TEMPLATE_EMAIL = 'global/template/email';
+ const XML_PATH_TEMPLATE_EMAIL = 'global/template/email';
+ const XML_PATH_SENDING_SET_RETURN_PATH = 'system/smtp/set_return_path';
protected $_templateFilter;
protected $_preprocessFlag = false;
@@ -315,9 +316,9 @@ public function getInclude($template, array $variables)
* @param array $variables template variables
* @return boolean
**/
- public function send($email, $name=null, array $variables = array())
+ public function send($email, $name = null, array $variables = array())
{
- if(!$this->isValidForSend()) {
+ if (!$this->isValidForSend()) {
return false;
}
@@ -332,6 +333,11 @@ public function send($email, $name=null, array $variables = array())
ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
$mail = $this->getMail();
+
+ if (Mage::getStoreConfigFlag(self::XML_PATH_SENDING_SET_RETURN_PATH)) {
+ $mail->setReturnPath($this->getSenderEmail());
+ }
+
if (is_array($email)) {
foreach ($email as $emailOne) {
$mail->addTo($emailOne, $name);
diff --git a/app/code/core/Mage/Core/Model/Email/Template/Filter.php b/app/code/core/Mage/Core/Model/Email/Template/Filter.php
index 952a929856..acc4599f52 100644
--- a/app/code/core/Mage/Core/Model/Email/Template/Filter.php
+++ b/app/code/core/Mage/Core/Model/Email/Template/Filter.php
@@ -113,16 +113,20 @@ public function blockDirective($construction)
} elseif (isset($blockParameters['id'])) {
$block = $layout->createBlock('cms/block');
if ($block) {
- $block->setBlockId($blockParameters['id'])
- ->setBlockParams($blockParameters);
- foreach ($blockParameters as $k => $v) {
- if (in_array($k, $skipParams)) {
- continue;
- }
- $block->setDataUsingMethod($k, $v);
+ $block->setBlockId($blockParameters['id']);
+ }
+ }
+
+ if ($block) {
+ $block->setBlockParams($blockParameters);
+ foreach ($blockParameters as $k => $v) {
+ if (in_array($k, $skipParams)) {
+ continue;
}
+ $block->setDataUsingMethod($k, $v);
}
}
+
if (!$block) {
return '';
}
diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php
index 2f38aa4af6..9ee4bc554e 100644
--- a/app/code/core/Mage/Core/Model/Layout.php
+++ b/app/code/core/Mage/Core/Model/Layout.php
@@ -368,7 +368,7 @@ protected function _translateLayoutNode($node, &$args)
$args[$arg] = Mage::helper((string)$node['module'])->__($args[$arg]);
}
else {
- $args[$arg] = __($args[$arg]);
+ $args[$arg] = Mage::helper('core')->__($args[$arg]);
}
}
}
diff --git a/app/code/core/Mage/Core/Model/Layout/Update.php b/app/code/core/Mage/Core/Model/Layout/Update.php
index f772ced03a..68abaddefc 100644
--- a/app/code/core/Mage/Core/Model/Layout/Update.php
+++ b/app/code/core/Mage/Core/Model/Layout/Update.php
@@ -243,71 +243,97 @@ public function asSimplexml()
*/
public function merge($handle)
{
- if (!$this->fetchPackageLayoutUpdates($handle)
- && !$this->fetchDbLayoutUpdates($handle)) {
- #$this->removeHandle($handle);
+ $packageUpdatesStatus = $this->fetchPackageLayoutUpdates($handle);
+ if (Mage::app()->isInstalled()) {
+ $this->fetchDbLayoutUpdates($handle);
}
+// if (!$this->fetchPackageLayoutUpdates($handle)
+// && !$this->fetchDbLayoutUpdates($handle)) {
+// #$this->removeHandle($handle);
+// }
return $this;
}
public function fetchFileLayoutUpdates()
{
+ $storeId = Mage::app()->getStore()->getId();
$elementClass = $this->getElementClass();
-
$design = Mage::getSingleton('core/design_package');
- $area = $design->getArea();
- $storeId = Mage::app()->getStore()->getId();
- $cacheKey = 'LAYOUT_'.$area.'_STORE'.$storeId.'_'.$design->getPackageName().'_'.$design->getTheme('layout');
-#echo "TEST:".$cacheKey;
+ $cacheKey = 'LAYOUT_'.$design->getArea().'_STORE'.$storeId.'_'.$design->getPackageName().'_'.$design->getTheme('layout');
$cacheTags = array('layout');
-
if (Mage::app()->useCache('layout') && ($layoutStr = Mage::app()->loadCache($cacheKey))) {
$this->_packageLayout = simplexml_load_string($layoutStr, $elementClass);
}
-
if (empty($layoutStr)) {
- $updatesRoot = Mage::app()->getConfig()->getNode($area.'/layout/updates');
- Mage::dispatchEvent('core_layout_update_updates_get_after', array('updates' => $updatesRoot));
- $updateFiles = array();
- foreach ($updatesRoot->children() as $updateNode) {
- if ($updateNode->file) {
- $module = $updateNode->getAttribute('module');
- if ($module && Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $module)) {
- continue;
- }
- $updateFiles[] = (string)$updateNode->file;
- }
- }
-
- // custom local layout updates file - load always last
- $updateFiles[] = 'local.xml';
-
- $layoutStr = '';
- #$layoutXml = new $elementClass(' ');
- foreach ($updateFiles as $file) {
- $filename = $design->getLayoutFilename($file);
- if (!is_readable($filename)) {
- continue;
- }
- $fileStr = file_get_contents($filename);
- $fileStr = str_replace($this->_subst['from'], $this->_subst['to'], $fileStr);
- $fileXml = simplexml_load_string($fileStr, $elementClass);
- if (!$fileXml instanceof SimpleXMLElement) {
- continue;
- }
- $layoutStr .= $fileXml->innerXml();
-
- #$layoutXml->appendChild($fileXml);
- }
- $layoutXml = simplexml_load_string(''.$layoutStr.' ', $elementClass);
-
- $this->_packageLayout = $layoutXml;
-
+ $this->_packageLayout = $this->getFileLayoutUpdatesXml(
+ $design->getArea(),
+ $design->getPackageName(),
+ $design->getTheme('layout'),
+ $storeId
+ );
if (Mage::app()->useCache('layout')) {
Mage::app()->saveCache($this->_packageLayout->asXml(), $cacheKey, $cacheTags, null);
}
}
+
+
+// $elementClass = $this->getElementClass();
+//
+// $design = Mage::getSingleton('core/design_package');
+// $area = $design->getArea();
+// $storeId = Mage::app()->getStore()->getId();
+// $cacheKey = 'LAYOUT_'.$area.'_STORE'.$storeId.'_'.$design->getPackageName().'_'.$design->getTheme('layout');
+//#echo "TEST:".$cacheKey;
+// $cacheTags = array('layout');
+//
+// if (Mage::app()->useCache('layout') && ($layoutStr = Mage::app()->loadCache($cacheKey))) {
+// $this->_packageLayout = simplexml_load_string($layoutStr, $elementClass);
+// }
+//
+// if (empty($layoutStr)) {
+// $updatesRoot = Mage::app()->getConfig()->getNode($area.'/layout/updates');
+// Mage::dispatchEvent('core_layout_update_updates_get_after', array('updates' => $updatesRoot));
+// $updateFiles = array();
+// foreach ($updatesRoot->children() as $updateNode) {
+// if ($updateNode->file) {
+// $module = $updateNode->getAttribute('module');
+// if ($module && Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $module)) {
+// continue;
+// }
+// $updateFiles[] = (string)$updateNode->file;
+// }
+// }
+//
+// // custom local layout updates file - load always last
+// $updateFiles[] = 'local.xml';
+//
+// $layoutStr = '';
+// #$layoutXml = new $elementClass(' ');
+// foreach ($updateFiles as $file) {
+// $filename = $design->getLayoutFilename($file);
+// if (!is_readable($filename)) {
+// continue;
+// }
+// $fileStr = file_get_contents($filename);
+// $fileStr = str_replace($this->_subst['from'], $this->_subst['to'], $fileStr);
+// $fileXml = simplexml_load_string($fileStr, $elementClass);
+// if (!$fileXml instanceof SimpleXMLElement) {
+// continue;
+// }
+// $layoutStr .= $fileXml->innerXml();
+//
+// #$layoutXml->appendChild($fileXml);
+// }
+// $layoutXml = simplexml_load_string(''.$layoutStr.' ', $elementClass);
+//
+// $this->_packageLayout = $layoutXml;
+//
+// if (Mage::app()->useCache('layout')) {
+// Mage::app()->saveCache($this->_packageLayout->asXml(), $cacheKey, $cacheTags, null);
+// }
+// }
+
return $this;
}
@@ -315,17 +341,14 @@ public function fetchPackageLayoutUpdates($handle)
{
$_profilerKey = 'layout/package_update: '.$handle;
Varien_Profiler::start($_profilerKey);
-
if (empty($this->_packageLayout)) {
$this->fetchFileLayoutUpdates();
}
foreach ($this->_packageLayout->$handle as $updateXml) {
#echo '';
$this->fetchRecursiveUpdates($updateXml);
-
$this->addUpdate($updateXml->innerXml());
}
-
Varien_Profiler::stop($_profilerKey);
return true;
@@ -335,22 +358,15 @@ public function fetchDbLayoutUpdates($handle)
{
$_profilerKey = 'layout/db_update: '.$handle;
Varien_Profiler::start($_profilerKey);
-
- try {
- $updateStr = Mage::getResourceModel('core/layout')->fetchUpdatesByHandle($handle);
- if (!$updateStr) {
- return false;
- }
- $updateStr = str_replace($this->_subst['from'], $this->_subst['to'], $updateStr);
- $updateXml = simplexml_load_string($updateStr, $this->getElementClass());
- $this->fetchRecursiveUpdates($updateXml);
-
- $this->addUpdate($update);
- } catch (PDOException $e) {
- throw $e;
- } catch (Exception $e) {
-
+ $updateStr = Mage::getResourceModel('core/layout')->fetchUpdatesByHandle($handle);
+ if (!$updateStr) {
+ return false;
}
+ $updateStr = '' . $updateStr . ' ';
+ $updateStr = str_replace($this->_subst['from'], $this->_subst['to'], $updateStr);
+ $updateXml = simplexml_load_string($updateStr, $this->getElementClass());
+ $this->fetchRecursiveUpdates($updateXml);
+ $this->addUpdate($updateXml->innerXml());
Varien_Profiler::stop($_profilerKey);
return true;
@@ -365,4 +381,55 @@ public function fetchRecursiveUpdates($updateXml)
}
return $this;
}
+
+ /**
+ * Collect and merge layout updates from file
+ *
+ * @param string $area
+ * @param string $package
+ * @param string $theme
+ * @param integer $storeId
+ * @return Mage_Core_Model_Layout_Element
+ */
+ public function getFileLayoutUpdatesXml($area, $package, $theme, $storeId)
+ {
+ /* @var $design Mage_Core_Model_Design_Package */
+ $design = Mage::getSingleton('core/design_package');
+ $layoutXml = null;
+ $elementClass = $this->getElementClass();
+ $updatesRoot = Mage::app()->getConfig()->getNode($area.'/layout/updates');
+ Mage::dispatchEvent('core_layout_update_updates_get_after', array('updates' => $updatesRoot));
+ $updateFiles = array();
+ foreach ($updatesRoot->children() as $updateNode) {
+ if ($updateNode->file) {
+ $module = $updateNode->getAttribute('module');
+ if ($module && Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $module, $storeId)) {
+ continue;
+ }
+ $updateFiles[] = (string)$updateNode->file;
+ }
+ }
+ // custom local layout updates file - load always last
+ $updateFiles[] = 'local.xml';
+ $layoutStr = '';
+ foreach ($updateFiles as $file) {
+ $filename = $design->getLayoutFilename($file, array(
+ '_area' => $area,
+ '_package' => $package,
+ '_theme' => $theme
+ ));
+ if (!is_readable($filename)) {
+ continue;
+ }
+ $fileStr = file_get_contents($filename);
+ $fileStr = str_replace($this->_subst['from'], $this->_subst['to'], $fileStr);
+ $fileXml = simplexml_load_string($fileStr, $elementClass);
+ if (!$fileXml instanceof SimpleXMLElement) {
+ continue;
+ }
+ $layoutStr .= $fileXml->innerXml();
+ }
+ $layoutXml = simplexml_load_string(''.$layoutStr.' ', $elementClass);
+ return $layoutXml;
+ }
}
diff --git a/app/code/core/Mage/Core/Model/Locale.php b/app/code/core/Mage/Core/Model/Locale.php
index 935b327475..9996482077 100644
--- a/app/code/core/Mage/Core/Model/Locale.php
+++ b/app/code/core/Mage/Core/Model/Locale.php
@@ -229,7 +229,7 @@ protected function _getOptionLocales($translatedName=false)
{
$options = array();
$locales = $this->getLocale()->getLocaleList();
- $languages = $this->getLocale()->getLanguageTranslationList($this->getLocale());
+ $languages = $this->getLocale()->getTranslationList('language', $this->getLocale());
$countries = $this->getCountryTranslationList();
$allowed = $this->getAllowLocales();
@@ -243,8 +243,8 @@ protected function _getOptionLocales($translatedName=false)
continue;
}
if ($translatedName) {
- $label = ucwords($this->getLocale()->getLanguageTranslation($data[0], $code))
- . ' (' . $this->getLocale()->getCountryTranslation($data[1], $code) . ') / '
+ $label = ucwords($this->getLocale()->getTranslation($data[0], 'language', $code))
+ . ' (' . $this->getLocale()->getTranslation($data[1], 'country', $code) . ') / '
. $languages[$data[0]] . ' (' . $countries[$data[1]] . ')';
} else {
$label = $languages[$data[0]] . ' (' . $countries[$data[1]] . ')';
@@ -511,6 +511,25 @@ public function storeDate($store=null, $date=null, $includeTime=false)
return $date;
}
+ /**
+ * Create Zend_Date object with date converted from store's timezone
+ * to UTC time zone. Date can be passed in format of store's locale
+ * or in format which was passed as parameter.
+ *
+ * @param mixed $store Information about store
+ * @param string|integer|Zend_Date|array|null $date date in store's timezone
+ * @param boolean $includeTime flag for including time to date
+ * @param null|string $format
+ * @return Zend_Date
+ */
+ public function utcDate($store=null, $date, $includeTime = false, $format = null)
+ {
+ $dateObj = $this->storeDate($store, $date, $includeTime);
+ $dateObj->set($date, $format);
+ $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
+ return $dateObj;
+ }
+
/**
* Get store timestamp
* Timstamp will be builded with store timezone settings
@@ -529,19 +548,19 @@ public function storeTimeStamp($store=null)
}
/**
- * Create Mage_Core_Model_Locale_Currency object for current locale
+ * Create Zend_Currency object for current locale
*
* @param string $currency
- * @return Mage_Core_Model_Locale_Currency
+ * @return Zend_Currency
*/
public function currency($currency)
{
Varien_Profiler::start('locale/currency');
if (!isset(self::$_currencyCache[$this->getLocaleCode()][$currency])) {
try {
- $currencyObject = new Mage_Core_Model_Locale_Currency($currency, $this->getLocale());
+ $currencyObject = new Zend_Currency($currency, $this->getLocale());
} catch (Exception $e) {
- $currencyObject = new Mage_Core_Model_Locale_Currency($this->getCurrency(), $this->getLocale());
+ $currencyObject = new Zend_Currency($this->getCurrency(), $this->getLocale());
$options = array(
'name' => $currency,
'currency' => $currency,
@@ -724,7 +743,7 @@ public function getTranslation($value = null, $path = null)
*/
public function getCountryTranslation($value)
{
- return $this->getLocale()->getCountryTranslation($value, $this->getLocale());
+ return $this->getLocale()->getTranslation($value, 'country', $this->getLocale());
}
/**
@@ -734,7 +753,7 @@ public function getCountryTranslation($value)
*/
public function getCountryTranslationList()
{
- return $this->getLocale()->getCountryTranslationList($this->getLocale());
+ return $this->getLocale()->getTranslationList('territory', $this->getLocale(), 2);
}
/**
diff --git a/app/code/core/Mage/Core/Model/Locale/Currency.php b/app/code/core/Mage/Core/Model/Locale/Currency.php
deleted file mode 100644
index 3126c1e0e3..0000000000
--- a/app/code/core/Mage/Core/Model/Locale/Currency.php
+++ /dev/null
@@ -1,197 +0,0 @@
-
- */
-class Mage_Core_Model_Locale_Currency extends Zend_Currency
-{
- const XML_PATH_TRIM_CURRENCY_SIGN = 'currency/options/trim_sign';
- const US_LOCALE = 'en_US';
- protected $_locale;
-
- /**
- * Creates a currency instance. Every supressed parameter is used from the actual or the given locale.
- *
- * @param string $currency OPTIONAL currency short name
- * @param string|Zend_Locale $locale OPTIONAL locale name
- * @throws Zend_Currency_Exception When currency is invalid
- */
- public function __construct($currency = null, $locale = null)
- {
- parent::__construct($currency, $locale);
- $this->_options['symbol_choice'] = self::getSymbolChoice($currency, $this->_locale);
- }
-
- /**
- * Returns the actual or details of available currency symbol choice,
- *
- * @param string $currency (Optional) Currency name
- * @param string|Zend_Locale $locale (Optional) Locale to display informations
- * @return string
- */
- public function getSymbolChoice($currency = null, $locale = null)
- {
- if (($currency === null) and ($locale === null)) {
- return $this->_options['symbol_choice'];
- }
-
- $params = self::_checkParams($currency, $locale);
-
- //Get the symbol choice
- $symbolChoice = Zend_Locale_Data::getContent($params['locale'], 'currencysymbolchoice', $params['currency']);
- if (empty($symbolChoice) === true) {
- $symbolChoice = Zend_Locale_Data::getContent($params['locale'], 'currencysymbolchoice', $params['name']);
- }
- if (empty($symbolChoice) === true) {
- return null;
- }
- return $symbolChoice;
- }
-
- public function setLocale($locale = null)
- {
- $this->_locale = $locale;
- parent::setLocale($locale);
- return $this;
- }
-
- /**
- * Place the sign next to the number
- *
- * @param string $value
- * @param string $sign
- * @param array $options
- * @return string
- */
- protected function _concatSign($value, $sign, $options)
- {
- $trimSign = $this->getStore()->getConfig(self::XML_PATH_TRIM_CURRENCY_SIGN);
- if (is_null($trimSign) && $this->_locale && $this->_locale == self::US_LOCALE) {
- $trimSign = true;
- }
- if ($trimSign) {
- $sign = trim($sign);
- }
-
- // Place the sign next to the number
- if ($options['position'] === self::RIGHT) {
- $result = $value . $sign;
- } else if ($options['position'] === self::LEFT) {
- // Do not place sign before minus. And do not allow space between minus and sign
- if (0 === strpos($value, '-', 0)) {
- $result = '-' . ltrim($sign) . substr($value, 1);
- } else {
- $result = $sign . $value;
- }
- }
- return $result;
- }
-
- /**
- * Get store instance
- *
- * @return Mage_Core_Model_Store
- */
- public function getStore()
- {
- return Mage::app()->getStore();
- }
-
-/**
- * Internal method for checking the options array
- *
- * @param array $options
- * @return array
- * @throws Zend_Currency_Exception
- */
- private function checkOptions(array $options = array())
- {
- if (count($options) == 0) {
- return $this->_options;
- }
- foreach($options as $name => $value) {
- $name = strtolower($name);
- if ($name !== 'format') {
- if (gettype($value) === 'string') {
- $value = strtolower($value);
- }
- }
- if (array_key_exists($name, $this->_options)) {
- switch($name) {
- case 'position' :
- if (($value !== self::STANDARD) and ($value !== self::RIGHT) and ($value !== self::LEFT)) {
- #require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Unknown position '" . $value . "'");
- }
- if ($value === self::STANDARD) {
- $options['position'] = $this->_updateFormat();
- }
- break;
- case 'format' :
- if (!empty($value) && (!Zend_Locale::isLocale($value))) {
- #require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("'" .
- (gettype($value) === 'object' ? get_class($value) : $value)
- . "' is not a known locale.");
- }
- break;
- case 'display' :
- if (is_numeric($value) and ($value !== self::NO_SYMBOL) and ($value !== self::USE_SYMBOL) and
- ($value !== self::USE_SHORTNAME) and ($value !== self::USE_NAME)) {
- #require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Unknown display '$value'");
- }
- break;
- case 'precision' :
- if ($value === NULL) {
- $value = -1;
- }
- if (($value < -1) || ($value > 30)) {
- #require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("'$value' precision has to be between -1 and 30.");
- }
- break;
- case 'script' :
- try {
- Zend_Locale_Format::convertNumerals(0,$options['script']);
- } catch (Zend_Locale_Exception $e) {
- #require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception($e->getMessage());
- }
- break;
- }
- }
- else {
- #require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Unknown option: '$name' = '$value'");
- }
- }
- return $options;
- }
-}
diff --git a/app/code/core/Mage/Core/Model/Mysql4/Abstract.php b/app/code/core/Mage/Core/Model/Mysql4/Abstract.php
index c2ed5e936c..aed549d3cd 100644
--- a/app/code/core/Mage/Core/Model/Mysql4/Abstract.php
+++ b/app/code/core/Mage/Core/Model/Mysql4/Abstract.php
@@ -229,6 +229,7 @@ public function getMainTable()
* Get table name for the entity
*
* @param string $entityName
+ * @return string
*/
public function getTable($entityName)
{
@@ -246,6 +247,18 @@ public function getTable($entityName)
return $this->_tables[$entityName];
}
+ /**
+ * Retrieve table name for the entity separated value
+ *
+ * @param string $entityName
+ * @param string $valueType
+ * @return string
+ */
+ public function getValueTable($entityName, $valueType)
+ {
+ return $this->getTable($entityName) . '_' . $valueType;
+ }
+
/**
* Get connection by name or type
*
@@ -270,7 +283,7 @@ protected function _getConnection($connectionName)
/**
* Retrieve connection for read data
*
- * @return Zend_Db_Adapter_Abstract
+ * @return Varien_Db_Adapter_Pdo_Mysql
*/
protected function _getReadAdapter()
{
@@ -280,7 +293,7 @@ protected function _getReadAdapter()
/**
* Retrieve connection for write data
*
- * @return Zend_Db_Adapter_Abstract
+ * @return Varien_Db_Adapter_Pdo_Mysql
*/
protected function _getWriteAdapter()
{
@@ -290,7 +303,7 @@ protected function _getWriteAdapter()
/**
* Temporary resolving collection compatibility
*
- * @return Zend_Db_Adapter_Abstract
+ * @return Varien_Db_Adapter_Pdo_Mysql
*/
public function getReadConnection()
{
@@ -364,7 +377,8 @@ public function save(Mage_Core_Model_Abstract $object)
if ($this->_isPkAutoIncrement) {
$this->_getWriteAdapter()->update($this->getMainTable(), $this->_prepareDataForSave($object), $condition);
} else {
- $select = $this->_getWriteAdapter()->select($this->getMainTable(), array($this->getIdFieldName()))
+ $select = $this->_getWriteAdapter()->select()
+ ->from($this->getMainTable(), array($this->getIdFieldName()))
->where($condition);
if ($this->_getWriteAdapter()->fetchOne($select) !== false) {
$this->_getWriteAdapter()->update($this->getMainTable(), $this->_prepareDataForSave($object), $condition);
@@ -482,9 +496,21 @@ public function getUniqueFields()
* @return array
*/
protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
+ {
+ return $this->_prepareDataForTable($object, $this->getMainTable());
+ }
+
+ /**
+ * Prepare data for passed table
+ *
+ * @param Varien_Object $object
+ * @param string $table
+ * @return array
+ */
+ protected function _prepareDataForTable(Varien_Object $object, $table)
{
$data = array();
- $fields = $this->_getWriteAdapter()->describeTable($this->getMainTable());
+ $fields = $this->_getWriteAdapter()->describeTable($table);
foreach (array_keys($fields) as $field) {
if ($object->hasData($field)) {
$fieldValue = $object->getData($field);
@@ -567,10 +593,10 @@ protected function _checkUnique(Mage_Core_Model_Abstract $object)
if (!empty($existent)) {
if (count($existent) == 1 ) {
- $error = Mage::helper('core')->__('%s already exist', $existent[0]);
+ $error = Mage::helper('core')->__('%s already exists', $existent[0]);
}
else {
- $error = Mage::helper('core')->__('%s already exists', implode(', ', $existent));
+ $error = Mage::helper('core')->__('%s already exist', implode(', ', $existent));
}
Mage::throwException($error);
}
diff --git a/app/code/core/Mage/Core/Model/Mysql4/Email/Template.php b/app/code/core/Mage/Core/Model/Mysql4/Email/Template.php
index d7d1808d2b..dbdc2fd38f 100644
--- a/app/code/core/Mage/Core/Model/Mysql4/Email/Template.php
+++ b/app/code/core/Mage/Core/Model/Mysql4/Email/Template.php
@@ -189,7 +189,7 @@ protected function _prepareSave(Mage_Core_Model_Email_Template $template)
$validators = array(
'template_code' => array(Zend_Filter_Input::ALLOW_EMPTY => false),
- 'template_type' => 'Alnum',
+ #'template_type' => 'Alnum',
#'template_sender_email' => 'EmailAddress',
#'template_sender_name' => array(Zend_Filter_Input::ALLOW_EMPTY => false)
);
diff --git a/app/code/core/Mage/Core/Model/Mysql4/Layout.php b/app/code/core/Mage/Core/Model/Mysql4/Layout.php
index 9acb04c3d4..049ea8ec34 100644
--- a/app/code/core/Mage/Core/Model/Mysql4/Layout.php
+++ b/app/code/core/Mage/Core/Model/Mysql4/Layout.php
@@ -44,22 +44,22 @@ public function fetchUpdatesByHandle($handle, $params = array())
$package = isset($params['package']) ? $params['package'] : Mage::getSingleton('core/design_package')->getPackageName();
$theme = isset($params['theme']) ? $params['theme'] : Mage::getSingleton('core/design_package')->getTheme('layout');
- $read = $this->_getReadAdapter();
$updateStr = '';
-
- if ($read) {
- $select = $read->select()->from(array('update'=>$this->getMainTable()), 'xml')
+
+ $readAdapter = $this->_getReadAdapter();
+ if ($readAdapter) {
+ $select = $readAdapter->select()
+ ->from(array('update'=>$this->getMainTable()), array('xml'))
->join(array('link'=>$this->getTable('core/layout_link')), 'link.layout_update_id=update.layout_update_id', '')
->where('link.store_id=?', $storeId)
->where('link.package=?', $package)
- ->where('link.theme=?', $theme);
-
- if ($updates = $read->fetchAll($select)) {
- foreach ($updates as $update) {
- $updateStr .= $update['xml'];
- }
+ ->where('link.theme=?', $theme)
+ ->where('update.handle = ?', $handle);
+
+ foreach ($readAdapter->fetchAll($select) as $update) {
+ $updateStr .= $update['xml'];
}
}
return $updateStr;
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Core/Model/Mysql4/Session.php b/app/code/core/Mage/Core/Model/Mysql4/Session.php
index fa85569d98..af05d7a7a7 100644
--- a/app/code/core/Mage/Core/Model/Mysql4/Session.php
+++ b/app/code/core/Mage/Core/Model/Mysql4/Session.php
@@ -62,6 +62,14 @@ class Mage_Core_Model_Mysql4_Session implements Zend_Session_SaveHandler_Interfa
*/
protected $_write;
+ /**
+ * Automatic cleaning factor of expired sessions
+ *
+ * value zero means no automatic cleaning, one means automatic cleaning each time a session is closed, and x>1 means
+ * cleaning once in x calls
+ */
+ protected $_automaticCleaningFactor = 50;
+
public function __construct()
{
$this->_sessionTable = Mage::getSingleton('core/resource')->getTableName('core/session');
@@ -211,7 +219,12 @@ public function destroy($sessId)
*/
public function gc($sessMaxLifeTime)
{
- $this->_write->query("DELETE FROM `{$this->_sessionTable}` WHERE `session_expires` < ?", array(time()));
+ if ($this->_automaticCleaningFactor > 0) {
+ if ($this->_automaticCleaningFactor == 1 ||
+ rand(1, $this->_automaticCleaningFactor)==1) {
+ $this->_write->query("DELETE FROM `{$this->_sessionTable}` WHERE `session_expires` < ?", array(time()));
+ }
+ }
return true;
}
}
diff --git a/app/code/core/Mage/Core/Model/Mysql4/Store/Collection.php b/app/code/core/Mage/Core/Model/Mysql4/Store/Collection.php
index 5e936bf107..c6ad7e0b60 100644
--- a/app/code/core/Mage/Core/Model/Mysql4/Store/Collection.php
+++ b/app/code/core/Mage/Core/Model/Mysql4/Store/Collection.php
@@ -57,9 +57,21 @@ public function setWithoutDefaultFilter()
return $this;
}
+ /**
+ * Add filter by group id.
+ * Group id can be passed as one single value or array of values.
+ *
+ * @param int|array $groupId
+ * @return Mage_Core_Model_Mysql4_Store_Collection
+ */
public function addGroupFilter($groupId)
{
- $condition = $this->getConnection()->quoteInto("main_table.group_id=?", $groupId);
+ if (is_array($groupId)) {
+ $condition = $this->getConnection()->quoteInto("main_table.group_id IN (?)", $groupId);
+ } else {
+ $condition = $this->getConnection()->quoteInto("main_table.group_id = ?",$groupId);
+ }
+
$this->addFilter('group_id', $condition, 'string');
return $this;
}
diff --git a/app/code/core/Mage/Core/Model/Mysql4/Url/Rewrite.php b/app/code/core/Mage/Core/Model/Mysql4/Url/Rewrite.php
index 7db12ba479..b963717606 100644
--- a/app/code/core/Mage/Core/Model/Mysql4/Url/Rewrite.php
+++ b/app/code/core/Mage/Core/Model/Mysql4/Url/Rewrite.php
@@ -81,4 +81,29 @@ protected function _getLoadSelect($field, $value, $object)
return $select;
}
-}
\ No newline at end of file
+
+ /**
+ * Retrieve request_path using id_path and current store's id.
+ *
+ * @param string $idPath
+ * @param int|Mage_Core_Model_Store $store
+ * @return string|false
+ */
+ public function getRequestPathByIdPath($idPath, $store)
+ {
+ if ($store instanceof Mage_Core_Model_Store) {
+ $storeId = (int)$store->getId();
+ } else {
+ $storeId = (int)$store;
+ }
+
+ $select = $this->_getReadAdapter()->select();
+ /* @var $select Zend_Db_Select */
+ $select->from(array('main_table' => $this->getMainTable()), 'request_path')
+ ->where('main_table.store_id = ?', $storeId)
+ ->where('main_table.id_path = ?', $idPath)
+ ->limit(1);
+
+ return $this->_getReadAdapter()->fetchOne($select);
+ }
+}
diff --git a/app/code/core/Mage/Core/Model/Mysql4/Website/Collection.php b/app/code/core/Mage/Core/Model/Mysql4/Website/Collection.php
index 04983b9f61..3923ccabe9 100644
--- a/app/code/core/Mage/Core/Model/Mysql4/Website/Collection.php
+++ b/app/code/core/Mage/Core/Model/Mysql4/Website/Collection.php
@@ -91,23 +91,50 @@ public function load($printQuery = false, $logQuery = false)
return $this;
}
+ /**
+ * Join group and store info from appropriate tables.
+ * Defines new _idFiledName as 'website_group_store' bc for
+ * one website can be more then one row in collection.
+ * Sets extra combined ordering by group's name, defined
+ * sort ordering and store's name.
+ *
+ * @return Mage_Core_Model_Mysql4_Website_Collection
+ */
public function joinGroupAndStore()
{
- $this->_idFieldName = 'website_group_store';
- $this->getSelect()->joinLeft(
- array('group_table' => $this->getTable('core/store_group')),
- 'main_table.website_id=group_table.website_id',
- array('group_id'=>'group_id', 'group_title'=>'name')
- )->joinLeft(
- array('store_table' => $this->getTable('core/store')),
- 'group_table.group_id=store_table.group_id',
- array('store_id'=>'store_id', 'store_title'=>'name')
- );
- $this->addOrder('group_table.name', 'ASC') // store name
- ->addOrder('CASE WHEN store_table.store_id = 0 THEN 0 ELSE 1 END', 'ASC') // view is admin
- ->addOrder('store_table.sort_order', 'ASC') // view sort order
- ->addOrder('store_table.name', 'ASC') // view name
- ;
+ if (!$this->getFlag('groups_and_stores_joined')) {
+ $this->_idFieldName = 'website_group_store';
+ $this->getSelect()->joinLeft(
+ array('group_table' => $this->getTable('core/store_group')),
+ 'main_table.website_id=group_table.website_id',
+ array('group_id'=>'group_id', 'group_title'=>'name')
+ )->joinLeft(
+ array('store_table' => $this->getTable('core/store')),
+ 'group_table.group_id=store_table.group_id',
+ array('store_id'=>'store_id', 'store_title'=>'name')
+ );
+ $this->addOrder('group_table.name', 'ASC') // store name
+ ->addOrder('CASE WHEN store_table.store_id = 0 THEN 0 ELSE 1 END', 'ASC') // view is admin
+ ->addOrder('store_table.sort_order', 'ASC') // view sort order
+ ->addOrder('store_table.name', 'ASC') // view name
+ ;
+ $this->setFlag('groups_and_stores_joined', true);
+ }
+ return $this;
+ }
+
+ /**
+ * Adding filter by group id or array of ids but only if
+ * tables with appropriate information were joined before.
+ *
+ * @param int|array $groupIds
+ * @return Mage_Core_Model_Mysql4_Website_Collection
+ */
+ public function addFilterByGroupIds($groupIds)
+ {
+ if ($this->getFlag('groups_and_stores_joined')) {
+ $this->addFieldToFilter('group_table.group_id', $groupIds);
+ }
return $this;
}
}
diff --git a/app/code/core/Mage/Core/Model/Resource.php b/app/code/core/Mage/Core/Model/Resource.php
index 907491ffbd..d93a9ee277 100644
--- a/app/code/core/Mage/Core/Model/Resource.php
+++ b/app/code/core/Mage/Core/Model/Resource.php
@@ -37,6 +37,9 @@ class Mage_Core_Model_Resource
const AUTO_UPDATE_NEVER = -1;
const AUTO_UPDATE_ALWAYS = 1;
+ const DEFAULT_READ_RESOURCE = 'core_read';
+ const DEFAULT_WRITE_RESOURCE= 'core_write';
+
/**
* Instances of classes for connection types
*
@@ -68,12 +71,16 @@ class Mage_Core_Model_Resource
*/
public function getConnection($name)
{
+// echo $name . ' ';
if (isset($this->_connections[$name])) {
return $this->_connections[$name];
}
$connConfig = Mage::getConfig()->getResourceConnectionConfig($name);
-
- if (!$connConfig || !$connConfig->is('active', 1)) {
+ if (!$connConfig) {
+ $this->_connections[$name] = $this->_getDefaultConnection($name);
+ return $this->_connections[$name];
+ }
+ if (!$connConfig->is('active', 1)) {
return false;
}
$origName = $connConfig->getParent()->getName();
@@ -93,6 +100,14 @@ public function getConnection($name)
return $conn;
}
+ protected function _getDefaultConnection($requiredConnectionName)
+ {
+ if (strpos($requiredConnectionName, 'read') !== false) {
+ return $this->getConnection(self::DEFAULT_READ_RESOURCE);
+ }
+ return $this->getConnection(self::DEFAULT_WRITE_RESOURCE);
+ }
+
/**
* Get connection type instance
*
diff --git a/app/code/core/Mage/Core/Model/Resource/Setup.php b/app/code/core/Mage/Core/Model/Resource/Setup.php
index 5498e9c9fe..b3b2e3902f 100644
--- a/app/code/core/Mage/Core/Model/Resource/Setup.php
+++ b/app/code/core/Mage/Core/Model/Resource/Setup.php
@@ -31,6 +31,7 @@
*/
class Mage_Core_Model_Resource_Setup
{
+ const DEFAULT_SETUP_CONNECTION = 'core_setup';
const VERSION_COMPARE_EQUAL = 0;
const VERSION_COMPARE_LOWER = -1;
const VERSION_COMPARE_GREATER = 1;
@@ -56,7 +57,13 @@ public function __construct($resourceName)
$config = Mage::getConfig();
$this->_resourceName = $resourceName;
$this->_resourceConfig = $config->getResourceConfig($resourceName);
- $this->_connectionConfig = $config->getResourceConnectionConfig($resourceName);
+ $connection = $config->getResourceConnectionConfig($resourceName);
+ if ($connection) {
+ $this->_connectionConfig = $connection;
+ } else {
+ $this->_connectionConfig = $config->getResourceConnectionConfig(self::DEFAULT_SETUP_CONNECTION);
+ }
+
$modName = (string)$this->_resourceConfig->setup->module;
$this->_moduleConfig = $config->getModuleConfig($modName);
$this->_conn = Mage::getSingleton('core/resource')->getConnection($this->_resourceName);
diff --git a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
index cad2ee993e..36961c55e2 100644
--- a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
+++ b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
@@ -45,12 +45,6 @@ public function start($sessionName=null)
return $this;
}
- Varien_Profiler::start(__METHOD__.'/setOptions');
- if (is_writable(Mage::getBaseDir('session'))) {
- session_save_path($this->getSessionSavePath());
- }
- Varien_Profiler::stop(__METHOD__.'/setOptions');
-
switch($this->getSessionSaveMethod()) {
case 'db':
ini_set('session.save_handler', 'user');
@@ -62,27 +56,49 @@ public function start($sessionName=null)
ini_set('session.save_handler', 'memcache');
session_save_path($this->getSessionSavePath());
break;
+ case 'eaccelerator':
+ ini_set('session.save_handler', 'eaccelerator');
+ break;
default:
session_module_name('files');
+ if (is_writable(Mage::getBaseDir('session'))) {
+ session_save_path($this->getSessionSavePath());
+ }
break;
}
if (Mage::app()->getStore()->isAdmin()) {
$adminSessionLifetime = (int)Mage::getStoreConfig('admin/security/session_cookie_lifetime');
if ($adminSessionLifetime > 60) {
- Mage::getSingleton('core/cookie')->setLifetime($adminSessionLifetime);
+ $this->getCookie()->setLifetime($adminSessionLifetime);
}
}
- // set session cookie params
- session_set_cookie_params(
- $this->getCookie()->getLifetime(),
- $this->getCookie()->getPath(),
- $this->getCookie()->getDomain(),
- $this->getCookie()->isSecure(),
- $this->getCookie()->getHttponly()
+ // session cookie params
+ $cookieParams = array(
+ 'lifetime' => $this->getCookie()->getLifetime(),
+ 'path' => $this->getCookie()->getPath(),
+ 'domain' => $this->getCookie()->getConfigDomain(),
+ 'secure' => $this->getCookie()->isSecure(),
+ 'httponly' => $this->getCookie()->getHttponly()
);
+ if (!$cookieParams['httponly']) {
+ unset($cookieParams['httponly']);
+ if (!$cookieParams['secure']) {
+ unset($cookieParams['secure']);
+ if (!$cookieParams['domain']) {
+ unset($cookieParams['domain']);
+ }
+ }
+ }
+
+ if (isset($cookieParams['domain'])) {
+ $cookieParams['domain'] = $this->getCookie()->getDomain();
+ }
+
+ call_user_func_array('session_set_cookie_params', $cookieParams);
+
if (!empty($sessionName)) {
$this->setSessionName($sessionName);
}
diff --git a/app/code/core/Mage/Core/Model/Store.php b/app/code/core/Mage/Core/Model/Store.php
index 709bab5655..529969f4f4 100644
--- a/app/code/core/Mage/Core/Model/Store.php
+++ b/app/code/core/Mage/Core/Model/Store.php
@@ -28,12 +28,14 @@
/**
* Store model
*
- * @author Magento Core Team
+ * @author Magento Core Team
* @category Mage
* @package Mage_Core
*/
class Mage_Core_Model_Store extends Mage_Core_Model_Abstract
{
+ const ENTITY = 'core_store';
+
const XML_PATH_STORE_IN_URL = 'web/url/use_store';
const XML_PATH_USE_REWRITES = 'web/seo/use_rewrites';
const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
@@ -875,9 +877,18 @@ public function getName()
return $this->_getData('name');
}
+ /**
+ * Protect delete from non admin area
+ * Register indexing event before delete store
+ *
+ * @return Mage_Core_Model_Store
+ */
protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
+ Mage::getSingleton('index/indexer')->logEvent(
+ $this, self::ENTITY, Mage_Index_Model_Event::TYPE_DELETE
+ );
return parent::_beforeDelete();
}
@@ -893,6 +904,19 @@ protected function _afterDelte()
return $this;
}
+ /**
+ * Init indexing process after store delete commit
+ *
+ * @return Mage_Core_Model_Store
+ */
+ protected function _afterDeleteCommit()
+ {
+ parent::_afterDeleteCommit();
+ Mage::getSingleton('index/indexer')->indexEvents(
+ self::ENTITY, Mage_Index_Model_Event::TYPE_DELETE
+ );
+ }
+
/**
* Reinit and reset Config Data
*
diff --git a/app/code/core/Mage/Core/Model/Store/Group.php b/app/code/core/Mage/Core/Model/Store/Group.php
index 213b9f12eb..fb91ce24f0 100644
--- a/app/code/core/Mage/Core/Model/Store/Group.php
+++ b/app/code/core/Mage/Core/Model/Store/Group.php
@@ -34,6 +34,7 @@
class Mage_Core_Model_Store_Group extends Mage_Core_Model_Abstract
{
+ const ENTITY = 'store_group';
const CACHE_TAG = 'store_group';
protected $_cacheTag = true;
diff --git a/app/code/core/Mage/Core/Model/Translate/Inline.php b/app/code/core/Mage/Core/Model/Translate/Inline.php
index 52cd96b891..7bec912c31 100644
--- a/app/code/core/Mage/Core/Model/Translate/Inline.php
+++ b/app/code/core/Mage/Core/Model/Translate/Inline.php
@@ -168,7 +168,6 @@ public function processResponseBody(&$body)
$this->processResponseBody($part);
}
} else if (is_string($body)) {
- Mage::log($body);
$this->_content = $body;
$this->_tagAttributes();
diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite.php b/app/code/core/Mage/Core/Model/Url/Rewrite.php
index ea48def69e..b3af300f32 100644
--- a/app/code/core/Mage/Core/Model/Url/Rewrite.php
+++ b/app/code/core/Mage/Core/Model/Url/Rewrite.php
@@ -40,11 +40,34 @@ class Mage_Core_Model_Url_Rewrite extends Mage_Core_Model_Abstract
const TYPE_CUSTOM = 3;
const REWRITE_REQUEST_PATH_ALIAS = 'rewrite_request_path';
+ /**
+ * Cache tag for clear cache in after save and after delete
+ *
+ * @var mixed | array | string | boolean
+ */
+ protected $_cacheTag = false;
+
protected function _construct()
{
$this->_init('core/url_rewrite');
}
+ /**
+ * Clean cache for front-end menu
+ *
+ * @return Mage_Core_Model_Url_Rewrite
+ */
+ protected function _afterSave()
+ {
+ if ($this->hasCategoryId()) {
+ $this->_cacheTag = array(Mage_Catalog_Model_Category::CACHE_TAG, Mage_Core_Model_Store_Group::CACHE_TAG);
+ }
+
+ parent::_afterSave();
+
+ return $this;
+ }
+
/**
* Load rewrite information for request
*
diff --git a/app/code/core/Mage/Core/Model/Website.php b/app/code/core/Mage/Core/Model/Website.php
index 56772cb00a..d64570bce4 100644
--- a/app/code/core/Mage/Core/Model/Website.php
+++ b/app/code/core/Mage/Core/Model/Website.php
@@ -34,6 +34,7 @@
class Mage_Core_Model_Website extends Mage_Core_Model_Abstract
{
+ const ENTITY = 'core_website';
const CACHE_TAG = 'website';
protected $_cacheTag = true;
diff --git a/app/code/core/Mage/Core/etc/system.xml b/app/code/core/Mage/Core/etc/system.xml
index 0843279ab2..81c43ac546 100644
--- a/app/code/core/Mage/Core/etc/system.xml
+++ b/app/code/core/Mage/Core/etc/system.xml
@@ -586,15 +586,6 @@
1
1
-
- Make Zip Code optional for Specific countries
- multiselect
- 3
- adminhtml/system_config_source_country
- 1
- 1
- 0
-
@@ -656,7 +647,7 @@
1
- SMTP settings (Windows server only)
+ Mail Sending Settings
text
20
1
@@ -679,6 +670,7 @@
1
1
1
+ For Windows Server Only
Port (25)
@@ -687,6 +679,7 @@
1
1
1
+ For Windows Server Only
+
+ Set Return-Path
+ select
+ adminhtml/system_config_source_yesno
+ 70
+ 1
+ 0
+ 0
+
@@ -825,7 +827,7 @@
Session Lifetime (seconds)
- Values less than 60 are ignored.
+ Values less than 60 are ignored. Please note, that changes will apply after logout.
3
1
0
@@ -1058,19 +1060,11 @@
Cookie Lifetime
text
- 30
- 1
- 1
- 1
-
-
- Cookie Domain
- text
10
1
1
1
-
+
Cookie Path
text
@@ -1079,6 +1073,14 @@
1
1
+
+ Cookie Domain
+ text
+ 30
+ 1
+ 1
+ 1
+
Use HTTP Only
select
diff --git a/app/code/core/Mage/Core/functions.php b/app/code/core/Mage/Core/functions.php
index 9541627c7a..1c50b92430 100644
--- a/app/code/core/Mage/Core/functions.php
+++ b/app/code/core/Mage/Core/functions.php
@@ -180,13 +180,13 @@ function mageCoreErrorHandler($errno, $errstr, $errfile, $errline){
// PEAR specific message handling
if (stripos($errfile.$errstr, 'pear') !== false) {
- // ignore strict notices
- if ($errno == E_STRICT) {
- return false;
+ // ignore strict and deprecated notices
+ if (($errno == E_STRICT) || ($errno == E_DEPRECATED)) {
+ return true;
}
// ignore attempts to read system files when open_basedir is set
if ($errno == E_WARNING && stripos($errstr, 'open_basedir') !== false) {
- return false;
+ return true;
}
}
@@ -371,4 +371,4 @@ function sys_get_temp_dir()
}
}
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Cron/etc/config.xml b/app/code/core/Mage/Cron/etc/config.xml
index fa5fc6caff..8fa3ad147e 100644
--- a/app/code/core/Mage/Cron/etc/config.xml
+++ b/app/code/core/Mage/Cron/etc/config.xml
@@ -37,20 +37,7 @@
Mage_Cron
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -73,7 +60,6 @@
- singleton
cron/observer
dispatch
diff --git a/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php b/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php
index e5280238fa..3ad8246f15 100644
--- a/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php
+++ b/app/code/core/Mage/Customer/Model/Convert/Adapter/Customer.php
@@ -199,7 +199,7 @@ public function getRegionId($country, $regionName)
*
* @return array
*/
- public function getCustomerGoups()
+ public function getCustomerGroups()
{
if (is_null($this->_customerGroups)) {
$this->_customerGroups = array();
@@ -213,7 +213,15 @@ public function getCustomerGoups()
return $this->_customerGroups;
}
-
+ /**
+ * Alias at getCustomerGroups()
+ *
+ * @return array
+ */
+ public function getCustomerGoups()
+ {
+ return $this->getCustomerGroups();
+ }
public function __construct()
{
@@ -433,7 +441,7 @@ public function saveRow($importData)
$customer->setWebsiteId($website->getId())
->loadByEmail($importData['email']);
if (!$customer->getId()) {
- $customerGroups = $this->getCustomerGoups();
+ $customerGroups = $this->getCustomerGroups();
/**
* Check customer group
*/
@@ -465,7 +473,7 @@ public function saveRow($importData)
}
}
elseif (!empty($importData['group_id'])) {
- $customerGroups = $this->getCustomerGoups();
+ $customerGroups = $this->getCustomerGroups();
/**
* Check customer group
*/
diff --git a/app/code/core/Mage/Customer/Model/Convert/Parser/Customer.php b/app/code/core/Mage/Customer/Model/Convert/Parser/Customer.php
index b3fa4f5d11..3e04c3539e 100644
--- a/app/code/core/Mage/Customer/Model/Convert/Parser/Customer.php
+++ b/app/code/core/Mage/Customer/Model/Convert/Parser/Customer.php
@@ -316,11 +316,19 @@ public function unparse()
$row['created_in'] = $store->getCode();
$newsletter = $this->getNewsletterModel()
+ ->setData(array())
->loadByCustomer($customer);
$row['is_subscribed'] = ($newsletter->getId()
&& $newsletter->getSubscriberStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
? 1 : 0;
+ if($customer->getGroupId()){
+ $group = Mage::getResourceModel('customer/group_collection')
+ ->addFilter('customer_group_id',$customer->getGroupId())
+ ->load();
+ $row['group'] = $group->getFirstItem()->getCustomerGroupCode();
+ }
+
$batchExport = $this->getBatchExportModel()
->setId(null)
->setBatchId($this->getBatchModel()->getId())
@@ -345,14 +353,10 @@ public function getExternalAttributes()
'country_id'
);
- $entityTypeId = Mage::getSingleton('eav/config')->getEntityType('customer')->getId();
- $customerAttributes = Mage::getResourceModel('eav/entity_attribute_collection')
- ->setEntityTypeFilter($entityTypeId)
+ $customerAttributes = Mage::getResourceModel('customer/attribute_collection')
->load()->getIterator();
- $entityTypeId = Mage::getSingleton('eav/config')->getEntityType('customer_address')->getId();
- $addressAttributes = Mage::getResourceModel('eav/entity_attribute_collection')
- ->setEntityTypeFilter($entityTypeId)
+ $addressAttributes = Mage::getResourceModel('customer/address_attribute_collection')
->load()->getIterator();
$attributes = array(
diff --git a/app/code/core/Mage/Customer/Model/Customer.php b/app/code/core/Mage/Customer/Model/Customer.php
index f02b3f45e5..c84d77db80 100644
--- a/app/code/core/Mage/Customer/Model/Customer.php
+++ b/app/code/core/Mage/Customer/Model/Customer.php
@@ -450,7 +450,7 @@ public function isAddressPrimary(Mage_Customer_Model_Address $address)
*
* @return Mage_Customer_Model_Customer
*/
- public function sendNewAccountEmail($type = 'registered', $backUrl = '', $store_id = '0')
+ public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
$types = array(
'registered' => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
@@ -465,7 +465,7 @@ public function sendNewAccountEmail($type = 'registered', $backUrl = '', $store_
/* @var $translate Mage_Core_Model_Translate */
$translate->setTranslateInline(false);
- $storeId = ($store_id == '0')?$this->getStoreId():$store_id;
+ $storeId = ($storeId == '0')?$this->getSendemailStoreId():$storeId;
if ($this->getWebsiteId() != '0' && $storeId == '0') {
$storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds();
reset($storeIds);
@@ -695,6 +695,10 @@ public function validate()
&& '' == trim($this->getTaxvat())) {
$errors[] = Mage::helper('customer')->__('TAX/VAT number is required.');
}
+ if (('req' === Mage::helper('customer/address')->getConfig('gender_show'))
+ && '' == trim($this->getGender())) {
+ $errors[] = Mage::helper('customer')->__('Gender is required.');
+ }
if (empty($errors)) {
return true;
diff --git a/app/code/core/Mage/Customer/Model/Entity/Customer/Collection.php b/app/code/core/Mage/Customer/Model/Entity/Customer/Collection.php
index 1335a9f962..9579e8a19e 100644
--- a/app/code/core/Mage/Customer/Model/Entity/Customer/Collection.php
+++ b/app/code/core/Mage/Customer/Model/Entity/Customer/Collection.php
@@ -91,21 +91,15 @@ public function getSelectCountSql()
}
/**
- * Retrive all ids for collection
+ * Reset left join
*
- * @return array
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
*/
- public function getAllIds($limit=null, $offset=null)
+ protected function _getAllIdsSelect($limit=null, $offset=null)
{
- $idsSelect = clone $this->getSelect();
- $idsSelect->reset(Zend_Db_Select::ORDER);
- $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
- $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
- $idsSelect->reset(Zend_Db_Select::COLUMNS);
- $idsSelect->from(null, 'e.'.$this->getEntity()->getIdFieldName());
- $idsSelect->limit($limit, $offset);
+ $idsSelect = parent::_getAllIdsSelect($limit, $offset);
$idsSelect->resetJoinLeft();
-
- return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams);
+ return $idsSelect;
}
-}
\ No newline at end of file
+
+}
diff --git a/app/code/core/Mage/Customer/Model/Entity/Setup.php b/app/code/core/Mage/Customer/Model/Entity/Setup.php
index cef4830b6a..3d796143e7 100644
--- a/app/code/core/Mage/Customer/Model/Entity/Setup.php
+++ b/app/code/core/Mage/Customer/Model/Entity/Setup.php
@@ -34,6 +34,26 @@
class Mage_Customer_Model_Entity_Setup extends Mage_Eav_Model_Entity_Setup
{
+ /**
+ * Prepare customer attribute values to save
+ *
+ * @param array $attr
+ * @return array
+ */
+ protected function _prepareValues($attr)
+ {
+ $data = parent::_prepareValues($attr);
+ $data = array_merge($data, array(
+ 'is_visible' => $this->_getValue($attr, 'visible', 1),
+ 'is_visible_on_front' => $this->_getValue($attr, 'visible_on_front', 0),
+ 'input_filter' => $this->_getValue($attr, 'input_filter', ''),
+ 'lines_to_divide_multiline' => $this->_getValue($attr, 'lines_to_divide', 0),
+ 'min_text_length' => $this->_getValue($attr, 'min_text_length', 0),
+ 'max_text_length' => $this->_getValue($attr, 'max_text_length', 0)
+ ));
+ return $data;
+ }
+
public function getDefaultEntities()
{
return array(
@@ -42,6 +62,8 @@ public function getDefaultEntities()
'table' => 'customer/entity',
'increment_model' => 'eav/entity_increment_numeric',
'increment_per_store' => false,
+ 'additional_attribute_table' => 'customer/eav_attribute',
+ 'entity_attribute_collection' => 'customer/eav_attribute',
'attributes' => array(
// 'entity_id' => array('type'=>'static'),
// 'entity_type_id' => array('type'=>'static'),
@@ -105,7 +127,7 @@ public function getDefaultEntities()
'group_id' => array(
'type' => 'static',
'input' => 'select',
- 'label' => 'Customer Group',
+ 'label' => 'Group',
'source' => 'customer/customer_attribute_source_group',
'sort_order' => 70,
),
@@ -138,7 +160,6 @@ public function getDefaultEntities()
'label' => 'Tax/VAT number',
'visible' => true,
'required' => false,
- 'position' => 1,
),
'confirmation' => array(
'label' => 'Is confirmed',
@@ -151,6 +172,8 @@ public function getDefaultEntities()
'customer_address'=>array(
'entity_model' =>'customer/customer_address',
'table' => 'customer/address_entity',
+ 'additional_attribute_table' => 'customer/eav_attribute',
+ 'entity_attribute_collection' => 'customer/eav_attribute',
'attributes' => array(
// 'entity_id' => array('type'=>'static'),
// 'entity_type_id' => array('type'=>'static'),
@@ -220,6 +243,7 @@ public function getDefaultEntities()
'source' => 'customer_entity/address_attribute_source_region',
'required' => 'false',
'sort_order' => 80,
+ 'label' => 'State/Province'
),
'postcode' => array(
'label' => 'Zip/Postal Code',
diff --git a/app/code/core/Mage/Customer/Model/Group.php b/app/code/core/Mage/Customer/Model/Group.php
index fb67b289c4..a8ecb7dd08 100644
--- a/app/code/core/Mage/Customer/Model/Group.php
+++ b/app/code/core/Mage/Customer/Model/Group.php
@@ -1,102 +1,119 @@
-
- */
-class Mage_Customer_Model_Group extends Mage_Core_Model_Abstract
-{
- const XML_PATH_DEFAULT_ID = 'customer/create_account/default_group';
- const NOT_LOGGED_IN_ID = 0;
- const CUST_GROUP_ALL = 32000;
-
- /**
- * Prefix of model events names
- *
- * @var string
- */
- protected $_eventPrefix = 'customer_group';
-
- /**
- * Parameter name in event
- *
- * In observe method you can use $observer->getEvent()->getObject() in this case
- *
- * @var string
- */
- protected $_eventObject = 'object';
-
- protected static $_taxClassIds = array();
-
- protected function _construct()
- {
- $this->_init('customer/group');
- }
-
- /**
- * Alias for setCustomerGroupCode
- *
- * @param string $value
- */
- public function setCode($value)
- {
- return $this->setCustomerGroupCode($value);
- }
-
- /**
- * Alias for getCustomerGroupCode
- *
- * @return string
- */
- public function getCode()
- {
- return $this->getCustomerGroupCode();
- }
-
- public function getTaxClassId($groupId=null)
- {
- if (!is_null($groupId)) {
- if (empty(self::$_taxClassIds[$groupId])) {
- $this->load($groupId);
- self::$_taxClassIds[$groupId] = $this->getData('tax_class_id');
- }
- $this->setData('tax_class_id', self::$_taxClassIds[$groupId]);
- }
- return $this->getData('tax_class_id');
- }
-
-
- public function usesAsDefault()
- {
- $data = Mage::getConfig()->getStoresConfigByPath(self::XML_PATH_DEFAULT_ID);
- if (in_array($this->getId(), $data)) {
- return true;
- }
- return false;
- }
-}
\ No newline at end of file
+
+ */
+class Mage_Customer_Model_Group extends Mage_Core_Model_Abstract
+{
+ const XML_PATH_DEFAULT_ID = 'customer/create_account/default_group';
+
+ const NOT_LOGGED_IN_ID = 0;
+ const CUST_GROUP_ALL = 32000;
+
+ const ENTITY = 'customer_group';
+
+ /**
+ * Prefix of model events names
+ *
+ * @var string
+ */
+ protected $_eventPrefix = 'customer_group';
+
+ /**
+ * Parameter name in event
+ *
+ * In observe method you can use $observer->getEvent()->getObject() in this case
+ *
+ * @var string
+ */
+ protected $_eventObject = 'object';
+
+ protected static $_taxClassIds = array();
+
+ protected function _construct()
+ {
+ $this->_init('customer/group');
+ }
+
+ /**
+ * Alias for setCustomerGroupCode
+ *
+ * @param string $value
+ */
+ public function setCode($value)
+ {
+ return $this->setCustomerGroupCode($value);
+ }
+
+ /**
+ * Alias for getCustomerGroupCode
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->getCustomerGroupCode();
+ }
+
+ public function getTaxClassId($groupId=null)
+ {
+ if (!is_null($groupId)) {
+ if (empty(self::$_taxClassIds[$groupId])) {
+ $this->load($groupId);
+ self::$_taxClassIds[$groupId] = $this->getData('tax_class_id');
+ }
+ $this->setData('tax_class_id', self::$_taxClassIds[$groupId]);
+ }
+ return $this->getData('tax_class_id');
+ }
+
+
+ public function usesAsDefault()
+ {
+ $data = Mage::getConfig()->getStoresConfigByPath(self::XML_PATH_DEFAULT_ID);
+ if (in_array($this->getId(), $data)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Processing data save after transaction commit
+ *
+ * @return Mage_Customer_Model_Group
+ */
+ protected function _afterSaveCommit()
+ {
+ parent::_afterSaveCommit();
+ Mage::getSingleton('index/indexer')->processEntityAction(
+ $this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE
+ );
+ return $this;
+ }
+}
diff --git a/app/code/core/Mage/Customer/controllers/AccountController.php b/app/code/core/Mage/Customer/controllers/AccountController.php
index dc98ca5f8a..f942838099 100644
--- a/app/code/core/Mage/Customer/controllers/AccountController.php
+++ b/app/code/core/Mage/Customer/controllers/AccountController.php
@@ -188,6 +188,8 @@ protected function _loginPostRedirect()
} else {
$session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl());
}
+ } else if ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
+ $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
}
$this->_redirectUrl($session->getBeforeAuthUrl(true));
@@ -246,6 +248,9 @@ public function createPostAction()
foreach (Mage::getConfig()->getFieldset('customer_account') as $code=>$node) {
if ($node->is('create') && ($value = $this->getRequest()->getParam($code)) !== null) {
+ if ($code == 'email') {
+ $value = trim($value);
+ }
$customer->setData($code, $value);
}
}
@@ -318,7 +323,10 @@ public function createPostAction()
->addException($e, $this->__('Can\'t save customer'));
}
}
-
+ /**
+ * Protect XSS injection in user input
+ */
+ $this->_getSession()->setEscapeMessages(true);
$this->_redirectError(Mage::getUrl('*/*/create', array('_secure'=>true)));
}
diff --git a/app/code/core/Mage/Customer/etc/config.xml b/app/code/core/Mage/Customer/etc/config.xml
index f05f5af695..36cd15f621 100644
--- a/app/code/core/Mage/Customer/etc/config.xml
+++ b/app/code/core/Mage/Customer/etc/config.xml
@@ -28,7 +28,7 @@
- 0.8.11
+ 1.4.0.0.2
@@ -91,6 +91,7 @@
1
1 1
1 1
+ 1 1
@@ -180,6 +181,9 @@ T: {{var telephone}}
+
+
+
@@ -189,20 +193,7 @@ T: {{var telephone}}
Mage_Customer
Mage_Customer_Model_Entity_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -240,68 +231,6 @@ T: {{var telephone}}
-
-
- Customers
- 40
-
-
-
- Manage Customers
- adminhtml/customer/
- admin/customer list
-
-
- Customer Groups
- adminhtml/customer_group/
- admin/customer/group
-
-
- Online Customers
- adminhtml/customer_online/
- admin/customer/online
-
-
-
-
-
-
-
-
-
- Customers
- 40
-
-
- Customer Groups
- 0
-
-
- Manage Customers
- 10
-
-
- Online Customers
- 20
-
-
-
-
-
-
-
-
- Customers Section
- 50
-
-
-
-
-
-
-
-
-
@@ -311,7 +240,6 @@ T: {{var telephone}}
- singleton
customer/observer
beforeLoadLayout
@@ -377,6 +305,7 @@ T: {{var telephone}}
+
1
diff --git a/app/code/core/Mage/Customer/etc/system.xml b/app/code/core/Mage/Customer/etc/system.xml
index 9b2edd1a50..bd278e909d 100644
--- a/app/code/core/Mage/Customer/etc/system.xml
+++ b/app/code/core/Mage/Customer/etc/system.xml
@@ -260,6 +260,15 @@
1
0
+
+ Show gender
+ select
+ adminhtml/system_config_source_nooptreq
+ 90
+ 1
+ 1
+ 0
+
diff --git a/app/code/core/Mage/Dataflow/Model/Mysql4/Profile/Collection.php b/app/code/core/Mage/Dataflow/Model/Mysql4/Profile/Collection.php
index a37dc0a622..8f2da7a123 100644
--- a/app/code/core/Mage/Dataflow/Model/Mysql4/Profile/Collection.php
+++ b/app/code/core/Mage/Dataflow/Model/Mysql4/Profile/Collection.php
@@ -46,7 +46,7 @@ protected function _construct()
*/
public function addStoreFilter($storeIds)
{
- $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
+ $this->getSelect()->where('main_table.store_id IN (?)', array(0, $storeIds));
return $this;
}
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Dataflow/etc/config.xml b/app/code/core/Mage/Dataflow/etc/config.xml
index 7681748ac0..2e877f8ef4 100644
--- a/app/code/core/Mage/Dataflow/etc/config.xml
+++ b/app/code/core/Mage/Dataflow/etc/config.xml
@@ -69,20 +69,7 @@
Mage_Dataflow
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
\ No newline at end of file
diff --git a/app/code/core/Mage/Directory/Helper/Data.php b/app/code/core/Mage/Directory/Helper/Data.php
index 8c5601f75c..20f5b48d41 100644
--- a/app/code/core/Mage/Directory/Helper/Data.php
+++ b/app/code/core/Mage/Directory/Helper/Data.php
@@ -35,6 +35,7 @@ class Mage_Directory_Helper_Data extends Mage_Core_Helper_Abstract
protected $_regionCollection;
protected $_regionJson;
protected $_currencyCache = array();
+ protected $_optionalZipCountries = null;
public function getRegionCollection()
{
@@ -115,24 +116,30 @@ public function currencyConvert($amount, $from, $to=null)
/**
* Return ISO2 country codes, which have optional Zip/Postal pre-configured
*
- * @param mixed $storeId Store
+ * @param bool $asJson
* @return array
*/
- public function getCountriesWithOptionalZip($storeId = null)
+ public function getCountriesWithOptionalZip($asJson = false)
{
- $value = Mage::getStoreConfig('general/country/optional_zip_countries', $storeId);
- return preg_split('/\,/', $value, 0, PREG_SPLIT_NO_EMPTY);
+ if (null === $this->_optionalZipCountries) {
+ $this->_optionalZipCountries = preg_split('/\,/', Mage::getStoreConfig('general/country/optional_zip_countries'),
+ 0, PREG_SPLIT_NO_EMPTY
+ );
+ }
+ if ($asJson) {
+ return Mage::helper('core')->jsonEncode($this->_optionalZipCountries);
+ }
+ return $this->_optionalZipCountries;
}
/**
- * Same as getCountriesWithOptionalZip() but result is json-encoded
+ * Check whether zip code is optional for specified country code
*
- * @see getCountriesWithOptionalZip
- * @param mixed $storeId Store
- * @return string
+ * @param string $countryCode
*/
- public function getCountriesWithOptionalZipJson($storeId = null)
+ public function isZipCodeOptional($countryCode)
{
- return Mage::helper('core')->jsonEncode($this->getCountriesWithOptionalZip($storeId));
+ $this->getCountriesWithOptionalZip();
+ return in_array($countryCode, $this->_optionalZipCountries);
}
}
diff --git a/app/code/core/Mage/Directory/Model/Currency/Filter.php b/app/code/core/Mage/Directory/Model/Currency/Filter.php
index 645f5acd24..dd0dc901ec 100644
--- a/app/code/core/Mage/Directory/Model/Currency/Filter.php
+++ b/app/code/core/Mage/Directory/Model/Currency/Filter.php
@@ -41,7 +41,7 @@ class Mage_Directory_Model_Currency_Filter implements Zend_Filter_Interface
/**
* Currency object
*
- * @var Mage_Core_Model_Locale_Currency
+ * @var Zend_Currency
*/
protected $_currency;
diff --git a/app/code/core/Mage/Directory/etc/config.xml b/app/code/core/Mage/Directory/etc/config.xml
index 0aa56f69a8..339b4416d8 100644
--- a/app/code/core/Mage/Directory/etc/config.xml
+++ b/app/code/core/Mage/Directory/etc/config.xml
@@ -76,14 +76,7 @@
Mage_Directory
- core_setup
-
- core_write
-
-
- core_read
-
diff --git a/app/code/core/Mage/Directory/etc/system.xml b/app/code/core/Mage/Directory/etc/system.xml
index ca1c60b674..bb0b0cb5ad 100644
--- a/app/code/core/Mage/Directory/etc/system.xml
+++ b/app/code/core/Mage/Directory/etc/system.xml
@@ -68,15 +68,6 @@
1
1
-
- Remove space from currency sign
- select
- adminhtml/system_config_source_yesno
- 4
- 1
- 1
- 1
-
@@ -194,5 +185,22 @@
+
+
+
+
+
+ Postal Code is Optional for
+ multiselect
+ 3
+ adminhtml/system_config_source_country
+ 1
+ 0
+ 0
+
+
+
+
+
diff --git a/app/code/core/Mage/Downloadable/Helper/File.php b/app/code/core/Mage/Downloadable/Helper/File.php
index 86f5b75c78..56011856c7 100644
--- a/app/code/core/Mage/Downloadable/Helper/File.php
+++ b/app/code/core/Mage/Downloadable/Helper/File.php
@@ -33,6 +33,17 @@
*/
class Mage_Downloadable_Helper_File extends Mage_Core_Helper_Abstract
{
+ public function __construct()
+ {
+ $nodes = Mage::getConfig()->getNode('global/mime/types');
+ if ($nodes) {
+ $nodes = (array)$nodes;
+ foreach ($nodes as $key => $value) {
+ self::$_mimeTypes[$key] = $value;
+ }
+ }
+ }
+
/**
* Checking file for moving and move it
*
@@ -143,10 +154,619 @@ public function getFileType($filePath)
protected function _getFileTypeByExt($ext)
{
- $type = Mage::getConfig()->getNode('global/mime/types/x' . $ext);
- if ($type) {
- return $type;
+ $type = 'x' . $ext;
+ if (isset(self::$_mimeTypes[$type])) {
+ return self::$_mimeTypes[$type];
}
return 'application/octet-stream';
}
+
+ public function getAllFileTypes()
+ {
+ return array_values(self::getAllMineTypes());
+ }
+
+ public function getAllMineTypes()
+ {
+ return self::$_mimeTypes;
+ }
+
+ protected static $_mimeTypes =
+ array(
+ 'x123' => 'application/vnd.lotus-1-2-3',
+ 'x3dml' => 'text/vnd.in3d.3dml',
+ 'x3g2' => 'video/3gpp2',
+ 'x3gp' => 'video/3gpp',
+ 'xace' => 'application/x-ace-compressed',
+ 'xacu' => 'application/vnd.acucobol',
+ 'xaep' => 'application/vnd.audiograph',
+ 'xai' => 'application/postscript',
+ 'xaif' => 'audio/x-aiff',
+
+ 'xaifc' => 'audio/x-aiff',
+ 'xaiff' => 'audio/x-aiff',
+ 'xami' => 'application/vnd.amiga.ami',
+ 'xapr' => 'application/vnd.lotus-approach',
+ 'xasf' => 'video/x-ms-asf',
+ 'xaso' => 'application/vnd.accpac.simply.aso',
+ 'xasx' => 'video/x-ms-asf',
+ 'xatom' => 'application/atom+xml',
+ 'xatomcat' => 'application/atomcat+xml',
+
+ 'xatomsvc' => 'application/atomsvc+xml',
+ 'xatx' => 'application/vnd.antix.game-component',
+ 'xau' => 'audio/basic',
+ 'xavi' => 'video/x-msvideo',
+ 'xbat' => 'application/x-msdownload',
+ 'xbcpio' => 'application/x-bcpio',
+ 'xbdm' => 'application/vnd.syncml.dm+wbxml',
+ 'xbh2' => 'application/vnd.fujitsu.oasysprs',
+ 'xbmi' => 'application/vnd.bmi',
+
+ 'xbmp' => 'image/bmp',
+ 'xbox' => 'application/vnd.previewsystems.box',
+ 'xboz' => 'application/x-bzip2',
+ 'xbtif' => 'image/prs.btif',
+ 'xbz' => 'application/x-bzip',
+ 'xbz2' => 'application/x-bzip2',
+ 'xcab' => 'application/vnd.ms-cab-compressed',
+ 'xccxml' => 'application/ccxml+xml',
+ 'xcdbcmsg' => 'application/vnd.contact.cmsg',
+
+ 'xcdkey' => 'application/vnd.mediastation.cdkey',
+ 'xcdx' => 'chemical/x-cdx',
+ 'xcdxml' => 'application/vnd.chemdraw+xml',
+ 'xcdy' => 'application/vnd.cinderella',
+ 'xcer' => 'application/pkix-cert',
+ 'xcgm' => 'image/cgm',
+ 'xchat' => 'application/x-chat',
+ 'xchm' => 'application/vnd.ms-htmlhelp',
+ 'xchrt' => 'application/vnd.kde.kchart',
+
+ 'xcif' => 'chemical/x-cif',
+ 'xcii' => 'application/vnd.anser-web-certificate-issue-initiation',
+ 'xcil' => 'application/vnd.ms-artgalry',
+ 'xcla' => 'application/vnd.claymore',
+ 'xclkk' => 'application/vnd.crick.clicker.keyboard',
+ 'xclkp' => 'application/vnd.crick.clicker.palette',
+ 'xclkt' => 'application/vnd.crick.clicker.template',
+ 'xclkw' => 'application/vnd.crick.clicker.wordbank',
+ 'xclkx' => 'application/vnd.crick.clicker',
+
+ 'xclp' => 'application/x-msclip',
+ 'xcmc' => 'application/vnd.cosmocaller',
+ 'xcmdf' => 'chemical/x-cmdf',
+ 'xcml' => 'chemical/x-cml',
+ 'xcmp' => 'application/vnd.yellowriver-custom-menu',
+ 'xcmx' => 'image/x-cmx',
+ 'xcom' => 'application/x-msdownload',
+ 'xconf' => 'text/plain',
+ 'xcpio' => 'application/x-cpio',
+
+ 'xcpt' => 'application/mac-compactpro',
+ 'xcrd' => 'application/x-mscardfile',
+ 'xcrl' => 'application/pkix-crl',
+ 'xcrt' => 'application/x-x509-ca-cert',
+ 'xcsh' => 'application/x-csh',
+ 'xcsml' => 'chemical/x-csml',
+ 'xcss' => 'text/css',
+ 'xcsv' => 'text/csv',
+ 'xcurl' => 'application/vnd.curl',
+
+ 'xcww' => 'application/prs.cww',
+ 'xdaf' => 'application/vnd.mobius.daf',
+ 'xdavmount' => 'application/davmount+xml',
+ 'xdd2' => 'application/vnd.oma.dd2+xml',
+ 'xddd' => 'application/vnd.fujixerox.ddd',
+ 'xdef' => 'text/plain',
+ 'xder' => 'application/x-x509-ca-cert',
+ 'xdfac' => 'application/vnd.dreamfactory',
+ 'xdis' => 'application/vnd.mobius.dis',
+
+ 'xdjv' => 'image/vnd.djvu',
+ 'xdjvu' => 'image/vnd.djvu',
+ 'xdll' => 'application/x-msdownload',
+ 'xdna' => 'application/vnd.dna',
+ 'xdoc' => 'application/msword',
+ 'xdot' => 'application/msword',
+ 'xdp' => 'application/vnd.osgi.dp',
+ 'xdpg' => 'application/vnd.dpgraph',
+ 'xdsc' => 'text/prs.lines.tag',
+
+ 'xdtd' => 'application/xml-dtd',
+ 'xdvi' => 'application/x-dvi',
+ 'xdwf' => 'model/vnd.dwf',
+ 'xdwg' => 'image/vnd.dwg',
+ 'xdxf' => 'image/vnd.dxf',
+ 'xdxp' => 'application/vnd.spotfire.dxp',
+ 'xecelp4800' => 'audio/vnd.nuera.ecelp4800',
+ 'xecelp7470' => 'audio/vnd.nuera.ecelp7470',
+ 'xecelp9600' => 'audio/vnd.nuera.ecelp9600',
+
+ 'xecma' => 'application/ecmascript',
+ 'xedm' => 'application/vnd.novadigm.edm',
+ 'xedx' => 'application/vnd.novadigm.edx',
+ 'xefif' => 'application/vnd.picsel',
+ 'xei6' => 'application/vnd.pg.osasli',
+ 'xeml' => 'message/rfc822',
+ 'xeol' => 'audio/vnd.digital-winds',
+ 'xeot' => 'application/vnd.ms-fontobject',
+ 'xeps' => 'application/postscript',
+
+ 'xesf' => 'application/vnd.epson.esf',
+ 'xetx' => 'text/x-setext',
+ 'xexe' => 'application/x-msdownload',
+ 'xext' => 'application/vnd.novadigm.ext',
+ 'xez' => 'application/andrew-inset',
+ 'xez2' => 'application/vnd.ezpix-album',
+ 'xez3' => 'application/vnd.ezpix-package',
+ 'xfbs' => 'image/vnd.fastbidsheet',
+ 'xfdf' => 'application/vnd.fdf',
+
+ 'xfe_launch' => 'application/vnd.denovo.fcselayout-link',
+ 'xfg5' => 'application/vnd.fujitsu.oasysgp',
+ 'xfli' => 'video/x-fli',
+ 'xflo' => 'application/vnd.micrografx.flo',
+ 'xflw' => 'application/vnd.kde.kivio',
+ 'xflx' => 'text/vnd.fmi.flexstor',
+ 'xfly' => 'text/vnd.fly',
+ 'xfnc' => 'application/vnd.frogans.fnc',
+ 'xfpx' => 'image/vnd.fpx',
+
+ 'xfsc' => 'application/vnd.fsc.weblaunch',
+ 'xfst' => 'image/vnd.fst',
+ 'xftc' => 'application/vnd.fluxtime.clip',
+ 'xfti' => 'application/vnd.anser-web-funds-transfer-initiation',
+ 'xfvt' => 'video/vnd.fvt',
+ 'xfzs' => 'application/vnd.fuzzysheet',
+ 'xg3' => 'image/g3fax',
+ 'xgac' => 'application/vnd.groove-account',
+ 'xgdl' => 'model/vnd.gdl',
+
+ 'xghf' => 'application/vnd.groove-help',
+ 'xgif' => 'image/gif',
+ 'xgim' => 'application/vnd.groove-identity-message',
+ 'xgph' => 'application/vnd.flographit',
+ 'xgram' => 'application/srgs',
+ 'xgrv' => 'application/vnd.groove-injector',
+ 'xgrxml' => 'application/srgs+xml',
+ 'xgtar' => 'application/x-gtar',
+ 'xgtm' => 'application/vnd.groove-tool-message',
+
+ 'xgtw' => 'model/vnd.gtw',
+ 'xh261' => 'video/h261',
+ 'xh263' => 'video/h263',
+ 'xh264' => 'video/h264',
+ 'xhbci' => 'application/vnd.hbci',
+ 'xhdf' => 'application/x-hdf',
+ 'xhlp' => 'application/winhlp',
+ 'xhpgl' => 'application/vnd.hp-hpgl',
+ 'xhpid' => 'application/vnd.hp-hpid',
+
+ 'xhps' => 'application/vnd.hp-hps',
+ 'xhqx' => 'application/mac-binhex40',
+ 'xhtke' => 'application/vnd.kenameaapp',
+ 'xhtm' => 'text/html',
+ 'xhtml' => 'text/html',
+ 'xhvd' => 'application/vnd.yamaha.hv-dic',
+ 'xhvp' => 'application/vnd.yamaha.hv-voice',
+ 'xhvs' => 'application/vnd.yamaha.hv-script',
+ 'xice' => '#x-conference/x-cooltalk',
+
+ 'xico' => 'image/x-icon',
+ 'xics' => 'text/calendar',
+ 'xief' => 'image/ief',
+ 'xifb' => 'text/calendar',
+ 'xifm' => 'application/vnd.shana.informed.formdata',
+ 'xigl' => 'application/vnd.igloader',
+ 'xigx' => 'application/vnd.micrografx.igx',
+ 'xiif' => 'application/vnd.shana.informed.interchange',
+ 'ximp' => 'application/vnd.accpac.simply.imp',
+
+ 'xims' => 'application/vnd.ms-ims',
+ 'xin' => 'text/plain',
+ 'xipk' => 'application/vnd.shana.informed.package',
+ 'xirm' => 'application/vnd.ibm.rights-management',
+ 'xirp' => 'application/vnd.irepository.package+xml',
+ 'xitp' => 'application/vnd.shana.informed.formtemplate',
+ 'xivp' => 'application/vnd.immervision-ivp',
+ 'xivu' => 'application/vnd.immervision-ivu',
+ 'xjad' => 'text/vnd.sun.j2me.app-descriptor',
+
+ 'xjam' => 'application/vnd.jam',
+ 'xjava' => 'text/x-java-source',
+ 'xjisp' => 'application/vnd.jisp',
+ 'xjlt' => 'application/vnd.hp-jlyt',
+ 'xjoda' => 'application/vnd.joost.joda-archive',
+ 'xjpe' => 'image/jpeg',
+ 'xjpeg' => 'image/jpeg',
+ 'xjpg' => 'image/jpeg',
+ 'xjpgm' => 'video/jpm',
+
+ 'xjpgv' => 'video/jpeg',
+ 'xjpm' => 'video/jpm',
+ 'xjs' => 'application/javascript',
+ 'xjson' => 'application/json',
+ 'xkar' => 'audio/midi',
+ 'xkarbon' => 'application/vnd.kde.karbon',
+ 'xkfo' => 'application/vnd.kde.kformula',
+ 'xkia' => 'application/vnd.kidspiration',
+ 'xkml' => 'application/vnd.google-earth.kml+xml',
+
+ 'xkmz' => 'application/vnd.google-earth.kmz',
+ 'xkon' => 'application/vnd.kde.kontour',
+ 'xksp' => 'application/vnd.kde.kspread',
+ 'xlatex' => 'application/x-latex',
+ 'xlbd' => 'application/vnd.llamagraphics.life-balance.desktop',
+ 'xlbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
+ 'xles' => 'application/vnd.hhe.lesson-player',
+ 'xlist' => 'text/plain',
+ 'xlog' => 'text/plain',
+
+ 'xlrm' => 'application/vnd.ms-lrm',
+ 'xltf' => 'application/vnd.frogans.ltf',
+ 'xlvp' => 'audio/vnd.lucent.voice',
+ 'xlwp' => 'application/vnd.lotus-wordpro',
+ 'xm13' => 'application/x-msmediaview',
+ 'xm14' => 'application/x-msmediaview',
+ 'xm1v' => 'video/mpeg',
+ 'xm2a' => 'audio/mpeg',
+ 'xm3a' => 'audio/mpeg',
+
+ 'xm3u' => 'audio/x-mpegurl',
+ 'xm4u' => 'video/vnd.mpegurl',
+ 'xmag' => 'application/vnd.ecowin.chart',
+ 'xmathml' => 'application/mathml+xml',
+ 'xmbk' => 'application/vnd.mobius.mbk',
+ 'xmbox' => 'application/mbox',
+ 'xmc1' => 'application/vnd.medcalcdata',
+ 'xmcd' => 'application/vnd.mcd',
+ 'xmdb' => 'application/x-msaccess',
+
+ 'xmdi' => 'image/vnd.ms-modi',
+ 'xmesh' => 'model/mesh',
+ 'xmfm' => 'application/vnd.mfmp',
+ 'xmgz' => 'application/vnd.proteus.magazine',
+ 'xmid' => 'audio/midi',
+ 'xmidi' => 'audio/midi',
+ 'xmif' => 'application/vnd.mif',
+ 'xmime' => 'message/rfc822',
+ 'xmj2' => 'video/mj2',
+
+ 'xmjp2' => 'video/mj2',
+ 'xmlp' => 'application/vnd.dolby.mlp',
+ 'xmmd' => 'application/vnd.chipnuts.karaoke-mmd',
+ 'xmmf' => 'application/vnd.smaf',
+ 'xmmr' => 'image/vnd.fujixerox.edmics-mmr',
+ 'xmny' => 'application/x-msmoney',
+ 'xmov' => 'video/quicktime',
+ 'xmovie' => 'video/x-sgi-movie',
+ 'xmp2' => 'audio/mpeg',
+
+ 'xmp2a' => 'audio/mpeg',
+ 'xmp3' => 'audio/mpeg',
+ 'xmp4' => 'video/mp4',
+ 'xmp4a' => 'audio/mp4',
+ 'xmp4s' => 'application/mp4',
+ 'xmp4v' => 'video/mp4',
+ 'xmpc' => 'application/vnd.mophun.certificate',
+ 'xmpe' => 'video/mpeg',
+ 'xmpeg' => 'video/mpeg',
+
+ 'xmpg' => 'video/mpeg',
+ 'xmpg4' => 'video/mp4',
+ 'xmpga' => 'audio/mpeg',
+ 'xmpkg' => 'application/vnd.apple.installer+xml',
+ 'xmpm' => 'application/vnd.blueice.multipass',
+ 'xmpn' => 'application/vnd.mophun.application',
+ 'xmpp' => 'application/vnd.ms-project',
+ 'xmpt' => 'application/vnd.ms-project',
+ 'xmpy' => 'application/vnd.ibm.minipay',
+
+ 'xmqy' => 'application/vnd.mobius.mqy',
+ 'xmrc' => 'application/marc',
+ 'xmscml' => 'application/mediaservercontrol+xml',
+ 'xmseq' => 'application/vnd.mseq',
+ 'xmsf' => 'application/vnd.epson.msf',
+ 'xmsh' => 'model/mesh',
+ 'xmsi' => 'application/x-msdownload',
+ 'xmsl' => 'application/vnd.mobius.msl',
+ 'xmsty' => 'application/vnd.muvee.style',
+
+ 'xmts' => 'model/vnd.mts',
+ 'xmus' => 'application/vnd.musician',
+ 'xmvb' => 'application/x-msmediaview',
+ 'xmwf' => 'application/vnd.mfer',
+ 'xmxf' => 'application/mxf',
+ 'xmxl' => 'application/vnd.recordare.musicxml',
+ 'xmxml' => 'application/xv+xml',
+ 'xmxs' => 'application/vnd.triscape.mxs',
+ 'xmxu' => 'video/vnd.mpegurl',
+
+ 'xn-gage' => 'application/vnd.nokia.n-gage.symbian.install',
+ 'xngdat' => 'application/vnd.nokia.n-gage.data',
+ 'xnlu' => 'application/vnd.neurolanguage.nlu',
+ 'xnml' => 'application/vnd.enliven',
+ 'xnnd' => 'application/vnd.noblenet-directory',
+ 'xnns' => 'application/vnd.noblenet-sealer',
+ 'xnnw' => 'application/vnd.noblenet-web',
+ 'xnpx' => 'image/vnd.net-fpx',
+ 'xnsf' => 'application/vnd.lotus-notes',
+
+ 'xoa2' => 'application/vnd.fujitsu.oasys2',
+ 'xoa3' => 'application/vnd.fujitsu.oasys3',
+ 'xoas' => 'application/vnd.fujitsu.oasys',
+ 'xobd' => 'application/x-msbinder',
+ 'xoda' => 'application/oda',
+ 'xodc' => 'application/vnd.oasis.opendocument.chart',
+ 'xodf' => 'application/vnd.oasis.opendocument.formula',
+ 'xodg' => 'application/vnd.oasis.opendocument.graphics',
+ 'xodi' => 'application/vnd.oasis.opendocument.image',
+
+ 'xodp' => 'application/vnd.oasis.opendocument.presentation',
+ 'xods' => 'application/vnd.oasis.opendocument.spreadsheet',
+ 'xodt' => 'application/vnd.oasis.opendocument.text',
+ 'xogg' => 'application/ogg',
+ 'xoprc' => 'application/vnd.palm',
+ 'xorg' => 'application/vnd.lotus-organizer',
+ 'xotc' => 'application/vnd.oasis.opendocument.chart-template',
+ 'xotf' => 'application/vnd.oasis.opendocument.formula-template',
+ 'xotg' => 'application/vnd.oasis.opendocument.graphics-template',
+
+ 'xoth' => 'application/vnd.oasis.opendocument.text-web',
+ 'xoti' => 'application/vnd.oasis.opendocument.image-template',
+ 'xotm' => 'application/vnd.oasis.opendocument.text-master',
+ 'xots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
+ 'xott' => 'application/vnd.oasis.opendocument.text-template',
+ 'xoxt' => 'application/vnd.openofficeorg.extension',
+ 'xp10' => 'application/pkcs10',
+ 'xp7r' => 'application/x-pkcs7-certreqresp',
+ 'xp7s' => 'application/pkcs7-signature',
+
+ 'xpbd' => 'application/vnd.powerbuilder6',
+ 'xpbm' => 'image/x-portable-bitmap',
+ 'xpcl' => 'application/vnd.hp-pcl',
+ 'xpclxl' => 'application/vnd.hp-pclxl',
+ 'xpct' => 'image/x-pict',
+ 'xpcx' => 'image/x-pcx',
+ 'xpdb' => 'chemical/x-pdb',
+ 'xpdf' => 'application/pdf',
+ 'xpfr' => 'application/font-tdpfr',
+
+ 'xpgm' => 'image/x-portable-graymap',
+ 'xpgn' => 'application/x-chess-pgn',
+ 'xpgp' => 'application/pgp-encrypted',
+ 'xpic' => 'image/x-pict',
+ 'xpki' => 'application/pkixcmp',
+ 'xpkipath' => 'application/pkix-pkipath',
+ 'xplb' => 'application/vnd.3gpp.pic-bw-large',
+ 'xplc' => 'application/vnd.mobius.plc',
+ 'xplf' => 'application/vnd.pocketlearn',
+
+ 'xpls' => 'application/pls+xml',
+ 'xpml' => 'application/vnd.ctc-posml',
+ 'xpng' => 'image/png',
+ 'xpnm' => 'image/x-portable-anymap',
+ 'xportpkg' => 'application/vnd.macports.portpkg',
+ 'xpot' => 'application/vnd.ms-powerpoint',
+ 'xppd' => 'application/vnd.cups-ppd',
+ 'xppm' => 'image/x-portable-pixmap',
+ 'xpps' => 'application/vnd.ms-powerpoint',
+
+ 'xppt' => 'application/vnd.ms-powerpoint',
+ 'xpqa' => 'application/vnd.palm',
+ 'xprc' => 'application/vnd.palm',
+ 'xpre' => 'application/vnd.lotus-freelance',
+ 'xprf' => 'application/pics-rules',
+ 'xps' => 'application/postscript',
+ 'xpsb' => 'application/vnd.3gpp.pic-bw-small',
+ 'xpsd' => 'image/vnd.adobe.photoshop',
+ 'xptid' => 'application/vnd.pvi.ptid1',
+
+ 'xpub' => 'application/x-mspublisher',
+ 'xpvb' => 'application/vnd.3gpp.pic-bw-var',
+ 'xpwn' => 'application/vnd.3m.post-it-notes',
+ 'xqam' => 'application/vnd.epson.quickanime',
+ 'xqbo' => 'application/vnd.intu.qbo',
+ 'xqfx' => 'application/vnd.intu.qfx',
+ 'xqps' => 'application/vnd.publishare-delta-tree',
+ 'xqt' => 'video/quicktime',
+ 'xra' => 'audio/x-pn-realaudio',
+
+ 'xram' => 'audio/x-pn-realaudio',
+ 'xrar' => 'application/x-rar-compressed',
+ 'xras' => 'image/x-cmu-raster',
+ 'xrcprofile' => 'application/vnd.ipunplugged.rcprofile',
+ 'xrdf' => 'application/rdf+xml',
+ 'xrdz' => 'application/vnd.data-vision.rdz',
+ 'xrep' => 'application/vnd.businessobjects',
+ 'xrgb' => 'image/x-rgb',
+ 'xrif' => 'application/reginfo+xml',
+
+ 'xrl' => 'application/resource-lists+xml',
+ 'xrlc' => 'image/vnd.fujixerox.edmics-rlc',
+ 'xrm' => 'application/vnd.rn-realmedia',
+ 'xrmi' => 'audio/midi',
+ 'xrmp' => 'audio/x-pn-realaudio-plugin',
+ 'xrms' => 'application/vnd.jcp.javame.midlet-rms',
+ 'xrnc' => 'application/relax-ng-compact-syntax',
+ 'xrpss' => 'application/vnd.nokia.radio-presets',
+ 'xrpst' => 'application/vnd.nokia.radio-preset',
+
+ 'xrq' => 'application/sparql-query',
+ 'xrs' => 'application/rls-services+xml',
+ 'xrsd' => 'application/rsd+xml',
+ 'xrss' => 'application/rss+xml',
+ 'xrtf' => 'application/rtf',
+ 'xrtx' => 'text/richtext',
+ 'xsaf' => 'application/vnd.yamaha.smaf-audio',
+ 'xsbml' => 'application/sbml+xml',
+ 'xsc' => 'application/vnd.ibm.secure-container',
+
+ 'xscd' => 'application/x-msschedule',
+ 'xscm' => 'application/vnd.lotus-screencam',
+ 'xscq' => 'application/scvp-cv-request',
+ 'xscs' => 'application/scvp-cv-response',
+ 'xsdp' => 'application/sdp',
+ 'xsee' => 'application/vnd.seemail',
+ 'xsema' => 'application/vnd.sema',
+ 'xsemd' => 'application/vnd.semd',
+ 'xsemf' => 'application/vnd.semf',
+
+ 'xsetpay' => 'application/set-payment-initiation',
+ 'xsetreg' => 'application/set-registration-initiation',
+ 'xsfs' => 'application/vnd.spotfire.sfs',
+ 'xsgm' => 'text/sgml',
+ 'xsgml' => 'text/sgml',
+ 'xsh' => 'application/x-sh',
+ 'xshar' => 'application/x-shar',
+ 'xshf' => 'application/shf+xml',
+ 'xsilo' => 'model/mesh',
+
+ 'xsit' => 'application/x-stuffit',
+ 'xsitx' => 'application/x-stuffitx',
+ 'xslt' => 'application/vnd.epson.salt',
+ 'xsnd' => 'audio/basic',
+ 'xspf' => 'application/vnd.yamaha.smaf-phrase',
+ 'xspl' => 'application/x-futuresplash',
+ 'xspot' => 'text/vnd.in3d.spot',
+ 'xspp' => 'application/scvp-vp-response',
+ 'xspq' => 'application/scvp-vp-request',
+
+ 'xsrc' => 'application/x-wais-source',
+ 'xsrx' => 'application/sparql-results+xml',
+ 'xssf' => 'application/vnd.epson.ssf',
+ 'xssml' => 'application/ssml+xml',
+ 'xstf' => 'application/vnd.wt.stf',
+ 'xstk' => 'application/hyperstudio',
+ 'xstr' => 'application/vnd.pg.format',
+ 'xsus' => 'application/vnd.sus-calendar',
+ 'xsusp' => 'application/vnd.sus-calendar',
+
+ 'xsv4cpio' => 'application/x-sv4cpio',
+ 'xsv4crc' => 'application/x-sv4crc',
+ 'xsvd' => 'application/vnd.svd',
+ 'xswf' => 'application/x-shockwave-flash',
+ 'xtao' => 'application/vnd.tao.intent-module-archive',
+ 'xtar' => 'application/x-tar',
+ 'xtcap' => 'application/vnd.3gpp2.tcap',
+ 'xtcl' => 'application/x-tcl',
+ 'xtex' => 'application/x-tex',
+
+ 'xtext' => 'text/plain',
+ 'xtif' => 'image/tiff',
+ 'xtiff' => 'image/tiff',
+ 'xtmo' => 'application/vnd.tmobile-livetv',
+ 'xtorrent' => 'application/x-bittorrent',
+ 'xtpl' => 'application/vnd.groove-tool-template',
+ 'xtpt' => 'application/vnd.trid.tpt',
+ 'xtra' => 'application/vnd.trueapp',
+ 'xtrm' => 'application/x-msterminal',
+
+ 'xtsv' => 'text/tab-separated-values',
+ 'xtxd' => 'application/vnd.genomatix.tuxedo',
+ 'xtxf' => 'application/vnd.mobius.txf',
+ 'xtxt' => 'text/plain',
+ 'xumj' => 'application/vnd.umajin',
+ 'xunityweb' => 'application/vnd.unity',
+ 'xuoml' => 'application/vnd.uoml+xml',
+ 'xuri' => 'text/uri-list',
+ 'xuris' => 'text/uri-list',
+
+ 'xurls' => 'text/uri-list',
+ 'xustar' => 'application/x-ustar',
+ 'xutz' => 'application/vnd.uiq.theme',
+ 'xuu' => 'text/x-uuencode',
+ 'xvcd' => 'application/x-cdlink',
+ 'xvcf' => 'text/x-vcard',
+ 'xvcg' => 'application/vnd.groove-vcard',
+ 'xvcs' => 'text/x-vcalendar',
+ 'xvcx' => 'application/vnd.vcx',
+
+ 'xvis' => 'application/vnd.visionary',
+ 'xviv' => 'video/vnd.vivo',
+ 'xvrml' => 'model/vrml',
+ 'xvsd' => 'application/vnd.visio',
+ 'xvsf' => 'application/vnd.vsf',
+ 'xvss' => 'application/vnd.visio',
+ 'xvst' => 'application/vnd.visio',
+ 'xvsw' => 'application/vnd.visio',
+ 'xvtu' => 'model/vnd.vtu',
+
+ 'xvxml' => 'application/voicexml+xml',
+ 'xwav' => 'audio/x-wav',
+ 'xwax' => 'audio/x-ms-wax',
+ 'xwbmp' => 'image/vnd.wap.wbmp',
+ 'xwbs' => 'application/vnd.criticaltools.wbs+xml',
+ 'xwbxml' => 'application/vnd.wap.wbxml',
+ 'xwcm' => 'application/vnd.ms-works',
+ 'xwdb' => 'application/vnd.ms-works',
+ 'xwks' => 'application/vnd.ms-works',
+
+ 'xwm' => 'video/x-ms-wm',
+ 'xwma' => 'audio/x-ms-wma',
+ 'xwmd' => 'application/x-ms-wmd',
+ 'xwmf' => 'application/x-msmetafile',
+ 'xwml' => 'text/vnd.wap.wml',
+ 'xwmlc' => 'application/vnd.wap.wmlc',
+ 'xwmls' => 'text/vnd.wap.wmlscript',
+ 'xwmlsc' => 'application/vnd.wap.wmlscriptc',
+ 'xwmv' => 'video/x-ms-wmv',
+
+ 'xwmx' => 'video/x-ms-wmx',
+ 'xwmz' => 'application/x-ms-wmz',
+ 'xwpd' => 'application/vnd.wordperfect',
+ 'xwpl' => 'application/vnd.ms-wpl',
+ 'xwps' => 'application/vnd.ms-works',
+ 'xwqd' => 'application/vnd.wqd',
+ 'xwri' => 'application/x-mswrite',
+ 'xwrl' => 'model/vrml',
+ 'xwsdl' => 'application/wsdl+xml',
+
+ 'xwspolicy' => 'application/wspolicy+xml',
+ 'xwtb' => 'application/vnd.webturbo',
+ 'xwvx' => 'video/x-ms-wvx',
+ 'xx3d' => 'application/vnd.hzn-3d-crossword',
+ 'xxar' => 'application/vnd.xara',
+ 'xxbd' => 'application/vnd.fujixerox.docuworks.binder',
+ 'xxbm' => 'image/x-xbitmap',
+ 'xxdm' => 'application/vnd.syncml.dm+xml',
+ 'xxdp' => 'application/vnd.adobe.xdp+xml',
+
+ 'xxdw' => 'application/vnd.fujixerox.docuworks',
+ 'xxenc' => 'application/xenc+xml',
+ 'xxfdf' => 'application/vnd.adobe.xfdf',
+ 'xxfdl' => 'application/vnd.xfdl',
+ 'xxht' => 'application/xhtml+xml',
+ 'xxhtml' => 'application/xhtml+xml',
+ 'xxhvml' => 'application/xv+xml',
+ 'xxif' => 'image/vnd.xiff',
+ 'xxla' => 'application/vnd.ms-excel',
+
+ 'xxlc' => 'application/vnd.ms-excel',
+ 'xxlm' => 'application/vnd.ms-excel',
+ 'xxls' => 'application/vnd.ms-excel',
+ 'xxlt' => 'application/vnd.ms-excel',
+ 'xxlw' => 'application/vnd.ms-excel',
+ 'xxml' => 'application/xml',
+ 'xxo' => 'application/vnd.olpc-sugar',
+ 'xxop' => 'application/xop+xml',
+ 'xxpm' => 'image/x-xpixmap',
+
+ 'xxpr' => 'application/vnd.is-xpr',
+ 'xxps' => 'application/vnd.ms-xpsdocument',
+ 'xxsl' => 'application/xml',
+ 'xxslt' => 'application/xslt+xml',
+ 'xxsm' => 'application/vnd.syncml+xml',
+ 'xxspf' => 'application/xspf+xml',
+ 'xxul' => 'application/vnd.mozilla.xul+xml',
+ 'xxvm' => 'application/xv+xml',
+ 'xxvml' => 'application/xv+xml',
+
+ 'xxwd' => 'image/x-xwindowdump',
+ 'xxyz' => 'chemical/x-xyz',
+ 'xzaz' => 'application/vnd.zzazz.deck+xml',
+ 'xzip' => 'application/zip',
+ 'xzmm' => 'application/vnd.handheld-entertainment+xml'
+ );
}
diff --git a/app/code/core/Mage/Downloadable/Model/Product/Type.php b/app/code/core/Mage/Downloadable/Model/Product/Type.php
index 3dac7c132c..39fe36f079 100644
--- a/app/code/core/Mage/Downloadable/Model/Product/Type.php
+++ b/app/code/core/Mage/Downloadable/Model/Product/Type.php
@@ -70,6 +70,9 @@ public function getLinks($product = null)
*/
public function hasLinks($product = null)
{
+ if ($this->getProduct($product)->hasData('links_exist')) {
+ return $this->getProduct($product)->getData('links_exist');
+ }
return count($this->getLinks($product)) > 0;
}
@@ -143,7 +146,7 @@ public function hasSamples($product = null)
}
/**
- * Enter description here...
+ * Save Product downloadable information (links and samples)
*
* @param Mage_Catalog_Model_Product $product
* @return Mage_Downloadable_Model_Product_Type
@@ -260,6 +263,9 @@ public function save($product = null)
if ($_deleteItems) {
Mage::getResourceModel('downloadable/link')->deleteItems($_deleteItems);
}
+ if ($this->getProduct($product)->getLinksPurchasedSeparately()) {
+ $this->getProduct($product)->setIsCustomOptionChanged();
+ }
}
}
@@ -267,7 +273,7 @@ public function save($product = null)
}
/**
- * Enter description here...
+ * Prepare Product object before adding to Shopping Cart
*
* @param Varien_Object $buyRequest
* @param Mage_Catalog_Model_Product $product
@@ -355,6 +361,20 @@ public function beforeSave($product = null)
$this->getProduct($product)->setTypeHasOptions(false);
$this->getProduct($product)->setTypeHasRequiredOptions(false);
}
+
+ // Update links_exist attribute value
+ $linksExist = false;
+ if ($data = $product->getDownloadableData()) {
+ if (isset($data['link'])) {
+ foreach ($data['link'] as $linkItem) {
+ if (!isset($linkItem['is_delete']) || !$linkItem['is_delete']) {
+ $linksExist = true;
+ break;
+ }
+ }
+ }
+ }
+ $this->getProduct($product)->setLinksExist($linksExist);
}
/**
@@ -383,4 +403,15 @@ public function getSearchableData($product = null)
return $searchData;
}
+
+ /**
+ * Check is product available for sale
+ *
+ * @param Mage_Catalog_Model_Product $product
+ * @return bool
+ */
+ public function isSalable($product = null)
+ {
+ return $this->hasLinks($product) && parent::isSalable($product);
+ }
}
diff --git a/app/code/core/Mage/Downloadable/etc/config.xml b/app/code/core/Mage/Downloadable/etc/config.xml
index 62bf6b870d..cfce6421fa 100644
--- a/app/code/core/Mage/Downloadable/etc/config.xml
+++ b/app/code/core/Mage/Downloadable/etc/config.xml
@@ -28,7 +28,7 @@
- 0.1.15
+ 0.1.16
@@ -108,20 +108,7 @@
Mage_Downloadable
Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -133,6 +120,7 @@
downloadable/product_price
downloadable/catalogIndex_data_downloadable
0
+ downloadable/indexer_price
@@ -160,605 +148,6 @@
downloadable/sales_order_pdf_items_creditmemo
-
-
- application/vnd.lotus-1-2-3
- text/vnd.in3d.3dml
- video/3gpp2
- video/3gpp
- application/x-ace-compressed
- application/vnd.acucobol
- application/vnd.audiograph
- application/postscript
- audio/x-aiff
-
- audio/x-aiff
- audio/x-aiff
- application/vnd.amiga.ami
- application/vnd.lotus-approach
- video/x-ms-asf
- application/vnd.accpac.simply.aso
- video/x-ms-asf
- application/atom+xml
- application/atomcat+xml
-
- application/atomsvc+xml
- application/vnd.antix.game-component
- audio/basic
- video/x-msvideo
- application/x-msdownload
- application/x-bcpio
- application/vnd.syncml.dm+wbxml
- application/vnd.fujitsu.oasysprs
- application/vnd.bmi
-
- image/bmp
- application/vnd.previewsystems.box
- application/x-bzip2
- image/prs.btif
- application/x-bzip
- application/x-bzip2
- application/vnd.ms-cab-compressed
- application/ccxml+xml
- application/vnd.contact.cmsg
-
- application/vnd.mediastation.cdkey
- chemical/x-cdx
- application/vnd.chemdraw+xml
- application/vnd.cinderella
- application/pkix-cert
- image/cgm
- application/x-chat
- application/vnd.ms-htmlhelp
- application/vnd.kde.kchart
-
- chemical/x-cif
- application/vnd.anser-web-certificate-issue-initiation
- application/vnd.ms-artgalry
- application/vnd.claymore
- application/vnd.crick.clicker.keyboard
- application/vnd.crick.clicker.palette
- application/vnd.crick.clicker.template
- application/vnd.crick.clicker.wordbank
- application/vnd.crick.clicker
-
- application/x-msclip
- application/vnd.cosmocaller
- chemical/x-cmdf
- chemical/x-cml
- application/vnd.yellowriver-custom-menu
- image/x-cmx
- application/x-msdownload
- text/plain
- application/x-cpio
-
- application/mac-compactpro
- application/x-mscardfile
- application/pkix-crl
- application/x-x509-ca-cert
- application/x-csh
- chemical/x-csml
- text/css
- text/csv
- application/vnd.curl
-
- application/prs.cww
- application/vnd.mobius.daf
- application/davmount+xml
- application/vnd.oma.dd2+xml
- application/vnd.fujixerox.ddd
- text/plain
- application/x-x509-ca-cert
- application/vnd.dreamfactory
- application/vnd.mobius.dis
-
- image/vnd.djvu
- image/vnd.djvu
- application/x-msdownload
- application/vnd.dna
- application/msword
- application/msword
- application/vnd.osgi.dp
- application/vnd.dpgraph
- text/prs.lines.tag
-
- application/xml-dtd
- application/x-dvi
- model/vnd.dwf
- image/vnd.dwg
- image/vnd.dxf
- application/vnd.spotfire.dxp
- audio/vnd.nuera.ecelp4800
- audio/vnd.nuera.ecelp7470
- audio/vnd.nuera.ecelp9600
-
- application/ecmascript
- application/vnd.novadigm.edm
- application/vnd.novadigm.edx
- application/vnd.picsel
- application/vnd.pg.osasli
- message/rfc822
- audio/vnd.digital-winds
- application/vnd.ms-fontobject
- application/postscript
-
- application/vnd.epson.esf
- text/x-setext
- application/x-msdownload
- application/vnd.novadigm.ext
- application/andrew-inset
- application/vnd.ezpix-album
- application/vnd.ezpix-package
- image/vnd.fastbidsheet
- application/vnd.fdf
-
- application/vnd.denovo.fcselayout-link
- application/vnd.fujitsu.oasysgp
- video/x-fli
- application/vnd.micrografx.flo
- application/vnd.kde.kivio
- text/vnd.fmi.flexstor
- text/vnd.fly
- application/vnd.frogans.fnc
- image/vnd.fpx
-
- application/vnd.fsc.weblaunch
- image/vnd.fst
- application/vnd.fluxtime.clip
- application/vnd.anser-web-funds-transfer-initiation
- video/vnd.fvt
- application/vnd.fuzzysheet
- image/g3fax
- application/vnd.groove-account
- model/vnd.gdl
-
- application/vnd.groove-help
- image/gif
- application/vnd.groove-identity-message
- application/vnd.flographit
- application/srgs
- application/vnd.groove-injector
- application/srgs+xml
- application/x-gtar
- application/vnd.groove-tool-message
-
- model/vnd.gtw
- video/h261
- video/h263
- video/h264
- application/vnd.hbci
- application/x-hdf
- application/winhlp
- application/vnd.hp-hpgl
- application/vnd.hp-hpid
-
- application/vnd.hp-hps
- application/mac-binhex40
- application/vnd.kenameaapp
- text/html
- text/html
- application/vnd.yamaha.hv-dic
- application/vnd.yamaha.hv-voice
- application/vnd.yamaha.hv-script
- #x-conference/x-cooltalk
-
- image/x-icon
- text/calendar
- image/ief
- text/calendar
- application/vnd.shana.informed.formdata
- application/vnd.igloader
- application/vnd.micrografx.igx
- application/vnd.shana.informed.interchange
- application/vnd.accpac.simply.imp
-
- application/vnd.ms-ims
- text/plain
- application/vnd.shana.informed.package
- application/vnd.ibm.rights-management
- application/vnd.irepository.package+xml
- application/vnd.shana.informed.formtemplate
- application/vnd.immervision-ivp
- application/vnd.immervision-ivu
- text/vnd.sun.j2me.app-descriptor
-
- application/vnd.jam
- text/x-java-source
- application/vnd.jisp
- application/vnd.hp-jlyt
- application/vnd.joost.joda-archive
- image/jpeg
- image/jpeg
- image/jpeg
- video/jpm
-
- video/jpeg
- video/jpm
- application/javascript
- application/json
- audio/midi
- application/vnd.kde.karbon
- application/vnd.kde.kformula
- application/vnd.kidspiration
- application/vnd.google-earth.kml+xml
-
- application/vnd.google-earth.kmz
- application/vnd.kde.kontour
- application/vnd.kde.kspread
- application/x-latex
- application/vnd.llamagraphics.life-balance.desktop
- application/vnd.llamagraphics.life-balance.exchange+xml
- application/vnd.hhe.lesson-player
- text/plain
- text/plain
-
- application/vnd.ms-lrm
- application/vnd.frogans.ltf
- audio/vnd.lucent.voice
- application/vnd.lotus-wordpro
- application/x-msmediaview
- application/x-msmediaview
- video/mpeg
- audio/mpeg
- audio/mpeg
-
- audio/x-mpegurl
- video/vnd.mpegurl
- application/vnd.ecowin.chart
- application/mathml+xml
- application/vnd.mobius.mbk
- application/mbox
- application/vnd.medcalcdata
- application/vnd.mcd
- application/x-msaccess
-
- image/vnd.ms-modi
- model/mesh
- application/vnd.mfmp
- application/vnd.proteus.magazine
- audio/midi
- audio/midi
- application/vnd.mif
- message/rfc822
- video/mj2
-
- video/mj2
- application/vnd.dolby.mlp
- application/vnd.chipnuts.karaoke-mmd
- application/vnd.smaf
- image/vnd.fujixerox.edmics-mmr
- application/x-msmoney
- video/quicktime
- video/x-sgi-movie
- audio/mpeg
-
- audio/mpeg
- audio/mpeg
- video/mp4
- audio/mp4
- application/mp4
- video/mp4
- application/vnd.mophun.certificate
- video/mpeg
- video/mpeg
-
- video/mpeg
- video/mp4
- audio/mpeg
- application/vnd.apple.installer+xml
- application/vnd.blueice.multipass
- application/vnd.mophun.application
- application/vnd.ms-project
- application/vnd.ms-project
- application/vnd.ibm.minipay
-
- application/vnd.mobius.mqy
- application/marc
- application/mediaservercontrol+xml
- application/vnd.mseq
- application/vnd.epson.msf
- model/mesh
- application/x-msdownload
- application/vnd.mobius.msl
- application/vnd.muvee.style
-
- model/vnd.mts
- application/vnd.musician
- application/x-msmediaview
- application/vnd.mfer
- application/mxf
- application/vnd.recordare.musicxml
- application/xv+xml
- application/vnd.triscape.mxs
- video/vnd.mpegurl
-
- application/vnd.nokia.n-gage.symbian.install
- application/vnd.nokia.n-gage.data
- application/vnd.neurolanguage.nlu
- application/vnd.enliven
- application/vnd.noblenet-directory
- application/vnd.noblenet-sealer
- application/vnd.noblenet-web
- image/vnd.net-fpx
- application/vnd.lotus-notes
-
- application/vnd.fujitsu.oasys2
- application/vnd.fujitsu.oasys3
- application/vnd.fujitsu.oasys
- application/x-msbinder
- application/oda
- application/vnd.oasis.opendocument.chart
- application/vnd.oasis.opendocument.formula
- application/vnd.oasis.opendocument.graphics
- application/vnd.oasis.opendocument.image
-
- application/vnd.oasis.opendocument.presentation
- application/vnd.oasis.opendocument.spreadsheet
- application/vnd.oasis.opendocument.text
- application/ogg
- application/vnd.palm
- application/vnd.lotus-organizer
- application/vnd.oasis.opendocument.chart-template
- application/vnd.oasis.opendocument.formula-template
- application/vnd.oasis.opendocument.graphics-template
-
- application/vnd.oasis.opendocument.text-web
- application/vnd.oasis.opendocument.image-template
- application/vnd.oasis.opendocument.text-master
- application/vnd.oasis.opendocument.spreadsheet-template
- application/vnd.oasis.opendocument.text-template
- application/vnd.openofficeorg.extension
- application/pkcs10
- application/x-pkcs7-certreqresp
- application/pkcs7-signature
-
- application/vnd.powerbuilder6
- image/x-portable-bitmap
- application/vnd.hp-pcl
- application/vnd.hp-pclxl
- image/x-pict
- image/x-pcx
- chemical/x-pdb
- application/pdf
- application/font-tdpfr
-
- image/x-portable-graymap
- application/x-chess-pgn
- application/pgp-encrypted
- image/x-pict
- application/pkixcmp
- application/pkix-pkipath
- application/vnd.3gpp.pic-bw-large
- application/vnd.mobius.plc
- application/vnd.pocketlearn
-
- application/pls+xml
- application/vnd.ctc-posml
- image/png
- image/x-portable-anymap
- application/vnd.macports.portpkg
- application/vnd.ms-powerpoint
- application/vnd.cups-ppd
- image/x-portable-pixmap
- application/vnd.ms-powerpoint
-
- application/vnd.ms-powerpoint
- application/vnd.palm
- application/vnd.palm
- application/vnd.lotus-freelance
- application/pics-rules
- application/postscript
- application/vnd.3gpp.pic-bw-small
- image/vnd.adobe.photoshop
- application/vnd.pvi.ptid1
-
- application/x-mspublisher
- application/vnd.3gpp.pic-bw-var
- application/vnd.3m.post-it-notes
- application/vnd.epson.quickanime
- application/vnd.intu.qbo
- application/vnd.intu.qfx
- application/vnd.publishare-delta-tree
- video/quicktime
- audio/x-pn-realaudio
-
- audio/x-pn-realaudio
- application/x-rar-compressed
- image/x-cmu-raster
- application/vnd.ipunplugged.rcprofile
- application/rdf+xml
- application/vnd.data-vision.rdz
- application/vnd.businessobjects
- image/x-rgb
- application/reginfo+xml
-
- application/resource-lists+xml
- image/vnd.fujixerox.edmics-rlc
- application/vnd.rn-realmedia
- audio/midi
- audio/x-pn-realaudio-plugin
- application/vnd.jcp.javame.midlet-rms
- application/relax-ng-compact-syntax
- application/vnd.nokia.radio-presets
- application/vnd.nokia.radio-preset
-
- application/sparql-query
- application/rls-services+xml
- application/rsd+xml
- application/rss+xml
- application/rtf
- text/richtext
- application/vnd.yamaha.smaf-audio
- application/sbml+xml
- application/vnd.ibm.secure-container
-
- application/x-msschedule
- application/vnd.lotus-screencam
- application/scvp-cv-request
- application/scvp-cv-response
- application/sdp
- application/vnd.seemail
- application/vnd.sema
- application/vnd.semd
- application/vnd.semf
-
- application/set-payment-initiation
- application/set-registration-initiation
- application/vnd.spotfire.sfs
- text/sgml
- text/sgml
- application/x-sh
- application/x-shar
- application/shf+xml
- model/mesh
-
- application/x-stuffit
- application/x-stuffitx
- application/vnd.epson.salt
- audio/basic
- application/vnd.yamaha.smaf-phrase
- application/x-futuresplash
- text/vnd.in3d.spot
- application/scvp-vp-response
- application/scvp-vp-request
-
- application/x-wais-source
- application/sparql-results+xml
- application/vnd.epson.ssf
- application/ssml+xml
- application/vnd.wt.stf
- application/hyperstudio
- application/vnd.pg.format
- application/vnd.sus-calendar
- application/vnd.sus-calendar
-
- application/x-sv4cpio
- application/x-sv4crc
- application/vnd.svd
- application/x-shockwave-flash
- application/vnd.tao.intent-module-archive
- application/x-tar
- application/vnd.3gpp2.tcap
- application/x-tcl
- application/x-tex
-
- text/plain
- image/tiff
- image/tiff
- application/vnd.tmobile-livetv
- application/x-bittorrent
- application/vnd.groove-tool-template
- application/vnd.trid.tpt
- application/vnd.trueapp
- application/x-msterminal
-
- text/tab-separated-values
- application/vnd.genomatix.tuxedo
- application/vnd.mobius.txf
- text/plain
- application/vnd.umajin
- application/vnd.unity
- application/vnd.uoml+xml
- text/uri-list
- text/uri-list
-
- text/uri-list
- application/x-ustar
- application/vnd.uiq.theme
- text/x-uuencode
- application/x-cdlink
- text/x-vcard
- application/vnd.groove-vcard
- text/x-vcalendar
- application/vnd.vcx
-
- application/vnd.visionary
- video/vnd.vivo
- model/vrml
- application/vnd.visio
- application/vnd.vsf
- application/vnd.visio
- application/vnd.visio
- application/vnd.visio
- model/vnd.vtu
-
- application/voicexml+xml
- audio/x-wav
- audio/x-ms-wax
- image/vnd.wap.wbmp
- application/vnd.criticaltools.wbs+xml
- application/vnd.wap.wbxml
- application/vnd.ms-works
- application/vnd.ms-works
- application/vnd.ms-works
-
- video/x-ms-wm
- audio/x-ms-wma
- application/x-ms-wmd
- application/x-msmetafile
- text/vnd.wap.wml
- application/vnd.wap.wmlc
- text/vnd.wap.wmlscript
- application/vnd.wap.wmlscriptc
- video/x-ms-wmv
-
- video/x-ms-wmx
- application/x-ms-wmz
- application/vnd.wordperfect
- application/vnd.ms-wpl
- application/vnd.ms-works
- application/vnd.wqd
- application/x-mswrite
- model/vrml
- application/wsdl+xml
-
- application/wspolicy+xml
- application/vnd.webturbo
- video/x-ms-wvx
- application/vnd.hzn-3d-crossword
- application/vnd.xara
- application/vnd.fujixerox.docuworks.binder
- image/x-xbitmap
- application/vnd.syncml.dm+xml
- application/vnd.adobe.xdp+xml
-
- application/vnd.fujixerox.docuworks
- application/xenc+xml
- application/vnd.adobe.xfdf
- application/vnd.xfdl
- application/xhtml+xml
- application/xhtml+xml
- application/xv+xml
- image/vnd.xiff
- application/vnd.ms-excel
-
- application/vnd.ms-excel
- application/vnd.ms-excel
- application/vnd.ms-excel
- application/vnd.ms-excel
- application/vnd.ms-excel
- application/xml
- application/vnd.olpc-sugar
- application/xop+xml
- image/x-xpixmap
-
- application/vnd.is-xpr
- application/vnd.ms-xpsdocument
- application/xml
- application/xslt+xml
- application/vnd.syncml+xml
- application/xspf+xml
- application/vnd.mozilla.xul+xml
- application/xv+xml
- application/xv+xml
-
- image/x-xwindowdump
- chemical/x-xyz
- application/vnd.zzazz.deck+xml
- application/zip
- application/vnd.handheld-entertainment+xml
-
-
@@ -770,25 +159,6 @@
-
-
-
-
-
-
-
-
-
- Downloadable product Section
-
-
-
-
-
-
-
-
-
@@ -809,7 +179,6 @@
- singleton
downloadable/observer
prepareProductSave
@@ -818,7 +187,6 @@
- singleton
downloadable/observer
saveDownloadableOrderItem
@@ -827,7 +195,6 @@
- singleton
downloadable/observer
setLinkStatus
@@ -868,7 +235,6 @@
- singleton
downloadable/observer
saveDownloadableOrderItem
@@ -877,7 +243,6 @@
- singleton
downloadable/observer
setLinkStatus
@@ -886,7 +251,6 @@
- singleton
downloadable/observer
setHasDownloadableProducts
@@ -895,7 +259,6 @@
- singleton
downloadable/observer
setHasDownloadableProducts
@@ -904,7 +267,6 @@
- singleton
downloadable/observer
isAllowedGuestCheckout
diff --git a/app/code/core/Mage/Eav/Helper/Data.php b/app/code/core/Mage/Eav/Helper/Data.php
index 2884d86245..7d810148b9 100644
--- a/app/code/core/Mage/Eav/Helper/Data.php
+++ b/app/code/core/Mage/Eav/Helper/Data.php
@@ -29,5 +29,103 @@
*/
class Mage_Eav_Helper_Data extends Mage_Core_Helper_Abstract
{
+ protected $_attributesLockedFields = array();
+ protected $_entityTypeFrontendClasses = array();
+
+ /**
+ * Return default frontend classes value labal array
+ *
+ * @return array
+ */
+ protected function _getDefaultFrontendClasses()
+ {
+ return array(
+ array(
+ 'value' => '',
+ 'label' => Mage::helper('eav')->__('None')
+ ),
+ array(
+ 'value' => 'validate-number',
+ 'label' => Mage::helper('eav')->__('Decimal Number')
+ ),
+ array(
+ 'value' => 'validate-digits',
+ 'label' => Mage::helper('eav')->__('Integer Number')
+ ),
+ array(
+ 'value' => 'validate-email',
+ 'label' => Mage::helper('eav')->__('Email')
+ ),
+ array(
+ 'value' => 'validate-url',
+ 'label' => Mage::helper('eav')->__('Url')
+ ),
+ array(
+ 'value' => 'validate-alpha',
+ 'label' => Mage::helper('eav')->__('Letters')
+ ),
+ array(
+ 'value' => 'validate-alphanum',
+ 'label' => Mage::helper('eav')->__('Letters(a-zA-Z) or Numbers(0-9)')
+ )
+ );
+ }
+
+ /**
+ * Return merged default and entity type frontend classes value label array
+ *
+ * @param string $entityTypeCode
+ * @return array
+ */
+ public function getFrontendClasses($entityTypeCode)
+ {
+ $_defaultClasses = $this->_getDefaultFrontendClasses();
+ if (isset($this->_entityTypeFrontendClasses[$entityTypeCode])) {
+ return array_merge(
+ $_defaultClasses,
+ $this->_entityTypeFrontendClasses[$entityTypeCode]
+ );
+ }
+ $_entityTypeClasses = Mage::app()->getConfig()
+ ->getNode('global/eav_frontendclasses/' . $entityTypeCode);
+ if ($_entityTypeClasses) {
+ foreach ($_entityTypeClasses->children() as $item) {
+ $this->_entityTypeFrontendClasses[$entityTypeCode][] = array(
+ 'value' => (string)$item->value,
+ 'label' => (string)$item->label
+ );
+ }
+ return array_merge(
+ $_defaultClasses,
+ $this->_entityTypeFrontendClasses[$entityTypeCode]
+ );
+ }
+ return $_defaultClasses;
+ }
+
+ /**
+ * Retrieve attributes locked fields to edit
+ *
+ * @param string $entityTypeCode
+ * @return array
+ */
+ public function getAttributeLockedFields($entityTypeCode)
+ {
+ if (!$entityTypeCode) {
+ return array();
+ }
+ if (isset($this->_attributesLockedFields[$entityTypeCode])) {
+ return $this->_attributesLockedFields[$entityTypeCode];
+ }
+ $lockedAttributeFields = array();
+ $_data = Mage::app()->getConfig()->getNode('global/eav_attributes/' . $entityTypeCode);
+ if ($_data) {
+ foreach ($_data->children() as $attribute) {
+ $this->_attributesLockedFields[$entityTypeCode][(string)$attribute->code] = array_keys($attribute->locked_fields->asArray());
+ }
+ return $this->_attributesLockedFields[$entityTypeCode];
+ }
+ return array();
+ }
}
diff --git a/app/code/core/Mage/Eav/Model/Config.php b/app/code/core/Mage/Eav/Model/Config.php
index 72a3a3f877..29bd286177 100644
--- a/app/code/core/Mage/Eav/Model/Config.php
+++ b/app/code/core/Mage/Eav/Model/Config.php
@@ -454,6 +454,10 @@ public function getEntityAttributeCodes($entityType, $object=null)
if (($object instanceof Varien_Object) && $object->getAttributeSetId()) {
$attributeSetId = $object->getAttributeSetId();
}
+ $storeId = 0;
+ if (($object instanceof Varien_Object) && $object->getStoreId()) {
+ $storeId = $object->getStoreId();
+ }
$cacheKey = sprintf('%d-%d', $entityType->getId(), $attributeSetId);
if (isset($this->_attributeCodes[$cacheKey])) {
return $this->_attributeCodes[$cacheKey];
@@ -465,6 +469,7 @@ public function getEntityAttributeCodes($entityType, $object=null)
->setEntityTypeFilter($entityType->getId())
->setAttributeSetFilter($attributeSetId)
// ->addSetInfo()
+ ->addStoreLabel($storeId)
->getData();
$attributes = array();
foreach ($attributesInfo as $attributeData) {
@@ -601,8 +606,8 @@ public function loadCollectionAttributes($entityType, $attributes)
if (empty($attributes)) {
return $this;
}
-
- $attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')
+ $attributeCollection = $entityType->getEntityAttributeCollection();
+ $attributesInfo = Mage::getResourceModel($attributeCollection)
->useLoadDataFields()
->setEntityTypeFilter($entityType->getId())
->setCodeFilter($attributes)
diff --git a/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php b/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php
index 82c0614f5b..f8a9c96126 100644
--- a/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php
+++ b/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php
@@ -164,8 +164,8 @@ public function setFilter($attrFilterArray, $attrToDb = null, $bind = null, $joi
case 'datetimeFromTo':
$attr = array(
'attribute' => $keyDB,
- 'from' => $val['from'],
- 'to' => $val['to'],
+ 'from' => isset($val['from']) ? $val['from'] : null,
+ 'to' => isset($val['to']) ? $val['to'] : null,
'datetime' => true
);
break;
diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php
index 90d0c14532..366358a26c 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php
@@ -320,7 +320,7 @@ public function unsetAttributes($attributes=null)
* If attribute is not found false is returned
*
* @param string|integer|Mage_Core_Model_Config_Element $attribute
- * @return Mage_Eav_Model_Entity_Attribute_Abstract
+ * @return Mage_Eav_Model_Entity_Attribute_Abstract || false
*/
public function getAttribute($attribute)
{
@@ -928,6 +928,12 @@ public function save(Varien_Object $object)
return $this;
}
+ /**
+ * Retrieve Object instance with original data
+ *
+ * @param Varien_Object $object
+ * @return Varien_Object
+ */
protected function _getOrigObject($object)
{
$className = get_class($object);
@@ -950,37 +956,53 @@ protected function _getOrigObject($object)
*/
protected function _collectSaveData($newObject)
{
- $newData = $newObject->getData();
- $entityId = $newObject->getData($this->getEntityIdField());
+ $newData = $newObject->getData();
+ $entityId = $newObject->getData($this->getEntityIdField());
+
+ // define result data
+ $entityRow = array();
+ $insert = array();
+ $update = array();
+ $delete = array();
+
if (!empty($entityId)) {
+ $origData = $newObject->getOrigData();
/**
- * get current data in db for this entity
+ * get current data in db for this entity if original data is empty
*/
- /*$className = get_class($newObject);
- $origObject = new $className();
- $origObject->setData(array());
- $this->load($origObject, $entityId);
- $origData = $origObject->getOrigData();*/
- $origData = $this->_getOrigObject($newObject)->getOrigData();
+ if (empty($origData)) {
+ $origData = $this->_getOrigObject($newObject)->getOrigData();
+ }
/**
* drop attributes that are unknown in new data
* not needed after introduction of partial entity loading
*/
- foreach ($origData as $k=>$v) {
+ foreach ($origData as $k => $v) {
if (!array_key_exists($k, $newData)) {
unset($origData[$k]);
}
}
+ } else {
+ $origData = array();
}
- foreach ($newData as $k=>$v) {
+ $staticFields = $this->_getWriteAdapter()->describeTable($this->getEntityTable());
+ $staticFields = array_keys($staticFields);
+ $attributeCodes = array_keys($this->_attributesByCode);
+
+ foreach ($newData as $k => $v) {
/**
* Check attribute information
*/
if (is_numeric($k) || is_array($v)) {
continue;
- throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid data object key'));
+ }
+ /**
+ * Check if data key is presented in static fields or attribute codes
+ */
+ if (!in_array($k, $staticFields) && !in_array($k, $attributeCodes)) {
+ continue;
}
$attribute = $this->getAttribute($k);
@@ -1001,21 +1023,19 @@ protected function _collectSaveData($newObject)
/**
* Check comparability for attribute value
*/
- if (isset($origData[$k])) {
- if ($attribute->isValueEmpty($v)) {
+ if (array_key_exists($k, $origData)) {
+ if ($this->_isAttributeValueEmpty($attribute, $v)) {
$delete[$attribute->getBackend()->getTable()][] = array(
'attribute_id' => $attrId,
'value_id' => $attribute->getBackend()->getValueId()
);
- }
- elseif ($v!==$origData[$k]) {
+ } else if ($v !== $origData[$k]) {
$update[$attrId] = array(
'value_id' => $attribute->getBackend()->getValueId(),
'value' => $v,
);
}
- }
- elseif (!$attribute->isValueEmpty($v)) {
+ } else if (!$this->_isAttributeValueEmpty($attribute, $v)) {
$insert[$attrId] = $v;
}
}
@@ -1103,7 +1123,7 @@ protected function _processSaveData($saveData)
* insert attribute values
*/
if (!empty($insert)) {
- foreach ($insert as $attrId=>$value) {
+ foreach ($insert as $attrId => $value) {
$attribute = $this->getAttribute($attrId);
$this->_insertAttribute($newObject, $attribute, $value);
}
@@ -1113,7 +1133,7 @@ protected function _processSaveData($saveData)
* update attribute values
*/
if (!empty($update)) {
- foreach ($update as $attrId=>$v) {
+ foreach ($update as $attrId => $v) {
$attribute = $this->getAttribute($attrId);
$this->_updateAttribute($newObject, $attribute, $v['value_id'], $v['value']);
}
@@ -1123,7 +1143,7 @@ protected function _processSaveData($saveData)
* delete empty attribute values
*/
if (!empty($delete)) {
- foreach ($delete as $table=>$values) {
+ foreach ($delete as $table => $values) {
$this->_deleteAttributes($newObject, $table, $values);
}
}
@@ -1399,4 +1419,16 @@ protected function _afterSetConfig()
// Varien_Profiler::stop(__METHOD__);
// return $this;
}
+
+ /**
+ * Check is attribute value empty
+ *
+ * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
+ * @param mixed $value
+ * @return bool
+ */
+ protected function _isAttributeValueEmpty(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $value)
+ {
+ return $attribute->isValueEmpty($value);
+ }
}
diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Entity/Attribute.php
index 16768b743f..da6bc61177 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Attribute.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Attribute.php
@@ -101,17 +101,6 @@ protected function _beforeSave()
Mage::throwException(Mage::helper('eav')->__('The attribute code \'%s\' is reserved by system. Please, try another attribute code.', $this->_data['attribute_code']));
}
- // prevent changing attribute scope, if used in configurable products
- if (isset($this->_origData['is_global'])) {
- if (!isset($this->_data['is_global'])) {
- Mage::throwException('0_o');
- }
- if (($this->_data['is_global'] != $this->_origData['is_global'])
- && $this->_getResource()->isUsedBySuperProducts($this)) {
- Mage::throwException(Mage::helper('eav')->__('Scope must not be changed, because the attribute is used in configurable products.'));
- }
- }
-
if ($this->getBackendType() == 'datetime') {
if (!$this->getBackendModel()) {
$this->setBackendModel('eav/entity_attribute_backend_datetime');
@@ -139,12 +128,6 @@ protected function _beforeSave()
}
}
- if ($this->getFrontendInput() == 'price') {
- if (!$this->getBackendModel()) {
- $this->setBackendModel('catalog/product_attribute_backend_price');
- }
- }
-
return parent::_beforeSave();
}
@@ -252,4 +235,27 @@ public function getAttributeCodesByFrontendType($type)
{
return $this->getResource()->getAttributeCodesByFrontendType($type);
}
+
+ /**
+ * Return array of labels of stores
+ *
+ * @return array
+ */
+ public function getStoreLabels()
+ {
+ if (!$this->getData('store_labels')) {
+ $this->setData('store_labels', $this->getResource()->getStoreLabelsByAttributeId($this->getId()));
+ }
+ return $this->getData('store_labels');
+ }
+
+ /**
+ * Return store label of attribute
+ *
+ * @return string
+ */
+ public function getStoreLabel()
+ {
+ return $this->getData('store_label');
+ }
}
diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php
index 70f1933893..f429f4ef2d 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php
@@ -246,6 +246,12 @@ public function setEntityType($type)
return $this;
}
+ /**
+ * Return is attribute global
+ *
+ * @deprecated moved to catalog attribute model
+ * @return integer
+ */
public function getIsGlobal()
{
return $this->_getData('is_global');
diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Datetime.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Datetime.php
index ce1eaef02d..c3e54141a0 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Datetime.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Datetime.php
@@ -28,15 +28,16 @@ class Mage_Eav_Model_Entity_Attribute_Backend_Datetime extends Mage_Eav_Model_En
{
public function beforeSave($object)
{
- $_formated = $object->getData($this->getAttribute()->getName() . '_is_formated');
- if (!$_formated) {
+ $attributeName = $this->getAttribute()->getName();
+ $_formated = $object->getData($attributeName . '_is_formated');
+ if (!$_formated && $object->hasData($attributeName)) {
try {
- $value = $this->formatDate($object->getData($this->getAttribute()->getName()));
+ $value = $this->formatDate($object->getData($attributeName));
} catch (Exception $e) {
throw new Exception("Invalid date.");
}
- $object->setData($this->getAttribute()->getName(), $value);
- $object->setData($this->getAttribute()->getName() . '_is_formated', true);
+ $object->setData($attributeName, $value);
+ $object->setData($attributeName . '_is_formated', true);
}
}
diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Table.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Table.php
index a7f7f19c1d..ab7a60ec3e 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Table.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Table.php
@@ -127,7 +127,7 @@ public function addValueSortToCollection($collection, $dir = 'asc')
. " AND `{$valueTable2}`.`store_id`='{$collection->getStoreId()}'",
array()
);
- $valueExpr = new Zend_Db_Expr("IFNULL(`{$valueTable2}`.`value`, `{$valueTable1}`.`value`)");
+ $valueExpr = new Zend_Db_Expr("IF(`{$valueTable2}`.`value_id`>0, `{$valueTable2}`.`value`, `{$valueTable1}`.`value`)");
Mage::getResourceModel('eav/entity_attribute_option')
->addOptionValueToCollection($collection, $this->getAttribute(), $valueExpr);
diff --git a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php
index d07c367406..3ad7d268d3 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php
@@ -24,7 +24,6 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-
/**
* Entity/Attribute/Model - collection abstract
*
@@ -811,11 +810,11 @@ public function load($printQuery = false, $logQuery = false)
}
/**
- * Retrive all ids for collection
+ * Clone and reset collection
*
- * @return array
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
*/
- public function getAllIds($limit=null, $offset=null)
+ protected function _getAllIdsSelect($limit=null, $offset=null)
{
$idsSelect = clone $this->getSelect();
$idsSelect->reset(Zend_Db_Select::ORDER);
@@ -824,7 +823,17 @@ public function getAllIds($limit=null, $offset=null)
$idsSelect->reset(Zend_Db_Select::COLUMNS);
$idsSelect->from(null, 'e.'.$this->getEntity()->getIdFieldName());
$idsSelect->limit($limit, $offset);
- return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams);
+ return $idsSelect;
+ }
+
+ /**
+ * Retrive all ids for collection
+ *
+ * @return array
+ */
+ public function getAllIds($limit=null, $offset=null)
+ {
+ return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
}
/**
diff --git a/app/code/core/Mage/Eav/Model/Entity/Setup.php b/app/code/core/Mage/Eav/Model/Entity/Setup.php
index 26217ff49b..206cec2313 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Setup.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Setup.php
@@ -92,12 +92,14 @@ public function installDefaultGroupIds()
public function addEntityType($code, array $params)
{
$data = array(
- 'entity_type_code' => $code,
- 'entity_model' => $params['entity_model'],
- 'attribute_model' => isset($params['attribute_model']) ? $params['attribute_model'] : '',
- 'entity_table' => isset($params['table']) ? $params['table'] : 'eav/entity',
- 'increment_model' => isset($params['increment_model']) ? $params['increment_model'] : '',
- 'increment_per_store' => isset($params['increment_per_store']) ? $params['increment_per_store'] : 0,
+ 'entity_type_code' => $code,
+ 'entity_model' => $params['entity_model'],
+ 'attribute_model' => isset($params['attribute_model']) ? $params['attribute_model'] : '',
+ 'entity_table' => isset($params['table']) ? $params['table'] : 'eav/entity',
+ 'increment_model' => isset($params['increment_model']) ? $params['increment_model'] : '',
+ 'increment_per_store' => isset($params['increment_per_store']) ? $params['increment_per_store'] : 0,
+ 'additional_attribute_table' => isset($params['additional_attribute_table']) ? $params['additional_attribute_table'] : '',
+ 'entity_attribute_collection'=> isset($params['entity_attribute_collection']) ? $params['entity_attribute_collection'] : '',
);
if ($this->getEntityType($code, 'entity_type_id')) {
@@ -518,55 +520,54 @@ protected function _getValue($array, $key, $default = null)
}
/**
- * Add attribute to an entity type
- *
- * If attribute is system will add to all existing attribute sets
+ * Prepare attribute values to save
*
- * @param string|integer $entityTypeId
- * @param string $code
* @param array $attr
- * @return Mage_Eav_Model_Entity_Setup
+ * @return array
*/
- public function addAttribute($entityTypeId, $code, array $attr)
+ protected function _prepareValues($attr)
{
- $entityTypeId = $this->getEntityTypeId($entityTypeId);
+ $data = array();
$data = array(
- 'entity_type_id' => $entityTypeId,
- 'attribute_code' => $code,
'backend_model' => $this->_getValue($attr, 'backend', ''),
'backend_type' => $this->_getValue($attr, 'type', 'varchar'),
'backend_table' => $this->_getValue($attr, 'table', ''),
'frontend_model' => $this->_getValue($attr, 'frontend', ''),
'frontend_input' => $this->_getValue($attr, 'input', 'text'),
- 'frontend_input_renderer' => $this->_getValue($attr, 'input_renderer', ''),
'frontend_label' => $this->_getValue($attr, 'label', ''),
'frontend_class' => $this->_getValue($attr, 'frontend_class', ''),
'source_model' => $this->_getValue($attr, 'source', ''),
- 'is_global' => $this->_getValue($attr, 'global', 1),
- 'is_visible' => $this->_getValue($attr, 'visible', 1),
'is_required' => $this->_getValue($attr, 'required', 1),
'is_user_defined' => $this->_getValue($attr, 'user_defined', 0),
'default_value' => $this->_getValue($attr, 'default', ''),
- 'is_searchable' => $this->_getValue($attr, 'searchable', 0),
- 'is_filterable' => $this->_getValue($attr, 'filterable', 0),
- 'is_comparable' => $this->_getValue($attr, 'comparable', 0),
- 'is_visible_on_front' => $this->_getValue($attr, 'visible_on_front', 0),
- 'is_html_allowed_on_front' => $this->_getValue($attr, 'is_html_allowed_on_front', 0),
- 'is_visible_in_advanced_search'
- => $this->_getValue($attr, 'visible_in_advanced_search', 0),
- 'is_used_for_price_rules' => $this->_getValue($attr, 'used_for_price_rules', 1),
- 'is_filterable_in_search' => $this->_getValue($attr, 'filterable_in_search', 0),
- 'used_in_product_listing' => $this->_getValue($attr, 'used_in_product_listing', 0),
- 'used_for_sort_by' => $this->_getValue($attr, 'used_for_sort_by', 0),
'is_unique' => $this->_getValue($attr, 'unique', 0),
- 'apply_to' => $this->_getValue($attr, 'apply_to', ''),
- 'is_configurable' => $this->_getValue($attr, 'is_configurable', 1),
'note' => $this->_getValue($attr, 'note', ''),
- 'position' => $this->_getValue($attr, 'position', 0),
);
+ return $data;
+ }
- $sortOrder = isset($attr['sort_order']) ? $attr['sort_order'] : null;
+ /**
+ * Add attribute to an entity type
+ *
+ * If attribute is system will add to all existing attribute sets
+ *
+ * @param string|integer $entityTypeId
+ * @param string $code
+ * @param array $attr
+ * @return Mage_Eav_Model_Entity_Setup
+ */
+ public function addAttribute($entityTypeId, $code, array $attr)
+ {
+ $entityTypeId = $this->getEntityTypeId($entityTypeId);
+ $data = array_merge(
+ array(
+ 'entity_type_id' => $entityTypeId,
+ 'attribute_code' => $code
+ ),
+ $this->_prepareValues($attr)
+ );
+ $sortOrder = isset($attr['sort_order']) ? $attr['sort_order'] : null;
if ($id = $this->getAttribute($entityTypeId, $code, 'attribute_id')) {
$this->updateAttribute($entityTypeId, $id, $data, null, $sortOrder);
} else {
@@ -580,7 +581,7 @@ public function addAttribute($entityTypeId, $code, array $attr)
$this->addAttributeToSet($entityTypeId, $set['attribute_set_id'], $attr['group'], $code, $sortOrder);
}
}
- if (empty($attr['is_user_defined'])) {
+ if (empty($attr['user_defined'])) {
$sets = $this->_conn->fetchAll('select * from '.$this->getTable('eav/attribute_set').' where entity_type_id=?', $entityTypeId);
foreach ($sets as $set) {
$this->addAttributeToSet($entityTypeId, $set['attribute_set_id'], $this->_generalGroupName, $code, $sortOrder);
@@ -612,7 +613,7 @@ public function addAttributeOption($option)
if (!empty($option['delete'][$optionId])) {
if ($intOptionId) {
$condition = $this->_conn->quoteInto('option_id=?', $intOptionId);
- $write->delete($optionTable, $condition);
+ $this->_conn->delete($optionTable, $condition);
}
continue;
}
@@ -650,7 +651,7 @@ public function addAttributeOption($option)
}
/**
- * Update Attribute data
+ * Update Attribute data and Attribute additional data
*
* @param mixed $entityTypeId
* @param mixed $id
@@ -660,6 +661,23 @@ public function addAttributeOption($option)
* @return Mage_Eav_Model_Entity_Setup
*/
public function updateAttribute($entityTypeId, $id, $field, $value=null, $sortOrder=null)
+ {
+ $this->_updateAttribute($entityTypeId, $id, $field, $value, $sortOrder);
+ $this->_updateAttributeAdditionalData($entityTypeId, $id, $field, $value);
+ return $this;
+ }
+
+ /**
+ * Update Attribute data
+ *
+ * @param mixed $entityTypeId
+ * @param mixed $id
+ * @param string $field
+ * @param mixed $value
+ * @param int $sortOrder
+ * @return Mage_Eav_Model_Entity_Setup
+ */
+ protected function _updateAttribute($entityTypeId, $id, $field, $value=null, $sortOrder=null)
{
if (!is_null($sortOrder)) {
$this->updateTableRow('eav/entity_attribute',
@@ -695,6 +713,49 @@ public function updateAttribute($entityTypeId, $id, $field, $value=null, $sortOr
return $this;
}
+ /**
+ * Update Attribute Additional data
+ *
+ * @param mixed $entityTypeId
+ * @param mixed $id
+ * @param string $field
+ * @param mixed $value
+ * @return Mage_Eav_Model_Entity_Setup
+ */
+ protected function _updateAttributeAdditionalData($entityTypeId, $id, $field, $value=null)
+ {
+ $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table');
+ if (!$additionalTable) {
+ return $this;
+ }
+ $additionalTableExists = $this->getConnection()->showTableStatus($this->getTable($additionalTable));
+ if ($additionalTable && $additionalTableExists) {
+ $attributeFields = $this->getConnection()->describeTable($this->getTable($additionalTable));
+ if (is_array($field)) {
+ $bind = array();
+ foreach ($field as $k => $v) {
+ if (isset($attributeFields[$k])) {
+ $bind[$k] = $v;
+ }
+ }
+ if (!$bind) {
+ return $this;
+ }
+ $field = $bind;
+ }
+ else {
+ if (!isset($attributeFields[$field])) {
+ return $this;
+ }
+ }
+ $this->updateTableRow($this->getTable($additionalTable),
+ 'attribute_id', $this->getAttributeId($entityTypeId, $id),
+ $field, $value
+ );
+ }
+ return $this;
+ }
+
/**
* Retrieve Attribute Data By Id or Code
*
@@ -705,11 +766,40 @@ public function updateAttribute($entityTypeId, $id, $field, $value=null, $sortOr
*/
public function getAttribute($entityTypeId, $id, $field=null)
{
- return $this->getTableRow('eav/attribute',
- is_numeric($id) ? 'attribute_id' : 'attribute_code', $id,
- $field,
- 'entity_type_id', $this->getEntityTypeId($entityTypeId)
- );
+ $joinTable = $this->getEntityType($entityTypeId, 'additional_attribute_table');
+ if (!$joinTable) {
+ return $this->getTableRow('eav/attribute',
+ is_numeric($id) ? 'attribute_id' : 'attribute_code', $id,
+ $field,
+ 'entity_type_id', $this->getEntityTypeId($entityTypeId)
+ );
+ }
+ $mainTable = $this->getTable('eav/attribute');
+ $joinTable = $this->getTable($joinTable);
+ $parentId = $this->getEntityTypeId($entityTypeId);
+ $idField = (is_numeric($id) ? 'attribute_id' : 'attribute_code');
+ $table = $mainTable . '-' . $joinTable;
+ if (empty($this->_setupCache[$table][$parentId][$id])) {
+ $sql = "select
+ $mainTable.*,
+ $joinTable.*
+ from
+ $mainTable
+ inner join $joinTable on $joinTable.attribute_id=$mainTable.attribute_id
+ where
+ $mainTable.$idField = :idField
+ and $mainTable.entity_type_id = :parentId";
+ $bind = array(
+ 'idField' => $id,
+ 'parentId' => $parentId
+ );
+ $this->_setupCache[$mainTable][$parentId][$id] = $this->_conn->fetchRow($sql, $bind);
+ $this->_conn->fetchAll($sql, $bind);
+ }
+ if (is_null($field)) {
+ return $this->_setupCache[$mainTable][$parentId][$id];
+ }
+ return isset($this->_setupCache[$mainTable][$parentId][$id][$field]) ? $this->_setupCache[$mainTable][$parentId][$id][$field] : false;
}
/**
@@ -775,8 +865,17 @@ public function getAttributeTable($entityTypeId, $id)
public function removeAttribute($entityTypeId, $code)
{
$attributeId = $this->getAttributeId($entityTypeId, $code);
+ $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table');
if ($attributeId) {
$this->deleteTableRow('eav/attribute', 'attribute_id', $attributeId);
+ if ($additionalTable) {
+ $additionalTable = $this->getTable($additionalTable);
+ $condition = $this->_conn->quoteInto("attribute_id=?", $attributeId);
+ $this->_conn->delete($additionalTable, $condition);
+ if (isset($this->_setupCache[$table.'-'.$additionalTable][0][$attributeId])) {
+ unset($this->_setupCache[$table][0][$attributeId]);
+ }
+ }
}
return $this;
}
@@ -1054,6 +1153,7 @@ protected function _getAttributeTableFields() {
*/
protected function _insertAttribute(array $data) {
$bind = array();
+
$fields = $this->_getAttributeTableFields();
foreach ($data as $k => $v) {
@@ -1066,7 +1166,40 @@ protected function _insertAttribute(array $data) {
}
$this->getConnection()->insert($this->getTable('eav/attribute'), $bind);
+ $attributeId = $this->getConnection()->lastInsertId();
+ $this->_insertAttributeAdditionalData(
+ $data['entity_type_id'],
+ array_merge(array('attribute_id' => $attributeId), $data)
+ );
+ return $this;
+ }
+ /**
+ * Insert attribute additional data
+ *
+ * @param array $data
+ * @return Mage_Eav_Model_Entity_Setup
+ */
+ protected function _insertAttributeAdditionalData($entityTypeId, array $data)
+ {
+ $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table');
+ if (!$additionalTable) {
+ return $this;
+ }
+ $additionalTableExists = $this->getConnection()->showTableStatus($this->getTable($additionalTable));
+ if ($additionalTable && $additionalTableExists) {
+ $bind = array();
+ $fields = $this->getConnection()->describeTable($this->getTable($additionalTable));
+ foreach ($data as $k => $v) {
+ if (isset($fields[$k])) {
+ $bind[$k] = $v;
+ }
+ }
+ if (!$bind) {
+ return $this;
+ }
+ $this->getConnection()->insert($this->getTable($additionalTable), $bind);
+ }
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Eav/Model/Entity/Type.php b/app/code/core/Mage/Eav/Model/Entity/Type.php
index 37f4439837..7d085c82b7 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Type.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Type.php
@@ -273,4 +273,17 @@ public function getEntity()
{
return Mage::getResourceSingleton($this->_data['entity_model']);
}
+
+ /**
+ * Return attribute collection. If not specify return default
+ *
+ * @return string
+ */
+ public function getEntityAttributeCollection()
+ {
+ if ($collection = $this->_getData('entity_attribute_collection')) {
+ return $collection;
+ }
+ return 'eav/entity_attribute_collection';
+ }
}
diff --git a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute.php
index 2c54c658a8..f26893fe22 100644
--- a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute.php
+++ b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute.php
@@ -169,23 +169,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object)
Mage::throwException(Mage::helper('eav')->__('Frontend label is not defined'));
}
$object->setFrontendLabel($frontendLabel[0]);
-
- if ($object->getData('modulePrefix')) {
- $str = $object->getData('modulePrefix') . Mage_Core_Model_Translate::SCOPE_SEPARATOR . $frontendLabel[0];
- }
- else {
- $str = $frontendLabel[0];
- }
- Mage::getModel('core/translate_string')
- ->setString($str)
- ->setTranslate($frontendLabel[0])
- ->setStoreTranslations($frontendLabel)
- ->save();
- }
- $applyTo = $object->getApplyTo();
-
- if (is_array($applyTo)) {
- $object->setApplyTo(implode(',', $applyTo));
+ $object->setStoreLabels($frontendLabel);
}
/**
@@ -208,11 +192,76 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object)
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
- $this->saveInSetIncluding($object)
+ $this->_saveStoreLabels($object)
+ ->_saveAdditionalAttributeData($object)
+ ->saveInSetIncluding($object)
->_saveOption($object);
return parent::_afterSave($object);
}
+ /**
+ * Save store labels
+ *
+ * @param Mage_Core_Model_Abstract $object
+ * @return Mage_Eav_Model_Mysql4_Entity_Attribute
+ */
+ protected function _saveStoreLabels(Mage_Core_Model_Abstract $object)
+ {
+ $storeLabels = $object->getStoreLabels();
+ if (is_array($storeLabels)) {
+ if ($object->getId()) {
+ $condition = $this->_getWriteAdapter()->quoteInto('attribute_id = ?', $object->getId());
+ $this->_getWriteAdapter()->delete($this->getTable('eav/attribute_label'), $condition);
+ }
+ foreach ($storeLabels as $storeId => $label) {
+ if ($storeId == 0 || !strlen($label)) {
+ continue;
+ }
+ $this->_getWriteAdapter()->insert(
+ $this->getTable('eav/attribute_label'),
+ array(
+ 'attribute_id' => $object->getId(),
+ 'store_id' => $storeId,
+ 'value' => $label
+ )
+ );
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Save additional data of attribute
+ *
+ * @param Mage_Core_Model_Abstract $object
+ * @return Mage_Eav_Model_Mysql4_Entity_Attribute
+ */
+ protected function _saveAdditionalAttributeData(Mage_Core_Model_Abstract $object)
+ {
+ if ($additionalTable = $this->getAdditionalAttributeTable($object->getEntityTypeId())) {
+ $describe = $this->describeTable($this->getTable($additionalTable));
+ $data = array();
+ foreach (array_keys($describe) as $field) {
+ if (null !== ($value = $object->getData($field))) {
+ $data[$field] = $value;
+ }
+ }
+ $select = $this->_getWriteAdapter()->select()
+ ->from($this->getTable($additionalTable), array('attribute_id'))
+ ->where('attribute_id = ?', $object->getId());
+ if ($this->_getWriteAdapter()->fetchOne($select)) {
+ $this->_getWriteAdapter()->update(
+ $this->getTable($additionalTable),
+ $data,
+ $this->_getWriteAdapter()->quoteInto('attribute_id = ?', $object->getId())
+ );
+ } else {
+ $this->_getWriteAdapter()->insert($this->getTable($additionalTable), $data);
+ }
+ }
+ return $this;
+ }
+
/**
* Enter description here...
*
@@ -392,7 +441,8 @@ public function getAttributeCodesByFrontendType($type)
* @param int $store
* @return Varien_Db_Select
*/
- public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store) {
+ public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store)
+ {
$joinCondition = "`e`.`entity_id`=`t1`.`entity_id`";
if ($attribute->getFlatAddChildData()) {
$joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`";
@@ -409,7 +459,7 @@ public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $at
. " AND t1.entity_type_id = t2.entity_type_id"
. " AND t1.attribute_id = t2.attribute_id"
. " AND t2.store_id = {$store}",
- array($attribute->getAttributeCode() => "IFNULL(t2.value, t1.value)"))
+ array($attribute->getAttributeCode() => "IF(t2.value_id>0, t2.value, t1.value)"))
->where("t1.entity_type_id=?", $attribute->getEntityTypeId())
->where("t1.attribute_id=?", $attribute->getId())
->where("t1.store_id=?", 0);
@@ -428,4 +478,58 @@ public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $at
public function describeTable($table) {
return $this->_getReadAdapter()->describeTable($table);
}
+
+ /**
+ * Retrieve additional attribute table name for specified entity type
+ *
+ * @param integer $entityTypeId
+ * @return string
+ */
+ public function getAdditionalAttributeTable($entityTypeId)
+ {
+ return Mage::getResourceSingleton('eav/entity_type')->getAdditionalAttributeTable($entityTypeId);
+ }
+
+ /**
+ * Load additional attribute data.
+ * Load label of current active store
+ *
+ * @param Varien_Object $object
+ * @return Mage_Eav_Model_Mysql4_Entity_Attribute
+ */
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
+ {
+ if ($entityType = $object->getData('entity_type')) {
+ $additionalTable = $entityType->getAdditionalAttributeTable();
+ } else {
+ $additionalTable = $this->getAdditionalAttributeTable($object->getEntityTypeId());
+ }
+ if ($additionalTable) {
+ $select = $this->_getReadAdapter()->select()
+ ->from($this->getTable($additionalTable))
+ ->where('attribute_id = ?', $object->getId());
+ if ($result = $this->_getReadAdapter()->fetchRow($select)) {
+ $object->addData($result);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve store labels by given attribute id
+ *
+ * @param integer $attributeId
+ * @return array
+ */
+ public function getStoreLabelsByAttributeId($attributeId)
+ {
+ $values = array();
+ $select = $this->_getReadAdapter()->select()
+ ->from($this->getTable('eav/attribute_label'))
+ ->where('attribute_id = ?', $attributeId);
+ foreach ($this->_getReadAdapter()->fetchAll($select) as $row) {
+ $values[$row['store_id']] = $row['value'];
+ }
+ return $values;
+ }
}
diff --git a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Collection.php b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Collection.php
index 064c1ab469..69007a41d7 100644
--- a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Collection.php
+++ b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Collection.php
@@ -49,14 +49,13 @@ public function _construct()
}
/**
- * Specify select columns which are used for load arrtibute values
+ * Return array of fields to load attribute values
*
- * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
+ * @return array
*/
- public function useLoadDataFields()
+ protected function _getLoadDataFields()
{
- $this->getSelect()->reset(Zend_Db_Select::COLUMNS);
- $this->getSelect()->columns(array(
+ $fields = array(
'attribute_id',
'entity_type_id',
'attribute_code',
@@ -66,8 +65,19 @@ public function useLoadDataFields()
'backend_table',
'frontend_input',
'source_model',
- 'is_global'
- ));
+ );
+ return $fields;
+ }
+
+ /**
+ * Specify select columns which are used for load arrtibute values
+ *
+ * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
+ */
+ public function useLoadDataFields()
+ {
+ $this->getSelect()->reset(Zend_Db_Select::COLUMNS);
+ $this->getSelect()->columns($this->_getLoadDataFields());
return $this;
}
@@ -80,6 +90,12 @@ public function useLoadDataFields()
public function setEntityTypeFilter($typeId)
{
$this->getSelect()->where('main_table.entity_type_id=?', $typeId);
+ if ($additionalTable = $this->getResource()->getAdditionalAttributeTable($typeId)) {
+ $this->getSelect()->join(
+ array('additional_table' => $this->getTable($additionalTable)),
+ 'additional_table.attribute_id=main_table.attribute_id'
+ );
+ }
return $this;
}
@@ -193,39 +209,6 @@ public function addAttributeGrouping()
return $this;
}
- /**
- * Specify filter by "is_visible" field
- *
- * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
- */
- public function addVisibleFilter()
- {
- $this->getSelect()->where('main_table.is_visible=?', 1);
- return $this;
- }
-
- /**
- * Specify "is_filterable" filter
- *
- * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
- */
- public function addIsFilterableFilter()
- {
- $this->getSelect()->where('main_table.is_filterable>0');
- return $this;
- }
-
- /**
- * Add filterable in search filter
- *
- * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
- */
- public function addIsFilterableInSearchFilter()
- {
- $this->getSelect()->where('main_table.is_filterable_in_search>0');
- return $this;
- }
-
/**
* Specify "is_unique" filter as true
*
@@ -248,17 +231,6 @@ public function addIsNotUniqueFilter()
return $this;
}
- /**
- * Specify "is_searchable" filter
- *
- * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
- */
- public function addIsSearchableFilter()
- {
- $this->getSelect()->where('main_table.is_searchable=1');
- return $this;
- }
-
/**
* Specify filter to select just attributes with options
*
@@ -276,18 +248,6 @@ public function addHasOptionsFilter()
return $this;
}
- /**
- * Specify "is_visible_in_advanced_search" filter
- *
- * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
- */
- public function addDisplayInAdvancedSearchFilter(){
- $this->getSelect()
- ->where('main_table.is_visible_in_advanced_search = ?', 1);
-
- return $this;
- }
-
/**
* Apply filter by attribute frontend input type
*
@@ -402,4 +362,20 @@ public function setCodeFilter($code)
$this->getSelect()->where('main_table.attribute_code IN(?)', $code);
return $this;
}
+
+ /**
+ * Add store label to attribute by specified store id
+ *
+ * @param integer $storeId
+ * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Collection
+ */
+ public function addStoreLabel($storeId)
+ {
+ $this->getSelect()->joinLeft(
+ array('al' => $this->getTable('eav/attribute_label')),
+ 'al.attribute_id = main_table.attribute_id AND al.store_id = ' . (int) $storeId,
+ array('store_label' => new Zend_Db_Expr('IFNULL(al.value, main_table.frontend_label)'))
+ );
+ return $this;
+ }
}
diff --git a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Group.php b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Group.php
index 5aefb82e0d..e4e651c825 100644
--- a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Group.php
+++ b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Group.php
@@ -82,4 +82,19 @@ private function _getMaxSortOrder($object)
$maxOrder = $read->fetchOne($select);
return $maxOrder;
}
+
+ /**
+ * Set any group default if old one was removed
+ *
+ * @param integer $attributeSetId
+ * @return Mage_Eav_Model_Mysql4_Entity_Attribute_Group
+ */
+ public function updateDefaultGroup($attributeSetId)
+ {
+ $this->_getWriteAdapter()->query(
+ "UPDATE `{$this->getMainTable()}` SET default_id = 1 WHERE attribute_set_id = :attribute_set_id ORDER BY default_id DESC LIMIT 1",
+ array('attribute_set_id' => $attributeSetId)
+ );
+ return $this;
+ }
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Option.php b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Option.php
index 9083605d38..33a6b6082a 100644
--- a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Option.php
+++ b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Option.php
@@ -86,7 +86,7 @@ public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $at
$joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`";
}
- $valueExpr = new Zend_Db_Expr("IFNULL(t2.value, t1.value)");
+ $valueExpr = new Zend_Db_Expr("IF(t2.value_id>0, t2.value, t1.value)");
$select = $this->_getReadAdapter()->select()
->joinLeft(
array('t1' => $attributeTable),
diff --git a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Option/Collection.php b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Option/Collection.php
index 6bd3b0dd6d..1bcf827de9 100644
--- a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Option/Collection.php
+++ b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Option/Collection.php
@@ -61,7 +61,7 @@ public function setStoreFilter($storeId=null, $useDefaultValue=true)
->joinLeft(array('store_value'=>$this->_optionValueTable),
'store_value.option_id=main_table.option_id AND '.$this->getConnection()->quoteInto('store_value.store_id=?', $storeId),
array('store_value'=>'value',
- 'value' => new Zend_Db_Expr('IFNULL(store_value.value,store_default_value.value)')))
+ 'value' => new Zend_Db_Expr('IF(store_value.value_id>0, store_value.value,store_default_value.value)')))
->where($this->getConnection()->quoteInto('store_default_value.store_id=?', 0));
}
else {
diff --git a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Set.php b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Set.php
index 6f97b6bb49..54f61f6a1f 100644
--- a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Set.php
+++ b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Attribute/Set.php
@@ -63,6 +63,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $object)
/* @var $group Mage_Eav_Model_Entity_Attribute_Group */
$group->delete();
}
+ Mage::getResourceModel('eav/entity_attribute_group')->updateDefaultGroup($object->getId());
}
if ($object->getRemoveAttributes()) {
foreach ($object->getRemoveAttributes() as $attribute) {
diff --git a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Type.php b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Type.php
index 601600a0ee..40d134d94c 100644
--- a/app/code/core/Mage/Eav/Model/Mysql4/Entity/Type.php
+++ b/app/code/core/Mage/Eav/Model/Mysql4/Entity/Type.php
@@ -55,4 +55,18 @@ public function loadByCode($object, $code)
return $this->load($object, $code, 'entity_type_code');
}
+ /**
+ * Retrieve additional attribute table name for specified entity type
+ *
+ * @param integer $entityTypeId
+ * @return string
+ */
+ public function getAdditionalAttributeTable($entityTypeId)
+ {
+ $select = $this->_getReadAdapter()->select()
+ ->from($this->getMainTable(), array('additional_attribute_table'))
+ ->where('entity_type_id = ?', $entityTypeId);
+ return $this->_getReadAdapter()->fetchOne($select);
+ }
+
}
diff --git a/app/code/core/Mage/Eav/etc/config.xml b/app/code/core/Mage/Eav/etc/config.xml
index d5795c5cbc..aaa0286d8a 100644
--- a/app/code/core/Mage/Eav/etc/config.xml
+++ b/app/code/core/Mage/Eav/etc/config.xml
@@ -28,7 +28,7 @@
- 0.7.13
+ 0.7.15
@@ -41,19 +41,54 @@
Mage_Eav_Model_Mysql4
-
-
-
-
-
-
-
-
-
-
-
-
- eav_attribute_option_value
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ eav_attribute_option_value
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -64,26 +99,28 @@
Mage_Eav
Mage_Eav_Model_Entity_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
EAV types and attributes
+
+
+
+
+
diff --git a/app/code/core/Mage/GiftMessage/etc/config.xml b/app/code/core/Mage/GiftMessage/etc/config.xml
index ef3f3f0cdd..46edc99418 100644
--- a/app/code/core/Mage/GiftMessage/etc/config.xml
+++ b/app/code/core/Mage/GiftMessage/etc/config.xml
@@ -58,20 +58,7 @@
Mage_GiftMessage
Mage_GiftMessage_Model_Mysql4_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
diff --git a/app/code/core/Mage/GiftRegistry/etc/config.xml b/app/code/core/Mage/GiftRegistry/etc/config.xml
index 9e818cc486..da4eb9ab57 100644
--- a/app/code/core/Mage/GiftRegistry/etc/config.xml
+++ b/app/code/core/Mage/GiftRegistry/etc/config.xml
@@ -61,20 +61,7 @@
Mage_GiftRegistry
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
diff --git a/app/code/core/Mage/GoogleAnalytics/Model/Observer.php b/app/code/core/Mage/GoogleAnalytics/Model/Observer.php
index 9851120398..a9e5d1ebf5 100644
--- a/app/code/core/Mage/GoogleAnalytics/Model/Observer.php
+++ b/app/code/core/Mage/GoogleAnalytics/Model/Observer.php
@@ -35,11 +35,22 @@ class Mage_GoogleAnalytics_Model_Observer
{
/**
- * Enter description here...
+ * Create Google Analytics block for success page view
*
- * @param unknown_type $observer
+ * @deprecated after 1.3.2.3 Use setGoogleAnalyticsOnOrderSuccessPageView() method instead
+ * @param Varien_Event_Observer $observer
*/
public function order_success_page_view($observer)
+ {
+ $this->setGoogleAnalyticsOnOrderSuccessPageView($observer);
+ }
+
+ /**
+ * Create Google Analytics block for success page view
+ *
+ * @param Varien_Event_Observer $observer
+ */
+ public function setGoogleAnalyticsOnOrderSuccessPageView(Varien_Event_Observer $observer)
{
$quoteId = Mage::getSingleton('checkout/session')->getLastQuoteId();
$analyticsBlock = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('google_analytics');
diff --git a/app/code/core/Mage/GoogleAnalytics/etc/config.xml b/app/code/core/Mage/GoogleAnalytics/etc/config.xml
index c997e27152..d4472ca974 100644
--- a/app/code/core/Mage/GoogleAnalytics/etc/config.xml
+++ b/app/code/core/Mage/GoogleAnalytics/etc/config.xml
@@ -60,12 +60,19 @@
- singleton
googleanalytics/observer
- order_success_page_view
+ setGoogleAnalyticsOnOrderSuccessPageView
+
+
+
+ googleanalytics/observer
+ setGoogleAnalyticsOnOrderSuccessPageView
+
+
+
@@ -86,24 +93,5 @@
-
-
-
-
-
-
-
-
-
- Google API
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/code/core/Mage/GoogleBase/Model/Service/Item.php b/app/code/core/Mage/GoogleBase/Model/Service/Item.php
index 627f296cb0..3079398f73 100644
--- a/app/code/core/Mage/GoogleBase/Model/Service/Item.php
+++ b/app/code/core/Mage/GoogleBase/Model/Service/Item.php
@@ -293,6 +293,7 @@ protected function _setUniversalData()
$this->_setAttribute('image_link', $object->getData('image_url'), 'url');
}
+ $this->_setAttribute('condition', 'new', 'text');
$this->_setAttribute('target_country', $targetCountry, 'text');
$this->_setAttribute('item_language', $this->getConfig()->getCountryInfo($targetCountry, 'language'), 'text');
diff --git a/app/code/core/Mage/GoogleBase/etc/config.xml b/app/code/core/Mage/GoogleBase/etc/config.xml
index 4689f2b5ca..3f92f83588 100644
--- a/app/code/core/Mage/GoogleBase/etc/config.xml
+++ b/app/code/core/Mage/GoogleBase/etc/config.xml
@@ -62,20 +62,7 @@
Mage_GoogleBase
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
Mage_GoogleBase_Block
@@ -106,7 +93,6 @@
- singleton
googlebase/observer
saveProductItem
@@ -115,7 +101,6 @@
- singleton
googlebase/observer
deleteProductItem
@@ -129,51 +114,6 @@
-
-
-
-
- Google Base
-
-
- Manage Attributes
- googlebase/types
-
-
- Manage Items
- googlebase/items
-
-
-
-
-
-
-
-
-
-
-
-
-
- Google Base
- 500
-
-
- Manage Attributes
- 0
-
-
- Manage Items
- 5
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/GoogleCheckout/Model/Mysql4/Setup.php b/app/code/core/Mage/GoogleCheckout/Model/Mysql4/Setup.php
index 94087326c5..6e856b2ee3 100644
--- a/app/code/core/Mage/GoogleCheckout/Model/Mysql4/Setup.php
+++ b/app/code/core/Mage/GoogleCheckout/Model/Mysql4/Setup.php
@@ -25,7 +25,7 @@
*/
-class Mage_GoogleCheckout_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
+class Mage_GoogleCheckout_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
{
}
\ No newline at end of file
diff --git a/app/code/core/Mage/GoogleCheckout/Model/Payment.php b/app/code/core/Mage/GoogleCheckout/Model/Payment.php
index ba8d7d890e..7f2946b2c5 100644
--- a/app/code/core/Mage/GoogleCheckout/Model/Payment.php
+++ b/app/code/core/Mage/GoogleCheckout/Model/Payment.php
@@ -56,17 +56,6 @@ public function canEdit()
return false;
}
- /**
- * Return true if the method can be used at this time
- * Use google/checkout/active flag of admin module config
- *
- * @return bool
- */
- public function isAvailable($quote=null)
- {
- return Mage::getStoreConfig('google/checkout/active') > 0;
- }
-
/**
* Return Order Place Redirect URL
*
diff --git a/app/code/core/Mage/GoogleCheckout/etc/config.xml b/app/code/core/Mage/GoogleCheckout/etc/config.xml
index e1c8c802c3..2aeb2c5f9b 100644
--- a/app/code/core/Mage/GoogleCheckout/etc/config.xml
+++ b/app/code/core/Mage/GoogleCheckout/etc/config.xml
@@ -33,13 +33,13 @@
-
- -
+
+ -
-
-
+
+
@@ -64,20 +64,7 @@
Mage_GoogleCheckout
Mage_GoogleCheckout_Model_Mysql4_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
Mage_GoogleCheckout_Block
@@ -137,25 +124,6 @@ Something like this is to be added to resolve bug #4890
-
-
-
-
-
-
-
-
-
- Google API
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php
index 52c0de1700..da8c0aedb5 100644
--- a/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php
+++ b/app/code/core/Mage/GoogleOptimizer/Block/Adminhtml/Cms/Page/Edit/Tab/Googleoptimizer.php
@@ -31,7 +31,9 @@
* @package Mage_GoogleOptimizer
* @author Magento Core Team
*/
-class Mage_Googleoptimizer_Block_Adminhtml_Cms_Page_Edit_Tab_Googleoptimizer extends Mage_Adminhtml_Block_Widget_Form
+class Mage_Googleoptimizer_Block_Adminhtml_Cms_Page_Edit_Tab_Googleoptimizer
+ extends Mage_Adminhtml_Block_Widget_Form
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
protected function _prepareForm()
{
@@ -43,6 +45,15 @@ protected function _prepareForm()
Mage::helper('googleoptimizer')->setStoreId(Mage::app()->getDefaultStoreView());
+ /*
+ * Checking if user have permissions to save information
+ */
+ if ($this->_isAllowedAction('save')) {
+ $isElementDisabled = false;
+ } else {
+ $isElementDisabled = true;
+ }
+
$fieldset->addField('conversion_page', 'select',
array(
'name' => 'conversion_page',
@@ -50,7 +61,8 @@ protected function _prepareForm()
'values'=> Mage::getModel('googleoptimizer/adminhtml_system_config_source_googleoptimizer_conversionpages')->toOptionArray(),
'class' => 'select googleoptimizer validate-googleoptimizer',
'required' => false,
- 'onchange' => 'googleOptimizerConversionPageAction(this)'
+ 'onchange' => 'googleOptimizerConversionPageAction(this)',
+ 'disabled' => $isElementDisabled
)
);
@@ -60,6 +72,7 @@ protected function _prepareForm()
array(
'name' => 'conversion_page_url',
'label' => Mage::helper('googleoptimizer')->__('Conversion Page URL'),
+ 'disabled' => $isElementDisabled
)
)->setRenderer($this->getLayout()->createBlock('googleoptimizer/adminhtml_cms_page_edit_renderer_conversion'));
} else {
@@ -70,7 +83,8 @@ protected function _prepareForm()
'class' => 'input-text',
'readonly' => 'readonly',
'required' => false,
- 'note' => Mage::helper('googleoptimizer')->__('Please copy and paste this value to experiment edit form')
+ 'note' => Mage::helper('googleoptimizer')->__('Please copy and paste this value to experiment edit form'),
+ 'disabled' => $isElementDisabled
)
);
}
@@ -78,6 +92,7 @@ protected function _prepareForm()
$fieldset->addField('export_controls', 'text',
array(
'name' => 'export_controls',
+ 'disabled' => $isElementDisabled
)
);
@@ -94,7 +109,8 @@ protected function _prepareForm()
'values'=> $pageTypes,
'class' => 'select googleoptimizer validate-googleoptimizer',
'required' => false,
- 'onchange' => 'googleOptimizerVariantPageAction(this)'
+ 'onchange' => 'googleOptimizerVariantPageAction(this)',
+ 'disabled' => $isElementDisabled
)
);
@@ -105,6 +121,7 @@ protected function _prepareForm()
'class' => 'textarea validate-googleoptimizer',
'required' => false,
'note' => '',
+ 'disabled' => $isElementDisabled
)
);
$fieldset->addField('tracking_script', 'textarea',
@@ -114,6 +131,7 @@ protected function _prepareForm()
'class' => 'textarea validate-googleoptimizer',
'required' => false,
'note' => '',
+ 'disabled' => $isElementDisabled
)
);
$fieldset->addField('conversion_script', 'textarea',
@@ -123,6 +141,7 @@ protected function _prepareForm()
'class' => 'textarea validate-googleoptimizer',
'required' => false,
'note' => '',
+ 'disabled' => $isElementDisabled
)
);
@@ -175,4 +194,54 @@ public function getGoogleOptimizer()
}
return $googleOptimizer;
}
-}
\ No newline at end of file
+
+ /**
+ * Prepare label for tab
+ *
+ * @return string
+ */
+ public function getTabLabel()
+ {
+ return Mage::helper('googleoptimizer')->__('Page View Optimization');
+ }
+
+ /**
+ * Prepare title for tab
+ *
+ * @return string
+ */
+ public function getTabTitle()
+ {
+ return Mage::helper('googleoptimizer')->__('Page View Optimization');
+ }
+
+ /**
+ * Returns status flag about this tab can be showen or not
+ *
+ * @return true
+ */
+ public function canShowTab()
+ {
+ return true;
+ }
+
+ /**
+ * Returns status flag about this tab hidden or not
+ *
+ * @return true
+ */
+ public function isHidden()
+ {
+ return false;
+ }
+
+ /** Check permission for passed action
+ *
+ * @param string $action
+ * @return bool
+ */
+ protected function _isAllowedAction($action)
+ {
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
+ }
+}
diff --git a/app/code/core/Mage/GoogleOptimizer/etc/config.xml b/app/code/core/Mage/GoogleOptimizer/etc/config.xml
index 9f3b8ae5f8..eec8303a9b 100644
--- a/app/code/core/Mage/GoogleOptimizer/etc/config.xml
+++ b/app/code/core/Mage/GoogleOptimizer/etc/config.xml
@@ -57,20 +57,7 @@
Mage_GoogleOptimizer
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
Mage_GoogleOptimizer_Block
@@ -79,7 +66,6 @@
- singleton
googleoptimizer/observer
appendToPageGoogleOptimizerScripts
@@ -125,7 +111,6 @@
- singleton
googleoptimizer/observer
appendToProductGoogleOptimizerScripts
@@ -134,7 +119,6 @@
- singleton
googleoptimizer/observer
appendToCategoryGoogleOptimizerScripts
@@ -143,7 +127,6 @@
- singleton
googleoptimizer/observer
assignHandlers
@@ -166,7 +149,6 @@
- singleton
googleoptimizer/observer
appendToProductGoogleOptimizerScripts
@@ -175,7 +157,6 @@
- singleton
googleoptimizer/observer
prepareProductGoogleOptimizerScripts
@@ -184,7 +165,6 @@
- singleton
googleoptimizer/observer
saveProductGoogleOptimizerScripts
@@ -193,7 +173,6 @@
- singleton
googleoptimizer/observer
deleteProductGoogleOptimizerScripts
@@ -202,7 +181,6 @@
- singleton
googleoptimizer/observer
appendToCategoryGoogleOptimizerScripts
@@ -211,7 +189,6 @@
- singleton
googleoptimizer/observer
prepareCategoryGoogleOptimizerScripts
@@ -220,7 +197,6 @@
- singleton
googleoptimizer/observer
saveCategoryGoogleOptimizerScripts
@@ -229,7 +205,6 @@
- singleton
googleoptimizer/observer
deleteCategoryGoogleOptimizerScripts
@@ -238,7 +213,6 @@
- singleton
googleoptimizer/observer
appendToPageGoogleOptimizerScripts
@@ -247,7 +221,6 @@
- singleton
googleoptimizer/observer
preparePageGoogleOptimizerScripts
@@ -256,7 +229,6 @@
- singleton
googleoptimizer/observer
savePageGoogleOptimizerScripts
@@ -265,7 +237,6 @@
- singleton
googleoptimizer/observer
deletePageGoogleOptimizerScripts
diff --git a/app/code/core/Mage/Install/etc/config.xml b/app/code/core/Mage/Install/etc/config.xml
index d99d1ea67d..ccdb6a2adb 100644
--- a/app/code/core/Mage/Install/etc/config.xml
+++ b/app/code/core/Mage/Install/etc/config.xml
@@ -41,14 +41,6 @@
Mage_Install_Model_Mysql4
-
-
- core_write
-
-
- core_read
-
-
Mage_Install_Block
@@ -77,7 +69,6 @@
- singleton
core/resource
checkDbConnection
@@ -86,7 +77,6 @@
- singleton
install/observer
installFailure
@@ -95,7 +85,6 @@
- singleton
install/observer
bindLocale
diff --git a/app/code/core/Mage/Log/Model/Mysql4/Log.php b/app/code/core/Mage/Log/Model/Mysql4/Log.php
index b6e9f05918..db5af20266 100644
--- a/app/code/core/Mage/Log/Model/Mysql4/Log.php
+++ b/app/code/core/Mage/Log/Model/Mysql4/Log.php
@@ -43,6 +43,36 @@ protected function _construct()
$this->_init('log/visitor', 'visitor_id');
}
+ /**
+ * Start resource transaction
+ *
+ * @return Mage_Log_Model_Mysql4_Log
+ */
+ public function beginTransaction()
+ {
+ return $this;
+ }
+
+ /**
+ * Commit resource transaction
+ *
+ * @return Mage_Log_Model_Mysql4_Log
+ */
+ public function commit()
+ {
+ return $this;
+ }
+
+ /**
+ * Roll back resource transaction
+ *
+ * @return Mage_Log_Model_Mysql4_Log
+ */
+ public function rollBack()
+ {
+ return $this;
+ }
+
/**
* Clean logs
*
diff --git a/app/code/core/Mage/Log/Model/Mysql4/Visitor.php b/app/code/core/Mage/Log/Model/Mysql4/Visitor.php
index 1958805444..5e375ee625 100644
--- a/app/code/core/Mage/Log/Model/Mysql4/Visitor.php
+++ b/app/code/core/Mage/Log/Model/Mysql4/Visitor.php
@@ -38,6 +38,36 @@ protected function _construct()
$this->_init('log/visitor', 'visitor_id');
}
+ /**
+ * Start resource transaction
+ *
+ * @return Mage_Log_Model_Mysql4_Visitor
+ */
+ public function beginTransaction()
+ {
+ return $this;
+ }
+
+ /**
+ * Commit resource transaction
+ *
+ * @return Mage_Log_Model_Mysql4_Visitor
+ */
+ public function commit()
+ {
+ return $this;
+ }
+
+ /**
+ * Roll back resource transaction
+ *
+ * @return Mage_Log_Model_Mysql4_Visitor
+ */
+ public function rollBack()
+ {
+ return $this;
+ }
+
protected function _prepareDataForSave(Mage_Core_Model_Abstract $visitor)
{
return array(
diff --git a/app/code/core/Mage/Log/Model/Visitor.php b/app/code/core/Mage/Log/Model/Visitor.php
index d849cc97a6..7dc94b7b74 100644
--- a/app/code/core/Mage/Log/Model/Visitor.php
+++ b/app/code/core/Mage/Log/Model/Visitor.php
@@ -175,10 +175,15 @@ public function saveByRequest($observer)
return $this;
}
- $this->setLastVisitAt(now());
- $this->save();
+ try {
+ $this->setLastVisitAt(now());
+ $this->save();
- $this->_getSession()->setVisitorData($this->getData());
+ $this->_getSession()->setVisitorData($this->getData());
+ }
+ catch (Exception $e) {
+ Mage::logException($e);
+ }
return $this;
}
diff --git a/app/code/core/Mage/Log/etc/config.xml b/app/code/core/Mage/Log/etc/config.xml
index 9558efdd30..752e58c0f4 100644
--- a/app/code/core/Mage/Log/etc/config.xml
+++ b/app/code/core/Mage/Log/etc/config.xml
@@ -82,20 +82,7 @@
Mage_Log
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -112,7 +99,6 @@
- singleton
log/visitor
initByRequest
@@ -121,7 +107,6 @@
- singleton
log/visitor
saveByRequest
@@ -130,7 +115,6 @@
- singleton
log/visitor
bindCustomerLogin
@@ -139,7 +123,6 @@
- singleton
log/visitor
bindCustomerLogout
@@ -148,7 +131,6 @@
- singleton
log/visitor
bindQuoteCreate
@@ -157,7 +139,6 @@
- singleton
log/visitor
bindQuoteDestroy
diff --git a/app/code/core/Mage/Newsletter/Block/Subscribe.php b/app/code/core/Mage/Newsletter/Block/Subscribe.php
index 5f572f58f4..656eed37a4 100644
--- a/app/code/core/Mage/Newsletter/Block/Subscribe.php
+++ b/app/code/core/Mage/Newsletter/Block/Subscribe.php
@@ -45,4 +45,15 @@ public function getErrorMessage()
$message = Mage::getSingleton('newsletter/session')->getError();
return $message;
}
-}
\ No newline at end of file
+
+ /**
+ * Retrieve form action url and set "secure" param to avoid confirm
+ * message when we submit form from secure page to unsecure
+ *
+ * @return string
+ */
+ public function getFormActionUrl()
+ {
+ return $this->getUrl('newsletter/subscriber/new', array('_secure' => true));
+ }
+}
diff --git a/app/code/core/Mage/Newsletter/Model/Mysql4/Queue/Collection.php b/app/code/core/Mage/Newsletter/Model/Mysql4/Queue/Collection.php
index 63ed4bb8b8..cf712eba17 100644
--- a/app/code/core/Mage/Newsletter/Model/Mysql4/Queue/Collection.php
+++ b/app/code/core/Mage/Newsletter/Model/Mysql4/Queue/Collection.php
@@ -34,17 +34,18 @@
class Mage_Newsletter_Model_Mysql4_Queue_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
- protected $_addSubscribersFlag = false;
+ protected $_addSubscribersFlag = false;
/**
* @var bool
*/
protected $_isStoreFilter = false;
- /**
- * Initializes collection
- */
+ /**
+ * Initializes collection
+ */
protected function _construct()
{
+ $this->_map['fields']['queue_id'] = 'main_table.queue_id';
$this->_init('newsletter/queue');
}
@@ -58,35 +59,35 @@ public function addTemplateInfo() {
$this->getSelect()->joinLeft(array('template'=>$this->getTable('template')),
'template.template_id=main_table.template_id',
array('template_subject','template_sender_name','template_sender_email'));
- $this->_joinedTables['template'] = true;
- return $this;
+ $this->_joinedTables['template'] = true;
+ return $this;
}
protected function _addSubscriberInfoToSelect()
{
$this->_addSubscribersFlag = true;
- $this->getSize(); // Executing of count query!
- $this->getSelect()
- ->joinLeft(array('link_total'=>$this->getTable('queue_link')),
- 'main_table.queue_id=link_total.queue_id',
- array(
- new Zend_Db_Expr('COUNT(DISTINCT link_total.queue_link_id) AS subscribers_total')
- ))
- ->joinLeft(array('link_sent'=>$this->getTable('queue_link')),
- 'main_table.queue_id=link_sent.queue_id and link_sent.letter_sent_at IS NOT NULL',
- array(
- new Zend_Db_Expr('COUNT(DISTINCT link_sent.queue_link_id) AS subscribers_sent')
- ))
- ->group('main_table.queue_id');
+ $this->getSize(); // Executing of count query!
+ $select = $this->getConnection()
+ ->select()
+ ->from(array('link_total' => $this->getTable('queue_link')), 'COUNT(DISTINCT `link_total`.`queue_link_id`)')
+ ->where('`main_table`.`queue_id` = `link_total`.`queue_id`');
+ $this->getSelect()
+ ->joinLeft(array('link_sent'=>$this->getTable('queue_link')),
+ 'main_table.queue_id=link_sent.queue_id and link_sent.letter_sent_at IS NOT NULL',
+ array(
+ new Zend_Db_Expr('COUNT(DISTINCT `link_sent`.`queue_link_id`) AS `subscribers_sent`'),
+ new Zend_Db_Expr('(' . $select . ') AS `subscribers_total`')
+ ))
+ ->group('main_table.queue_id');
return $this;
}
- public function load($printQuery=false, $logQuery=false) {
- if($this->_addSubscribersFlag && !$this->isLoaded()) {
- $this->_addSubscriberInfoToSelect();
- }
-
- return parent::load($printQuery, $logQuery);
+ public function load($printQuery=false, $logQuery=false)
+ {
+ if($this->_addSubscribersFlag && !$this->isLoaded()) {
+ $this->_addSubscriberInfoToSelect();
+ }
+ return parent::load($printQuery, $logQuery);
}
/**
@@ -96,55 +97,55 @@ public function load($printQuery=false, $logQuery=false) {
*/
public function addSubscribersInfo()
{
- $this->_addSubscribersFlag = true;
- return $this;
+ $this->_addSubscribersFlag = true;
+ return $this;
}
public function addFieldToFilter($field, $condition=null)
{
- if(in_array($field, array('subscribers_total', 'subscribers_sent'))) {
- $this->addFieldToFilter('main_table.queue_id', array('in'=>$this->_getIdsFromLink($field, $condition)));
- return $this;
- } else {
- return parent::addFieldToFilter($field, $condition);
- }
+ if(in_array($field, array('subscribers_total', 'subscribers_sent'))) {
+ $this->addFieldToFilter('main_table.queue_id', array('in'=>$this->_getIdsFromLink($field, $condition)));
+ return $this;
+ } else {
+ return parent::addFieldToFilter($field, $condition);
+ }
}
protected function _getIdsFromLink($field, $condition) {
- $select = $this->getConnection()->select()
- ->from($this->getTable('queue_link'), array('queue_id', 'COUNT(queue_link_id) as total'))
- ->group('queue_id')
- ->having($this->_getConditionSql('total', $condition));
+ $select = $this->getConnection()->select()
+ ->from($this->getTable('queue_link'), array('queue_id', 'COUNT(queue_link_id) as total'))
+ ->group('queue_id')
+ ->having($this->_getConditionSql('total', $condition));
- if($field == 'subscribers_sent') {
- $select->where('letter_sent_at IS NOT NULL');
- }
+ if($field == 'subscribers_sent') {
+ $select->where('letter_sent_at IS NOT NULL');
+ }
- $idList = $this->getConnection()->fetchCol($select);
+ $idList = $this->getConnection()->fetchCol($select);
- if(count($idList)) {
- return $idList;
- }
+ if(count($idList)) {
+ return $idList;
+ }
- return array(0);
+ return array(0);
}
/**
* Set filter for queue by subscriber.
*
- * @param int $subscriberId
- * @return Mage_Newsletter_Model_Mysql4_Queue_Collection
+ * @param int $subscriberId
+ * @return Mage_Newsletter_Model_Mysql4_Queue_Collection
*/
public function addSubscriberFilter($subscriberId)
{
- $this->getSelect()
- ->join(array('link'=>$this->getTable('queue_link')),
- 'main_table.queue_id=link.queue_id',
- array('letter_sent_at')
- )
- ->where('link.subscriber_id = ?', $subscriberId);
-
- return $this;
+ $this->getSelect()
+ ->join(array('link'=>$this->getTable('queue_link')),
+ 'main_table.queue_id=link.queue_id',
+ array('letter_sent_at')
+ )
+ ->where('link.subscriber_id = ?', $subscriberId);
+
+ return $this;
}
/**
@@ -154,13 +155,13 @@ public function addSubscriberFilter($subscriberId)
*/
public function addOnlyForSendingFilter()
{
- $this->getSelect()
- ->where('main_table.queue_status in (?)', array(Mage_Newsletter_Model_Queue::STATUS_SENDING,
- Mage_Newsletter_Model_Queue::STATUS_NEVER))
- ->where('main_table.queue_start_at < ?', Mage::getSingleton('core/date')->gmtdate())
- ->where('main_table.queue_start_at IS NOT NULL');
+ $this->getSelect()
+ ->where('main_table.queue_status in (?)', array(Mage_Newsletter_Model_Queue::STATUS_SENDING,
+ Mage_Newsletter_Model_Queue::STATUS_NEVER))
+ ->where('main_table.queue_start_at < ?', Mage::getSingleton('core/date')->gmtdate())
+ ->where('main_table.queue_start_at IS NOT NULL');
- return $this;
+ return $this;
}
/**
@@ -170,10 +171,10 @@ public function addOnlyForSendingFilter()
*/
public function addOnlyUnsentFilter()
{
- $this->getSelect()
- ->where('main_table.queue_status = ?', Mage_Newsletter_Model_Queue::STATUS_NEVER);
+ $this->getSelect()
+ ->where('main_table.queue_status = ?', Mage_Newsletter_Model_Queue::STATUS_NEVER);
- return $this;
+ return $this;
}
public function toOptionArray()
diff --git a/app/code/core/Mage/Newsletter/Model/Subscriber.php b/app/code/core/Mage/Newsletter/Model/Subscriber.php
index 798230c1a2..83c1191919 100644
--- a/app/code/core/Mage/Newsletter/Model/Subscriber.php
+++ b/app/code/core/Mage/Newsletter/Model/Subscriber.php
@@ -45,7 +45,7 @@ class Mage_Newsletter_Model_Subscriber extends Varien_Object
const XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY = 'newsletter/subscription/un_email_identity';
const XML_PATH_CONFIRMATION_FLAG = 'newsletter/subscription/confirm';
- const XML_PATH_SENDING_SET_RETURN_PATH = 'newsletter/sending/set_return_path';
+ const XML_PATH_SENDING_SET_RETURN_PATH = Mage_Core_Model_Email_Template::XML_PATH_SENDING_SET_RETURN_PATH;
protected $_isStatusChanged = false;
@@ -282,7 +282,6 @@ public function subscribe($email)
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
->loadByEmail($email);
- $isNewSubscriber = false;
$customerSession = Mage::getSingleton('customer/session');
@@ -290,15 +289,10 @@ public function subscribe($email)
$this->setSubscriberConfirmCode($this->randomSequence());
}
-// if(($this->getCustomerId() && !$customerSession->isLoggedIn())
-// || ($this->getCustomerId()
-// && $customerSession->getCustomerId() != $this->getCustomerId()
-// )) {
-// return $this->getSubscriberStatus();
-// }
+ $isConfirmNeed = Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1 ? true : false;
if (!$this->getId() || $this->getStatus()==self::STATUS_UNSUBSCRIBED || $this->getStatus()==self::STATUS_NOT_ACTIVE) {
- if (Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1) {
+ if ($isConfirmNeed) {
$this->setStatus(self::STATUS_NOT_ACTIVE);
} else {
$this->setStatus(self::STATUS_SUBSCRIBED);
@@ -317,16 +311,14 @@ public function subscribe($email)
} else {
$this->setStoreId(Mage::app()->getStore()->getId());
$this->setCustomerId(0);
- $isNewSubscriber = true;
}
$this->setIsStatusChanged(true);
try {
$this->save();
- if (Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1
- && $this->getSubscriberStatus()==self::STATUS_NOT_ACTIVE) {
- $this->sendConfirmationRequestEmail();
+ if ($isConfirmNeed) {
+ $this->sendConfirmationRequestEmail();
} else {
$this->sendConfirmationSuccessEmail();
}
@@ -453,10 +445,7 @@ public function sendConfirmationRequestEmail()
$translate->setTranslateInline(false);
$email = Mage::getModel('core/email_template');
- /* @var $email Mage_Core_Model_Email_Template */
- if (Mage::getStoreConfigFlag(self::XML_PATH_SENDING_SET_RETURN_PATH)) {
- $email->setReturnPath(Mage::getStoreConfig(self::XML_PATH_CONFIRM_EMAIL_IDENTITY));
- }
+
$email->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_CONFIRM_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_CONFIRM_EMAIL_IDENTITY),
@@ -485,10 +474,7 @@ public function sendConfirmationSuccessEmail()
$translate->setTranslateInline(false);
$email = Mage::getModel('core/email_template');
- /* @var $email Mage_Core_Model_Email_Template */
- if (Mage::getStoreConfigFlag(self::XML_PATH_SENDING_SET_RETURN_PATH)) {
- $email->setReturnPath(Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY));
- }
+
$email->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
@@ -516,10 +502,7 @@ public function sendUnsubscriptionEmail()
$translate->setTranslateInline(false);
$email = Mage::getModel('core/email_template');
- /* @var $email Mage_Core_Model_Email_Template */
- if (Mage::getStoreConfigFlag(self::XML_PATH_SENDING_SET_RETURN_PATH)) {
- $email->setReturnPath(Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY));
- }
+
$email->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY),
diff --git a/app/code/core/Mage/Newsletter/Model/Template.php b/app/code/core/Mage/Newsletter/Model/Template.php
index 121dd361e3..fcd306ac5d 100644
--- a/app/code/core/Mage/Newsletter/Model/Template.php
+++ b/app/code/core/Mage/Newsletter/Model/Template.php
@@ -72,7 +72,7 @@ public function validate()
{
$validators = array(
'template_code' => array(Zend_Filter_Input::ALLOW_EMPTY => false),
- 'template_type' => 'Alnum',
+ 'template_type' => 'Int',
'template_sender_email' => 'EmailAddress',
'template_sender_name' => array(Zend_Filter_Input::ALLOW_EMPTY => false)
);
diff --git a/app/code/core/Mage/Newsletter/etc/config.xml b/app/code/core/Mage/Newsletter/etc/config.xml
index cc3aaa08cf..ca16a6080d 100644
--- a/app/code/core/Mage/Newsletter/etc/config.xml
+++ b/app/code/core/Mage/Newsletter/etc/config.xml
@@ -28,7 +28,7 @@
- 0.8.0
+ 0.8.1
@@ -69,20 +69,7 @@
Mage_Newsletter
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -109,7 +96,6 @@
- singleton
newsletter/observer
subscribeCustomer
@@ -118,78 +104,12 @@
- singleton
newsletter/observer
customerDeleted
-
-
- Newsletter
- 60
-
-
- Newsletter Templates
- adminhtml/newsletter_template/
- admin/newsletter/template
-
-
- Newsletter Queue
- adminhtml/newsletter_queue/
- admin/newsletter/queue
-
-
- Newsletter Subscribers
- adminhtml/newsletter_subscriber/
- admin/newsletter/subscriber
-
-
- Newsletter Problem Reports
- adminhtml/newsletter_problem/
- admin/newsletter/problem
-
-
-
-
-
-
-
-
-
-
-
-
-
- Newsletter Section
-
-
-
-
-
-
- Newsletter
- 60
-
-
- Newsletter Problem Reports
-
-
- Newsletter Queue
-
-
- Newsletter Subscribers
-
-
- Newsletter Templates
-
-
-
-
-
-
-
@@ -205,7 +125,6 @@
- singleton
newsletter/observer
subscribeCustomer
@@ -214,7 +133,6 @@
- singleton
newsletter/observer
customerDeleted
diff --git a/app/code/core/Mage/Newsletter/etc/system.xml b/app/code/core/Mage/Newsletter/etc/system.xml
index a7a36df26f..2a00f4ef88 100644
--- a/app/code/core/Mage/Newsletter/etc/system.xml
+++ b/app/code/core/Mage/Newsletter/etc/system.xml
@@ -109,25 +109,6 @@
-
- Sending Options
- text
- 2
- 1
- 0
- 0
-
-
- Set Return-Path
- select
- adminhtml/system_config_source_yesno
- 1
- 1
- 0
- 0
-
-
-
diff --git a/app/code/core/Mage/Page/Block/Html/Head.php b/app/code/core/Mage/Page/Block/Html/Head.php
index 8494983e65..73bc5d9bb6 100644
--- a/app/code/core/Mage/Page/Block/Html/Head.php
+++ b/app/code/core/Mage/Page/Block/Html/Head.php
@@ -24,44 +24,107 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+
/**
* Html page block
*
* @category Mage
* @package Mage_Page
- * @author Magento Core Team
+ * @author Magento Core Team
*/
class Mage_Page_Block_Html_Head extends Mage_Core_Block_Template
{
+ /**
+ * Initialize template
+ *
+ */
protected function _construct()
{
$this->setTemplate('page/html/head.phtml');
}
- public function addCss($name, $params="")
+ /**
+ * Add CSS file to HEAD entity
+ *
+ * @param string $name
+ * @param string $params
+ * @return Mage_Page_Block_Html_Head
+ */
+ public function addCss($name, $params = "")
{
$this->addItem('skin_css', $name, $params);
return $this;
}
- public function addJs($name, $params="")
+ /**
+ * Add JavaScript file to HEAD entity
+ *
+ * @param string $name
+ * @param string $params
+ * @return Mage_Page_Block_Html_Head
+ */
+ public function addJs($name, $params = "")
{
$this->addItem('js', $name, $params);
return $this;
}
- public function addCssIe($name, $params="")
+ /**
+ * Add CSS file for Internet Explorer only to HEAD entity
+ *
+ * @param string $name
+ * @param string $params
+ * @return Mage_Page_Block_Html_Head
+ */
+ public function addCssIe($name, $params = "")
{
$this->addItem('skin_css', $name, $params, 'IE');
return $this;
}
- public function addJsIe($name, $params="")
+ /**
+ * Add JavaScript file for Internet Explorer only to HEAD entity
+ *
+ * @param string $name
+ * @param string $params
+ * @return Mage_Page_Block_Html_Head
+ */
+ public function addJsIe($name, $params = "")
{
$this->addItem('js', $name, $params, 'IE');
return $this;
}
+ /**
+ * Add Link element to HEAD entity
+ *
+ * @param string $rel forward link types
+ * @param string $href URI for linked resource
+ * @return Mage_Page_Block_Html_Head
+ */
+ public function addLinkRel($rel, $href)
+ {
+ $this->addItem('link_rel', $rel, $href);
+ return $this;
+ }
+
+ /**
+ * Add HEAD Item
+ *
+ * Allowed types:
+ * - js
+ * - js_css
+ * - skin_js
+ * - skin_css
+ * - rss
+ *
+ * @param string $type
+ * @param string $name
+ * @param string $params
+ * @param string $if
+ * @param string $cond
+ * @return Mage_Page_Block_Html_Head
+ */
public function addItem($type, $name, $params=null, $if=null, $cond=null)
{
if ($type==='skin_css' && empty($params)) {
@@ -77,22 +140,34 @@ public function addItem($type, $name, $params=null, $if=null, $cond=null)
return $this;
}
+ /**
+ * Remove Item from HEAD entity
+ *
+ * @param string $type
+ * @param string $name
+ * @return Mage_Page_Block_Html_Head
+ */
public function removeItem($type, $name)
{
unset($this->_data['items'][$type.'/'.$name]);
return $this;
}
+ /**
+ * Retrieve HEAD fragment HTML with CSS/JS/RSS definations
+ *
+ * @return string
+ */
public function getCssJsHtml()
{
-// return '';
- $lines = array();
+ $lines = array();
$baseJs = Mage::getBaseUrl('js');
- $html = '';
+ $html = '';
- $script = '';
+ $script = '';
$stylesheet = ' ';
- $alternate = ' ';
+ $alternate = ' ';
+ $linkRel = ' ';
foreach ($this->_data['items'] as $item) {
if (!is_null($item['cond']) && !$this->getData($item['cond'])) {
@@ -122,6 +197,10 @@ public function getCssJsHtml()
case 'rss':
$lines[$if]['other'][] = sprintf($alternate, 'application/rss+xml'/*'text/xml' for IE?*/, $item['name'], $item['params']);
break;
+
+ case 'link_rel':
+ $lines[$if]['other'][] = sprintf($linkRel, $item['name'], $item['params']);
+ break;
}
}
@@ -162,11 +241,19 @@ public function getCssJsHtml()
return $html;
}
- public function getChunkedItems($items, $prefix='', $maxLen=450)
+ /**
+ * Retrieve Chunked Items
+ *
+ * @param array $items
+ * @param string $prefix
+ * @param int $maxLen
+ * @return array
+ */
+ public function getChunkedItems($items, $prefix = '', $maxLen = 450)
{
$chunks = array();
- $chunk = $prefix;
- foreach ($items as $i=>$item) {
+ $chunk = $prefix;
+ foreach ($items as $item) {
if (strlen($chunk.','.$item)>$maxLen) {
$chunks[] = $chunk;
$chunk = $prefix;
@@ -177,6 +264,11 @@ public function getChunkedItems($items, $prefix='', $maxLen=450)
return $chunks;
}
+ /**
+ * Retrieve Content Type
+ *
+ * @return string
+ */
public function getContentType()
{
if (empty($this->_data['content_type'])) {
@@ -185,6 +277,11 @@ public function getContentType()
return $this->_data['content_type'];
}
+ /**
+ * Retrieve Media Type
+ *
+ * @return string
+ */
public function getMediaType()
{
if (empty($this->_data['media_type'])) {
@@ -193,6 +290,11 @@ public function getMediaType()
return $this->_data['media_type'];
}
+ /**
+ * Retrieve Charset
+ *
+ * @return string
+ */
public function getCharset()
{
if (empty($this->_data['charset'])) {
@@ -201,6 +303,12 @@ public function getCharset()
return $this->_data['charset'];
}
+ /**
+ * Set title element text
+ *
+ * @param string $title
+ * @return Mage_Page_Block_Html_Head
+ */
public function setTitle($title)
{
$this->_data['title'] = Mage::getStoreConfig('design/head/title_prefix').' '.$title
@@ -208,6 +316,11 @@ public function setTitle($title)
return $this;
}
+ /**
+ * Retrieve title element text (encoded)
+ *
+ * @return string
+ */
public function getTitle()
{
if (empty($this->_data['title'])) {
@@ -216,11 +329,21 @@ public function getTitle()
return htmlspecialchars(html_entity_decode($this->_data['title'], ENT_QUOTES, 'UTF-8'));
}
+ /**
+ * Retrieve default title text
+ *
+ * @return string
+ */
public function getDefaultTitle()
{
return Mage::getStoreConfig('design/head/default_title');
}
+ /**
+ * Retrieve content for description tag
+ *
+ * @return string
+ */
public function getDescription()
{
if (empty($this->_data['description'])) {
@@ -229,6 +352,11 @@ public function getDescription()
return $this->_data['description'];
}
+ /**
+ * Retrieve content for keyvords tag
+ *
+ * @return string
+ */
public function getKeywords()
{
if (empty($this->_data['keywords'])) {
@@ -237,6 +365,11 @@ public function getKeywords()
return $this->_data['keywords'];
}
+ /**
+ * Retrieve URL to robots file
+ *
+ * @return string
+ */
public function getRobots()
{
if (empty($this->_data['robots'])) {
@@ -257,5 +390,4 @@ public function getIncludes()
}
return $this->_data['includes'];
}
-
}
diff --git a/app/code/core/Mage/Page/Model/Source/Layout.php b/app/code/core/Mage/Page/Model/Source/Layout.php
index b490c5287b..edf2a76fab 100644
--- a/app/code/core/Mage/Page/Model/Source/Layout.php
+++ b/app/code/core/Mage/Page/Model/Source/Layout.php
@@ -63,7 +63,7 @@ public function getOptions()
*
* @return array
*/
- public function toOptionArray()
+ public function toOptionArray($withEmpty = false)
{
$options = array();
@@ -74,6 +74,10 @@ public function toOptionArray()
);
}
+ if ($withEmpty) {
+ array_unshift($options, array('value'=>'', 'label'=>Mage::helper('page')->__('-- Please Select --')));
+ }
+
return $options;
}
}
diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet.php b/app/code/core/Mage/Paygate/Model/Authorizenet.php
index 361c78afe8..573590f303 100644
--- a/app/code/core/Mage/Paygate/Model/Authorizenet.php
+++ b/app/code/core/Mage/Paygate/Model/Authorizenet.php
@@ -207,6 +207,13 @@ public function refund(Varien_Object $payment, $amount)
$payment->setAnetTransType(self::REQUEST_TYPE_CREDIT);
$request = $this->_buildRequest($payment);
$request->setXTransId($payment->getRefundTransactionId());
+
+ /**
+ * need to send last 4 digit credit card number to authorize.net
+ * otherwise it will give an error
+ */
+ $request->setXCardNum($payment->getCcLast4());
+
$result = $this->_postRequest($request);
if ($result->getResponseCode()==self::RESPONSE_CODE_APPROVED) {
diff --git a/app/code/core/Mage/Paygate/etc/config.xml b/app/code/core/Mage/Paygate/etc/config.xml
index 5db0e60fce..3b949fa0f7 100644
--- a/app/code/core/Mage/Paygate/etc/config.xml
+++ b/app/code/core/Mage/Paygate/etc/config.xml
@@ -28,7 +28,7 @@
- 0.7.0
+ 0.7.1
@@ -50,20 +50,7 @@
Mage_Paygate
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -122,14 +109,14 @@
C
Credit Card (Payflow Pro)
- https://pilot-payflowpro.verisign.com/transaction
+ https://payflowpro.paypal.com/transaction
MEDIUM
0
-
-
- 0
+
+
+ 0
diff --git a/app/code/core/Mage/Paygate/etc/system.xml b/app/code/core/Mage/Paygate/etc/system.xml
index 0831914602..839b315712 100644
--- a/app/code/core/Mage/Paygate/etc/system.xml
+++ b/app/code/core/Mage/Paygate/etc/system.xml
@@ -316,8 +316,9 @@
1
1
-
+
URL
+ Live: <strong>https://payflowpro.paypal.com/transaction</strong><br />Test: <strong>https://pilot-payflowpro.paypal.com/transaction</strong>
text
2
1
diff --git a/app/code/core/Mage/Payment/Helper/Data.php b/app/code/core/Mage/Payment/Helper/Data.php
index 535eb4bba4..d04c974f7c 100644
--- a/app/code/core/Mage/Payment/Helper/Data.php
+++ b/app/code/core/Mage/Payment/Helper/Data.php
@@ -44,13 +44,13 @@ public function getMethodInstance($code)
$key = self::XML_PATH_PAYMENT_METHODS.'/'.$code.'/model';
$class = Mage::getStoreConfig($key);
if (!$class) {
- Mage::throwException($this->__('Can not configuration for payment method with code: %s', $code));
+ Mage::throwException($this->__('Cannot load configuration for payment method "%s"', $code));
}
return Mage::getModel($class);
}
/**
- * Retrieve available payment methods for store
+ * Get and sort available payment methods for specified or current store
*
* array structure:
* $index => Varien_Simplexml_Element
@@ -58,61 +58,34 @@ public function getMethodInstance($code)
* @param mixed $store
* @return array
*/
- public function getStoreMethods($store=null, $quote=null)
+ public function getStoreMethods($store = null, $quote = null)
{
$methods = Mage::getStoreConfig(self::XML_PATH_PAYMENT_METHODS, $store);
$res = array();
foreach ($methods as $code => $methodConfig) {
- $prefix = self::XML_PATH_PAYMENT_METHODS.'/'.$code.'/';
-
- if (!Mage::getStoreConfigFlag($prefix.'active', $store)) {
- continue;
- }
- if (!$model = Mage::getStoreConfig($prefix.'model', $store)) {
+ $prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/';
+ if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) {
continue;
}
-
$methodInstance = Mage::getModel($model);
-
- if ($methodInstance instanceof Mage_Payment_Model_Method_Cc && !Mage::getStoreConfig($prefix.'cctypes')) {
- /* if the payment method has credit card types configuration option
- and no credit card type is enabled in configuration */
- continue;
- }
-
- if ( !$methodInstance->isAvailable($quote) ) {
+ if (!$methodInstance->isAvailable($quote)) {
/* if the payment method can not be used at this time */
continue;
}
- $sortOrder = (int)Mage::getStoreConfig($prefix.'sort_order', $store);
+ $sortOrder = (int)Mage::getStoreConfig($prefix . 'sort_order', $store);
$methodInstance->setSortOrder($sortOrder);
$methodInstance->setStore($store);
-// while (isset($res[$sortOrder])) {
-// $sortOrder++;
-// }
-// $res[$sortOrder] = $methodInstance;
$res[] = $methodInstance;
}
-// ksort($res);
- //die('!');
- //echo '';
- //var_dump( (array)$res);
usort($res, array($this, '_sortMethods'));
- //var_dump((array)$res);
- // echo ' ';
return $res;
}
protected function _sortMethods($a, $b)
{
- // var_dump($a);
if (is_object($a)) {
- //var_dump($a->getData());
- //var_dump($a->sort_order);
- //die ();
-
return (int)$a->sort_order < (int)$b->sort_order ? -1 : ((int)$a->sort_order > (int)$b->sort_order ? 1 : 0);
}
return 0;
@@ -154,4 +127,4 @@ public function getInfoBlock(Mage_Payment_Model_Info $info)
$block->setInfo($info);
return $block;
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Payment/Model/Method/Abstract.php b/app/code/core/Mage/Payment/Model/Method/Abstract.php
index b7e180ec84..97220b40f6 100644
--- a/app/code/core/Mage/Payment/Model/Method/Abstract.php
+++ b/app/code/core/Mage/Payment/Model/Method/Abstract.php
@@ -447,13 +447,21 @@ public function prepareSave()
}
/**
- * Return true if the method can be used at this time
+ * Check whether payment method can be used
*
+ * @param Mage_Sales_Model_Quote
* @return bool
*/
- public function isAvailable($quote=null)
+ public function isAvailable($quote = null)
{
- return true;
+ $checkResult = new StdClass;
+ $checkResult->isAvailable = (bool)(int)$this->getConfigData('active', ($quote ? $quote->getStoreId() : null));
+ Mage::dispatchEvent('payment_method_is_active', array(
+ 'result' => $checkResult,
+ 'method_instance' => $this,
+ 'quote' => $quote,
+ ));
+ return $checkResult->isAvailable;
}
/**
@@ -467,5 +475,4 @@ public function initialize($paymentAction, $stateObject)
{
return $this;
}
-
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Payment/Model/Method/Cc.php b/app/code/core/Mage/Payment/Model/Method/Cc.php
index 0311ccbf2d..4262279f16 100644
--- a/app/code/core/Mage/Payment/Model/Method/Cc.php
+++ b/app/code/core/Mage/Payment/Model/Method/Cc.php
@@ -137,7 +137,7 @@ public function validate()
$errorMsg = $this->_getHelper()->__('Credit card type is not allowed for this payment method');
}
- //validate credit card verification number
+ //validate credit card verification number
if ($errorMsg === false && $this->hasVerification()) {
$verifcationRegEx = $this->getVerificationRegEx();
$regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
@@ -154,7 +154,7 @@ public function validate()
return $this;
}
- public function hasVerification()
+ public function hasVerification()
{
$configData = $this->getConfigData('useccv');
if(is_null($configData)){
@@ -163,7 +163,7 @@ public function hasVerification()
return (bool) $configData;
}
- public function getVerificationRegEx()
+ public function getVerificationRegEx()
{
$verificationExpList = array(
'VI' => '/^[0-9]{3}$/', // Visa
@@ -240,4 +240,14 @@ public function validateCcNumOther($ccNumber)
return preg_match('/^\\d+$/', $ccNumber);
}
-}
\ No newline at end of file
+ /**
+ * Check whether there are CC types set in configuration
+ *
+ * @return bool
+ */
+ public function isAvailable($quote = null)
+ {
+ return $this->getConfigData('cctypes', ($quote ? $quote->getStoreId() : null))
+ && parent::isAvailable($quote);
+ }
+}
diff --git a/app/code/core/Mage/Payment/Model/Method/Free.php b/app/code/core/Mage/Payment/Model/Method/Free.php
index 6a1dc2fee6..ba50e9b44f 100644
--- a/app/code/core/Mage/Payment/Model/Method/Free.php
+++ b/app/code/core/Mage/Payment/Model/Method/Free.php
@@ -42,20 +42,14 @@ class Mage_Payment_Model_Method_Free extends Mage_Payment_Model_Method_Abstract
protected $_code = 'free';
/**
- * Check method is available
+ * Check whether method is available
*
* @param Mage_Sales_Model_Quote $quote
* @return bool
*/
- public function isAvailable($quote=null)
+ public function isAvailable($quote = null)
{
- if (is_null($quote)) {
- return false;
- }
-
- if (Mage::app()->getStore()->roundPrice($quote->getGrandTotal()) == 0) {
- return true;
- }
- return false;
+ return parent::isAvailable($quote) && (!empty($quote))
+ && (Mage::app()->getStore()->roundPrice($quote->getGrandTotal()) == 0);
}
}
diff --git a/app/code/core/Mage/Payment/etc/config.xml b/app/code/core/Mage/Payment/etc/config.xml
index a518c4fac3..6e1847bb63 100644
--- a/app/code/core/Mage/Payment/etc/config.xml
+++ b/app/code/core/Mage/Payment/etc/config.xml
@@ -44,9 +44,6 @@
Mage_Payment
-
- core_setup
-
@@ -93,7 +90,6 @@
- singleton
payment/observer
salesOrderBeforeSave
@@ -124,25 +120,6 @@
-
-
-
-
-
-
-
-
-
- Payment Methods Section
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Paypal/Block/Link/Shortcut.php b/app/code/core/Mage/Paypal/Block/Link/Shortcut.php
index 98291af078..6e17d7bb62 100644
--- a/app/code/core/Mage/Paypal/Block/Link/Shortcut.php
+++ b/app/code/core/Mage/Paypal/Block/Link/Shortcut.php
@@ -48,13 +48,17 @@ public function getImageUrl()
return 'https://www.paypal.com/'.$locale.'/i/btn/btn_xpressCheckout.gif';
}
+ /**
+ * Check whether method is available and render HTML
+ *
+ * @return string
+ */
public function _toHtml()
{
- if (Mage::getStoreConfigFlag('payment/paypal_express/active')
- && Mage::getSingleton('checkout/session')->getQuote()->validateMinimumAmount()) {
- return parent::_toHtml();
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
+ if (!Mage::getModel('paypal/express')->isAvailable($quote) || !$quote->validateMinimumAmount()) {
+ return '';
}
-
- return '';
+ return parent::_toHtml();
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Paypal/Model/Standard.php b/app/code/core/Mage/Paypal/Model/Standard.php
index a5c7e2e50a..348950b768 100644
--- a/app/code/core/Mage/Paypal/Model/Standard.php
+++ b/app/code/core/Mage/Paypal/Model/Standard.php
@@ -490,7 +490,7 @@ public function initialize($paymentAction, $stateObject)
{
$state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
$stateObject->setState($state);
- $stateObject->setStatus(Mage::getSingleton('sales/order_config')->getStateDefaultStatus($state));
+ $stateObject->setStatus('pending_paypal');
$stateObject->setIsNotified(false);
}
}
diff --git a/app/code/core/Mage/Paypal/etc/config.xml b/app/code/core/Mage/Paypal/etc/config.xml
index 93d7e78619..3c0d591d1f 100644
--- a/app/code/core/Mage/Paypal/etc/config.xml
+++ b/app/code/core/Mage/Paypal/etc/config.xml
@@ -50,24 +50,25 @@
Mage_Paypal
Mage_Paypal_Model_Mysql4_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
Mage_Paypal_Block
+
+
+
+ Pending PayPal
+
+
+
+
+
+
+
+
+
+
@@ -110,25 +111,6 @@
-
-
-
-
-
-
-
-
-
- PayPal Section
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/PaypalUk/etc/config.xml b/app/code/core/Mage/PaypalUk/etc/config.xml
index 8199705649..b9ed29868d 100644
--- a/app/code/core/Mage/PaypalUk/etc/config.xml
+++ b/app/code/core/Mage/PaypalUk/etc/config.xml
@@ -55,24 +55,25 @@
Mage_PaypalUk
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
Mage_PaypalUk_Block
+
+
+
+ Pending PayPal
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/core/Mage/Poll/Block/ActivePoll.php b/app/code/core/Mage/Poll/Block/ActivePoll.php
index df4e197ca0..90cdf4614c 100755
--- a/app/code/core/Mage/Poll/Block/ActivePoll.php
+++ b/app/code/core/Mage/Poll/Block/ActivePoll.php
@@ -79,7 +79,7 @@ public function __construct()
$this->assign('poll', $poll)
->assign('poll_answers', $pollAnswers)
- ->assign('action', Mage::getUrl('poll/vote/add', array('poll_id' => $pollId)));
+ ->assign('action', Mage::getUrl('poll/vote/add', array('poll_id' => $pollId, '_secure' => true)));
$this->_voted = Mage::getModel('poll/poll')->isVoted($pollId);
Mage::getSingleton('core/session')->setJustVotedPoll(false);
diff --git a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Collection.php b/app/code/core/Mage/Poll/Model/Mysql4/Poll/Collection.php
index a105cdba5e..348fe775aa 100644
--- a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Collection.php
+++ b/app/code/core/Mage/Poll/Model/Mysql4/Poll/Collection.php
@@ -63,7 +63,7 @@ public function addFieldToFilter($field, $condition=null)
*/
public function addStoresFilter($store)
{
- return $this->addStoresFilter($store);
+ return $this->addStoreFilter($store);
}
/**
diff --git a/app/code/core/Mage/Poll/etc/config.xml b/app/code/core/Mage/Poll/etc/config.xml
index 96432d60aa..33e531db77 100644
--- a/app/code/core/Mage/Poll/etc/config.xml
+++ b/app/code/core/Mage/Poll/etc/config.xml
@@ -100,20 +100,7 @@
Mage_Poll
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
diff --git a/app/code/core/Mage/ProductAlert/Model/Observer.php b/app/code/core/Mage/ProductAlert/Model/Observer.php
index 65bfbc5ad5..80e996603d 100644
--- a/app/code/core/Mage/ProductAlert/Model/Observer.php
+++ b/app/code/core/Mage/ProductAlert/Model/Observer.php
@@ -150,9 +150,12 @@ protected function _processPrice(Mage_ProductAlert_Model_Email $email)
}
$product->setCustomerGroupId($customer->getGroupId());
if ($alert->getPrice() > $product->getFinalPrice()) {
+ $productPrice = $product->getFinalPrice();
+ $product->setFinalPrice(Mage::helper('tax')->getPrice($product, $productPrice));
+ $product->setPrice(Mage::helper('tax')->getPrice($product, $product->getPrice()));
$email->addPriceProduct($product);
- $alert->setPrice($product->getFinalPrice());
+ $alert->setPrice($productPrice);
$alert->setLastSendDate(Mage::getModel('core/date')->gmtDate());
$alert->setSendCount($alert->getSendCount() + 1);
$alert->setStatus(1);
diff --git a/app/code/core/Mage/ProductAlert/etc/config.xml b/app/code/core/Mage/ProductAlert/etc/config.xml
index 2f067f7277..46e29306d9 100644
--- a/app/code/core/Mage/ProductAlert/etc/config.xml
+++ b/app/code/core/Mage/ProductAlert/etc/config.xml
@@ -60,20 +60,7 @@
Mage_ProductAlert
-
- core_setup
-
-
-
- core_setup
-
-
-
-
- core_setup
-
-
diff --git a/app/code/core/Mage/ProductAlert/etc/system.xml b/app/code/core/Mage/ProductAlert/etc/system.xml
index 0924faae93..f64446ddab 100644
--- a/app/code/core/Mage/ProductAlert/etc/system.xml
+++ b/app/code/core/Mage/ProductAlert/etc/system.xml
@@ -35,7 +35,7 @@
250
1
1
- 0
+ 1
Allow alert when product price changes
@@ -63,7 +63,7 @@
2
1
1
- 0
+ 1
Stock alert Email Template
@@ -72,7 +72,7 @@
4
1
1
- 0
+ 1
Alert Email Sender
@@ -81,7 +81,7 @@
5
1
1
- 0
+ 1
diff --git a/app/code/core/Mage/Rating/etc/config.xml b/app/code/core/Mage/Rating/etc/config.xml
index 8cc68b3703..4c5c828a13 100644
--- a/app/code/core/Mage/Rating/etc/config.xml
+++ b/app/code/core/Mage/Rating/etc/config.xml
@@ -72,20 +72,7 @@
Mage_Rating
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -106,25 +93,6 @@
-
-
-
-
-
-
-
-
-
- Manage Ratings
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Reports/Block/Product/Abstract.php b/app/code/core/Mage/Reports/Block/Product/Abstract.php
index 561f956bf8..95dfeac5c2 100644
--- a/app/code/core/Mage/Reports/Block/Product/Abstract.php
+++ b/app/code/core/Mage/Reports/Block/Product/Abstract.php
@@ -111,7 +111,9 @@ public function getItemsCollection()
->addAttributeToSelect($attributes)
->addIndexFilter()
->excludeProductIds($this->_getModel()->getExcludeProductIds())
- ->setAddedAtOrder();
+ ->setAddedAtOrder()
+ ->setPageSize($this->getPageSize())
+ ->setCurPage(1);
Mage::getSingleton('catalog/product_visibility')
->addVisibleInSiteFilterToCollection($this->_collection);
diff --git a/app/code/core/Mage/Reports/Model/Mysql4/Order/Collection.php b/app/code/core/Mage/Reports/Model/Mysql4/Order/Collection.php
index 33e2249895..9be0a19800 100644
--- a/app/code/core/Mage/Reports/Model/Mysql4/Order/Collection.php
+++ b/app/code/core/Mage/Reports/Model/Mysql4/Order/Collection.php
@@ -298,7 +298,11 @@ public function setStoreIds($storeIds)
->addExpressionAttributeToSelect(
'refunded',
'SUM({{base_total_refunded}})',
- array('base_total_refunded'));
+ array('base_total_refunded'))
+ ->addExpressionAttributeToSelect(
+ 'profit',
+ 'SUM({{base_total_paid}}) - SUM({{base_total_refunded}}) - SUM({{base_total_invoiced_cost}})',
+ array('base_total_paid', 'base_total_refunded', 'base_total_invoiced_cost'));
} else {
$this->addExpressionAttributeToSelect(
'subtotal',
@@ -327,7 +331,11 @@ public function setStoreIds($storeIds)
->addExpressionAttributeToSelect(
'refunded',
'SUM({{base_total_refunded}}*{{base_to_global_rate}})',
- array('base_total_refunded', 'base_to_global_rate'));
+ array('base_total_refunded', 'base_to_global_rate'))
+ ->addExpressionAttributeToSelect(
+ 'profit',
+ 'SUM({{base_total_paid}}*{{base_to_global_rate}}) - SUM({{base_total_refunded}}*{{base_to_global_rate}}) - SUM({{base_total_invoiced_cost}}*{{base_to_global_rate}})',
+ array('base_total_paid', 'base_total_refunded', 'base_total_invoiced_cost', 'base_to_global_rate'));
}
return $this;
@@ -460,4 +468,22 @@ public function getSelectCountSql()
return $sql;
}
+
+ /**
+ * Add period filter by created_at attribute
+ *
+ * @param string $period
+ * @return Mage_Reports_Model_Mysql4_Order_Collection
+ */
+ public function addCreateAtPeriodFilter($period)
+ {
+ list($from, $to) = $this->getDateRange($period, 0, 0, true);
+
+ $this->addAttributeToFilter('created_at', array(
+ 'from' => $from->toString(Varien_Date::DATETIME_INTERNAL_FORMAT),
+ 'to' => $to->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
+ ));
+
+ return $this;
+ }
}
diff --git a/app/code/core/Mage/Reports/Model/Mysql4/Product/Lowstock/Collection.php b/app/code/core/Mage/Reports/Model/Mysql4/Product/Lowstock/Collection.php
index 0a208b9a9d..0521f07366 100644
--- a/app/code/core/Mage/Reports/Model/Mysql4/Product/Lowstock/Collection.php
+++ b/app/code/core/Mage/Reports/Model/Mysql4/Product/Lowstock/Collection.php
@@ -1,174 +1,237 @@
-
- */
-
-class Mage_Reports_Model_Mysql4_Product_Lowstock_Collection extends Mage_Reports_Model_Mysql4_Product_Collection
-{
- protected $_inventoryItemResource = null;
- protected $_inventoryItemJoined = false;
- protected $_inventoryItemTableAlias = 'lowstock_inventory_item';
-
- /**
- * @return string
- */
- protected function _getInventoryItemResource()
- {
- if (is_null($this->_inventoryItemResource)) {
- $this->_inventoryItemResource = Mage::getResourceSingleton('cataloginventory/stock_item');
- }
- return $this->_inventoryItemResource;
- }
-
- /**
- * @return string
- */
- protected function _getInventoryItemTable()
- {
- return $this->_getInventoryItemResource()->getMainTable();
- }
-
- /**
- * @return string
- */
- protected function _getInventoryItemIdField()
- {
- return $this->_getInventoryItemResource()->getIdFieldName();
- }
-
- /**
- * @return string
- */
- protected function _getInventoryItemTableAlias()
- {
- return $this->_inventoryItemTableAlias;
- }
-
- /**
- * @param array|string $fields
- * @return string
- */
- protected function _processInventoryItemFields($fields)
- {
- if (is_array($fields)) {
- $aliasArr = array();
- foreach ($fields as &$field) {
- if ( is_string($field) && strpos($field, '(') === false ) {
- $field = sprintf('%s.%s', $this->_getInventoryItemTableAlias(), $field);
- }
- }
- unset($field);
- return $fields;
- }
- return sprintf('%s.%s', $this->_getInventoryItemTableAlias(), $fields);
- }
-
- /**
- * Join cataloginventory_stock_item table for further
- * stock_item values filters
- * @return Mage_Reports_Model_Mysql4_Product_Collection
- */
- public function joinInventoryItem($fields=array()) {
- if ( !$this->_inventoryItemJoined ) {
- $this->getSelect()->join(
- array($this->_getInventoryItemTableAlias() => $this->_getInventoryItemTable()),
- sprintf('e.%s=%s.product_id',
- $this->getEntity()->getEntityIdField(),
- $this->_getInventoryItemTableAlias()
- ),
- array()
- );
- $this->_inventoryItemJoined = true;
- }
- if (is_string($fields)) {
- $fields = array($fields);
- }
- if (!empty($fields)) {
- $this->getSelect()->columns($this->_processInventoryItemFields($fields));
- }
- return $this;
- }
-
- /**
- * @param array|string $typeFilter
- * @return Mage_Reports_Model_Mysql4_Product_Collection
- */
- public function filterByProductType($typeFilter)
- {
- if (!is_string($typeFilter) && !is_array($typeFilter)) {
- Mage::throwException(
- Mage::helper('catalog')->__('Wrong product type filter specified')
- );
- }
- $this->addAttributeToFilter('type_id', $typeFilter);
- return $this;
- }
-
- /**
- * @return Mage_Reports_Model_Mysql4_Product_Collection
- */
- public function filterByIsQtyProductTypes()
- {
- $this->filterByProductType(
- array_keys(array_filter(Mage::helper('cataloginventory')->getIsQtyTypeIds()))
- );
- return $this;
- }
-
- /**
- * @param int|null $storeId
- * @return Mage_Reports_Model_Mysql4_Product_Collection
- */
- public function useManageStockFilter($storeId=null)
- {
- $this->joinInventoryItem();
- $this->getSelect()->where(sprintf('IF(%s,%d,%s)=1',
- $this->_processInventoryItemFields('use_config_manage_stock'),
- (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK,$storeId),
- $this->_processInventoryItemFields('manage_stock')));
- return $this;
- }
-
- /**
- * @param int|null $storeId
- * @return Mage_Reports_Model_Mysql4_Product_Collection
- */
- public function useNotifyStockQtyFilter($storeId=null)
- {
- $this->joinInventoryItem(array('qty'));
- $this->getSelect()->where(sprintf('qty < IF(%s,%d,%s)',
- $this->_processInventoryItemFields('use_config_notify_stock_qty'),
- (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY,$storeId),
- $this->_processInventoryItemFields('notify_stock_qty')));
- return $this;
- }
-}
+
+ */
+class Mage_Reports_Model_Mysql4_Product_Lowstock_Collection extends Mage_Reports_Model_Mysql4_Product_Collection
+{
+ /**
+ * CatalogInventory Stock Item Resource instance
+ *
+ * @var Mage_CatalogInventory_Model_Mysql4_Stock_Item
+ */
+ protected $_inventoryItemResource = null;
+
+ /**
+ * Flag about is joined CatalogInventory Stock Item
+ *
+ * @var bool
+ */
+ protected $_inventoryItemJoined = false;
+
+ /**
+ * Alias for CatalogInventory Stock Item Table
+ *
+ * @var string
+ */
+ protected $_inventoryItemTableAlias = 'lowstock_inventory_item';
+
+ /**
+ * Retrieve CatalogInventory Stock Item Resource instance
+ *
+ * @return Mage_CatalogInventory_Model_Mysql4_Stock_Item
+ */
+ protected function _getInventoryItemResource()
+ {
+ if (is_null($this->_inventoryItemResource)) {
+ $this->_inventoryItemResource = Mage::getResourceSingleton('cataloginventory/stock_item');
+ }
+ return $this->_inventoryItemResource;
+ }
+
+ /**
+ * Retrieve CatalogInventory Stock Item Table
+ *
+ * @return string
+ */
+ protected function _getInventoryItemTable()
+ {
+ return $this->_getInventoryItemResource()->getMainTable();
+ }
+
+ /**
+ * Retrieve CatalogInventory Stock Item Table Id field name
+ *
+ * @return string
+ */
+ protected function _getInventoryItemIdField()
+ {
+ return $this->_getInventoryItemResource()->getIdFieldName();
+ }
+
+ /**
+ * Retrieve alias for CatalogInventory Stock Item Table
+ *
+ * @return string
+ */
+ protected function _getInventoryItemTableAlias()
+ {
+ return $this->_inventoryItemTableAlias;
+ }
+
+ /**
+ * Add catalog inventory stock item field to select
+ *
+ * @param string $field
+ * @param string $alias
+ * @return Mage_Reports_Model_Mysql4_Product_Lowstock_Collection
+ */
+ protected function _addInventoryItemFieldToSelect($field, $alias = null)
+ {
+ if (empty($alias)) {
+ $alias = $field;
+ }
+
+ if (isset($this->_joinFields[$alias])) {
+ return $this;
+ }
+
+ $this->_joinFields[$alias] = array(
+ 'table' => $this->_getInventoryItemTableAlias(),
+ 'field' => $field
+ );
+
+ $this->getSelect()->columns(array($alias => $field), $this->_getInventoryItemTableAlias());
+ return $this;
+ }
+
+ /**
+ * Retrieve catalog inventory stock item field correlation name
+ *
+ * @param string $field
+ * @return string
+ */
+ protected function _getInventoryItemField($field)
+ {
+ return sprintf('%s.%s', $this->_getInventoryItemTableAlias(), $field);
+ }
+
+ /**
+ * Join catalog inventory stock item table for further stock_item values filters
+ *
+ * @return Mage_Reports_Model_Mysql4_Product_Collection
+ */
+ public function joinInventoryItem($fields = array())
+ {
+ if (!$this->_inventoryItemJoined) {
+ $this->getSelect()->join(
+ array($this->_getInventoryItemTableAlias() => $this->_getInventoryItemTable()),
+ sprintf('`e`.`%s`=`%s`.`product_id`',
+ $this->getEntity()->getEntityIdField(),
+ $this->_getInventoryItemTableAlias()
+ ),
+ array()
+ );
+ $this->_inventoryItemJoined = true;
+ }
+
+ if (!is_array($fields)) {
+ if (empty($fields)) {
+ $fields = array();
+ } else {
+ $fields = array($fields);
+ }
+ }
+
+ foreach ($fields as $alias => $field) {
+ if (!is_string($alias)) {
+ $alias = null;
+ }
+ $this->_addInventoryItemFieldToSelect($field, $alias);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add filter by product type(s)
+ *
+ * @param array|string $typeFilter
+ * @return Mage_Reports_Model_Mysql4_Product_Collection
+ */
+ public function filterByProductType($typeFilter)
+ {
+ if (!is_string($typeFilter) && !is_array($typeFilter)) {
+ Mage::throwException(
+ Mage::helper('catalog')->__('Wrong product type filter specified')
+ );
+ }
+ $this->addAttributeToFilter('type_id', $typeFilter);
+ return $this;
+ }
+
+ /**
+ * Add filter by product types from config
+ * Only types witch has QTY parameter
+ *
+ * @return Mage_Reports_Model_Mysql4_Product_Collection
+ */
+ public function filterByIsQtyProductTypes()
+ {
+ $this->filterByProductType(
+ array_keys(array_filter(Mage::helper('cataloginventory')->getIsQtyTypeIds()))
+ );
+ return $this;
+ }
+
+ /**
+ * Add Use Manage Stock Condition to collection
+ *
+ * @param int|null $storeId
+ * @return Mage_Reports_Model_Mysql4_Product_Collection
+ */
+ public function useManageStockFilter($storeId = null)
+ {
+ $this->joinInventoryItem();
+ $this->getSelect()->where(sprintf('IF(%s,%d,%s)=1',
+ $this->_getInventoryItemField('use_config_manage_stock'),
+ (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK,$storeId),
+ $this->_getInventoryItemIdField('manage_stock')));
+ return $this;
+ }
+
+ /**
+ * Add Notify Stock Qty Condition to collection
+ *
+ * @param int $storeId
+ * @return Mage_Reports_Model_Mysql4_Product_Collection
+ */
+ public function useNotifyStockQtyFilter($storeId = null)
+ {
+ $this->joinInventoryItem(array('qty'));
+ $this->getSelect()->where(sprintf('qty < IF(%s,%d,%s)',
+ $this->_getInventoryItemField('use_config_notify_stock_qty'),
+ (int)Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY,$storeId),
+ $this->_getInventoryItemField('notify_stock_qty')));
+ return $this;
+ }
+}
diff --git a/app/code/core/Mage/Reports/Model/Mysql4/Quote/Collection.php b/app/code/core/Mage/Reports/Model/Mysql4/Quote/Collection.php
index 296719dd8a..aff458fe28 100644
--- a/app/code/core/Mage/Reports/Model/Mysql4/Quote/Collection.php
+++ b/app/code/core/Mage/Reports/Model/Mysql4/Quote/Collection.php
@@ -36,6 +36,8 @@ class Mage_Reports_Model_Mysql4_Quote_Collection extends Mage_Sales_Model_Mysql4
{
protected $_joinedFields = array();
+ protected $_map = array('fields' => array('store_id' => 'main_table.store_id'));
+
public function prepareForAbandonedReport($storeIds, $filter = null)
{
$this->addFieldToFilter('items_count', array('neq' => '0'))
@@ -43,13 +45,24 @@ public function prepareForAbandonedReport($storeIds, $filter = null)
->addSubtotal($storeIds, $filter)
->addCustomerData($filter)
->setOrder('updated_at');
-
if (is_array($storeIds)) {
- $this->addFieldToFilter('main_table.store_id', array('in' => $storeIds));
+ $this->addFieldToFilter('store_id', array('in' => $storeIds));
}
return $this;
}
+ /**
+ * Add store ids to filter
+ *
+ * @param array $storeIds
+ * @return Mage_Reports_Model_Mysql4_Quote_Collection
+ */
+ public function addStoreFilter($storeIds)
+ {
+ $this->addFieldToFilter('store_id', array('in' => $storeIds));
+ return $this;
+ }
+
public function addCustomerData($filter = null)
{
$customerEntity = Mage::getResourceSingleton('customer/customer');
diff --git a/app/code/core/Mage/Reports/etc/config.xml b/app/code/core/Mage/Reports/etc/config.xml
index 2a0aae3760..2ace0cb32f 100644
--- a/app/code/core/Mage/Reports/etc/config.xml
+++ b/app/code/core/Mage/Reports/etc/config.xml
@@ -28,7 +28,7 @@
- 0.7.8
+ 0.7.9
@@ -61,26 +61,12 @@
Mage_Reports
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
- singleton
reports/event_observer
eventClean
@@ -99,278 +85,6 @@
-
-
-
- Reports
- 80
-
-
- Sales
-
-
- Sales Report
- adminhtml/report_sales/sales
-
-
- Tax
- adminhtml/report_sales/tax
-
-
- Shipping
- adminhtml/report_sales/shipping
-
-
- Total invoiced
- adminhtml/report_sales/invoiced
-
-
- Total refunded
- adminhtml/report_sales/refunded
-
-
- Coupons
- adminhtml/report_sales/coupons
-
-
-
-
- Shopping Cart
-
-
- Products in carts
- adminhtml/report_shopcart/product
-
-
- Abandoned carts
- adminhtml/report_shopcart/abandoned
-
-
-
-
-
- Products
-
-
- Bestsellers
- adminhtml/report_product/ordered
-
-
- Products Ordered
- adminhtml/report_product/sold
-
-
- Most Viewed
- adminhtml/report_product/viewed
-
-
- Low stock
- adminhtml/report_product/lowstock
-
-
- Downloads
- adminhtml/report_product/downloads
-
-
-
-
- Customers
-
-
- New Accounts
- adminhtml/report_customer/accounts
-
-
- Customers by orders total
- adminhtml/report_customer/totals
-
-
- Customers by number of orders
- adminhtml/report_customer/orders
-
-
-
-
-
- Reviews
-
-
- Customers Reviews
- adminhtml/report_review/customer
-
-
- Products Reviews
- adminhtml/report_review/product
-
-
-
-
- Tags
-
-
- Customers
- adminhtml/report_tag/customer
-
-
- Products
- adminhtml/report_tag/product
-
-
-
- Popular
- adminhtml/report_tag/popular
-
-
-
-
- Search Terms
- adminhtml/report/search
-
-
-
-
-
-
-
-
-
-
- Reports
- 80
-
-
- Sales
-
-
- Sales Report
-
-
- Tax
-
-
- Shipping
-
-
- Total invoiced
-
-
- Total refunded
-
-
- Coupons
-
-
-
-
- Shopping Cart
-
-
- Products in carts
-
-
- Abandoned carts
-
-
-
-
- Products
-
-
- Bestsellers
-
-
- Products Ordered
-
-
- Most Viewed
-
-
- Low stock
-
-
- Downloads
-
-
-
-
- Customers
-
-
- New Accounts
-
-
- Customers by orders total
-
-
- Customers by number of orders
-
-
-
-
- Reviews
-
-
- Customers Reviews
-
-
- Products Reviews
-
-
-
-
- Tags
-
-
- Customers
-
-
- Popular
-
-
- Products
-
-
-
-
- Search Terms
-
-
-
-
-
-
-
-
- Reports
-
-
-
-
-
-
-
-
-
@@ -393,7 +107,6 @@
- singleton
reports/event_observer
catalogProductCompareRemoveProduct
@@ -402,7 +115,6 @@
- singleton
reports/event_observer
customerLogin
@@ -411,7 +123,6 @@
- singleton
reports/event_observer
customerLogout
@@ -420,7 +131,6 @@
- singleton
reports/event_observer
catalogProductView
@@ -429,7 +139,6 @@
- singleton
reports/event_observer
sendfriendProduct
@@ -438,7 +147,6 @@
- singleton
reports/event_observer
catalogProductCompareAddProduct
@@ -447,7 +155,6 @@
- singleton
reports/event_observer
catalogProductCompareClear
@@ -456,7 +163,6 @@
- singleton
reports/event_observer
checkoutCartAddProduct
@@ -465,7 +171,6 @@
- singleton
reports/event_observer
wishlistAddProduct
@@ -474,7 +179,6 @@
- singleton
reports/event_observer
wishlistShare
diff --git a/app/code/core/Mage/Reports/etc/system.xml b/app/code/core/Mage/Reports/etc/system.xml
index 0b0b1838da..5f9a6cf67e 100644
--- a/app/code/core/Mage/Reports/etc/system.xml
+++ b/app/code/core/Mage/Reports/etc/system.xml
@@ -93,7 +93,7 @@
0
- Month-To-Date Starts
+ Current Month Starts
select
adminhtml/report_config_form_field_mtdStart
Select day of the month
diff --git a/app/code/core/Mage/Review/Block/Helper.php b/app/code/core/Mage/Review/Block/Helper.php
index 6b367abd4c..737d3fc24d 100644
--- a/app/code/core/Mage/Review/Block/Helper.php
+++ b/app/code/core/Mage/Review/Block/Helper.php
@@ -33,7 +33,7 @@
*/
class Mage_Review_Block_Helper extends Mage_Core_Block_Template
{
- private $_availableTemplates = array(
+ protected $_availableTemplates = array(
'default' => 'review/helper/summary.phtml',
'short' => 'review/helper/summary_short.phtml'
);
diff --git a/app/code/core/Mage/Review/Model/Review.php b/app/code/core/Mage/Review/Model/Review.php
index 8bb34a5d21..9453d14d3e 100644
--- a/app/code/core/Mage/Review/Model/Review.php
+++ b/app/code/core/Mage/Review/Model/Review.php
@@ -33,6 +33,14 @@
*/
class Mage_Review_Model_Review extends Mage_Core_Model_Abstract
{
+
+ /**
+ * Event prefix for observer
+ *
+ * @var string
+ */
+ protected $_eventPrefix = 'review';
+
const ENTITY_PRODUCT = 1;
const STATUS_APPROVED = 1;
diff --git a/app/code/core/Mage/Review/etc/config.xml b/app/code/core/Mage/Review/etc/config.xml
index 70ee91e642..ca7b227191 100644
--- a/app/code/core/Mage/Review/etc/config.xml
+++ b/app/code/core/Mage/Review/etc/config.xml
@@ -66,20 +66,7 @@
Mage_Review
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -88,62 +75,6 @@
-
-
-
-
- Reviews and Ratings
-
-
- Customer Reviews
-
-
- Pending Reviews
- adminhtml/catalog_product_review/pending/
-
-
- All Reviews
- adminhtml/catalog_product_review/
-
-
-
-
- Manage Ratings
- adminhtml/rating/
-
-
-
-
-
-
-
-
-
-
-
-
-
- Reviews and Ratings
-
-
- Customer Reviews
-
-
- All Reviews
-
-
- Pending Reviews
-
-
-
-
-
-
-
-
-
-
-
@@ -164,6 +95,16 @@
+
+
+
+
+ rss/observer
+ reviewSaveAfter
+
+
+
+
diff --git a/app/code/core/Mage/Rss/Block/Catalog/Category.php b/app/code/core/Mage/Rss/Block/Catalog/Category.php
index 70978f0733..80344fd5ca 100644
--- a/app/code/core/Mage/Rss/Block/Catalog/Category.php
+++ b/app/code/core/Mage/Rss/Block/Catalog/Category.php
@@ -63,8 +63,7 @@ protected function _toHtml()
'link' => $newurl,
'charset' => 'UTF-8',
);
-//echo "";
-//print_r($data);
+
$rssObj->_addHeader($data);
$_collection = $category->getCollection();
@@ -81,18 +80,6 @@ protected function _toHtml()
$layer->prepareProductCollection($productCollection);
$productCollection->addCountToCategories($_collection);
- /*if ($_collection->count()) {
- foreach ($_collection as $_category){
- $data = array(
- 'title' => $_category->getName(),
- 'link' => $_category->getCategoryUrl(),
- 'description' => $this->helper('rss')->__('Total Products: %s', $_category->getProductCount()),
- );
-
- $rssObj->_addEntry($data);
- }
- }
- */
$category->getProductCollection()->setStoreId($storeId);
/*
only load latest 50 products
@@ -100,35 +87,61 @@ protected function _toHtml()
$_productCollection = $currentyCateogry
->getProductCollection()
->addAttributeToSort('updated_at','desc')
+ ->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds())
->setCurPage(1)
->setPageSize(50)
;
-//echo " ".$_productCollection->getSelect();
+
if ($_productCollection->getSize()>0) {
+ $args = array('rssObj' => $rssObj);
foreach ($_productCollection as $_product) {
- $final_price = $_product->getFinalPrice();
- $description = ' '.
- ' '.
- ''.$_product->getDescription().
- ' Price:'.Mage::helper('core')->currency($_product->getPrice()).
- ($_product->getPrice() != $final_price ? ' Special Price:'. Mage::helper('core')->currency($final_price) : '').
- '
'.
- ' '.
- '
'
- ;
- $data = array(
- 'title' => $_product->getName(),
- 'link' => $_product->getProductUrl(),
- 'description' => $description,
- );
-//print_r($data);
- $rssObj->_addEntry($data);
+ $args['product'] = $_product;
+ $this->addNewItemXmlCallback($args);
}
}
}
}
return $rssObj->createRssXml();
+ }
+
+ /**
+ * Preparing data and adding to rss object
+ *
+ * @param array $args
+ */
+ public function addNewItemXmlCallback($args)
+ {
+ $product = $args['product'];
+ $product->setAllowedInRss(true);
+
+ Mage::dispatchEvent('rss_catalog_category_xml_callback', $args);
+
+ if (!$product->getAllowedInRss()) {
+ return;
+ }
+
+ $description = ''
+ . ' '
+ . '' . $product->getDescription();
+
+ if ($product->getAllowedPriceInRss()) {
+ $description .= ' Price:'.Mage::helper('core')->currency($product->getPrice());
+ if ($product->getPrice() != $product->getFinalPrice()) {
+ $description .= ' Special Price:' . Mage::helper('core')->currency($product->getFinalPrice());
+ }
+ $description .= '
';
+ }
+
+ $description .= '
';
+ $rssObj = $args['rssObj'];
+ $data = array(
+ 'title' => $product->getName(),
+ 'link' => $product->getProductUrl(),
+ 'description' => $description,
+ );
+ $rssObj->_addEntry($data);
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Rss/Block/Catalog/New.php b/app/code/core/Mage/Rss/Block/Catalog/New.php
index 422922b384..8b54f6d513 100644
--- a/app/code/core/Mage/Rss/Block/Catalog/New.php
+++ b/app/code/core/Mage/Rss/Block/Catalog/New.php
@@ -77,19 +77,24 @@ protected function _toHtml()
->addAttributeToSelect(array('special_price', 'special_from_date', 'special_to_date'), 'left')
;
- Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
- Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
-//echo $products->getSelect();
+ $products->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
+
/*
using resource iterator to load the data one by one
instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
*/
+
Mage::getSingleton('core/resource_iterator')
->walk($products->getSelect(), array(array($this, 'addNewItemXmlCallback')), array('rssObj'=> $rssObj, 'product'=>$product));
return $rssObj->createRssXml();
}
+ /**
+ * Preparing data and adding to rss object
+ *
+ * @param array $args
+ */
public function addNewItemXmlCallback($args)
{
$product = $args['product'];
@@ -102,24 +107,31 @@ public function addNewItemXmlCallback($args)
return;
}
+ $allowedPriceInRss = $product->getAllowedPriceInRss();
+
//$product->unsetData()->load($args['row']['entity_id']);
$product->setData($args['row']);
- $final_price = $product->getFinalPrice();
$description = ''.
' '.
- ''.$product->getDescription().
- ' Price:'.Mage::helper('core')->currency($product->getPrice()).
- ($product->getPrice() != $final_price ? ' Special Price:'. Mage::helper('core')->currency($final_price) : '').
- '
'.
- ' '.
+ ''.$product->getDescription();
+
+ if ($allowedPriceInRss) {
+ $description .= ' Price:' . Mage::helper('core')->currency($product->getPrice());
+ if ($product->getPrice() != $product->getFinalPrice()){
+ $description .= ' Special Price:' . Mage::helper('core')->currency($product->getFinalPrice());
+ }
+ $description .= '
';
+ }
+
+ $description .= ' '.
'
';
+
$rssObj = $args['rssObj'];
$data = array(
'title' => $product->getName(),
'link' => $product->getProductUrl(),
'description' => $description,
-
- );
+ );
$rssObj->_addEntry($data);
}
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php b/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php
index 9676c28d5a..0c3340d146 100644
--- a/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php
+++ b/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php
@@ -29,12 +29,21 @@
*
* @category Mage
* @package Mage_Rss
- * @author Magento Core Team
+ * @author Magento Core Team
*/
class Mage_Rss_Block_Catalog_NotifyStock extends Mage_Rss_Block_Abstract
{
+
+ /**
+ * Cache tag constant for feed notify stock
+ *
+ * @var string
+ */
+ const CACHE_TAG = 'block_html_rss_catalog_notifystock';
+
protected function _construct()
{
+ $this->setCacheTags(array(self::CACHE_TAG));
/*
* setting cache to save the rss for 10 minutes
*/
diff --git a/app/code/core/Mage/Rss/Block/Catalog/Review.php b/app/code/core/Mage/Rss/Block/Catalog/Review.php
index bae3cba6f5..8960393ce3 100644
--- a/app/code/core/Mage/Rss/Block/Catalog/Review.php
+++ b/app/code/core/Mage/Rss/Block/Catalog/Review.php
@@ -29,12 +29,21 @@
*
* @category Mage
* @package Mage_Rss
- * @author Magento Core Team
+ * @author Magento Core Team
*/
class Mage_Rss_Block_Catalog_Review extends Mage_Rss_Block_Abstract
{
+
+ /**
+ * Cache tag constant for feed reviews
+ *
+ * @var string
+ */
+ const CACHE_TAG = 'block_html_rss_catalog_review';
+
protected function _construct()
{
+ $this->setCacheTags(array(self::CACHE_TAG));
/*
* setting cache to save the rss for 10 minutes
*/
diff --git a/app/code/core/Mage/Rss/Block/Catalog/Special.php b/app/code/core/Mage/Rss/Block/Catalog/Special.php
index 6fa5c48191..07eae45e0c 100644
--- a/app/code/core/Mage/Rss/Block/Catalog/Special.php
+++ b/app/code/core/Mage/Rss/Block/Catalog/Special.php
@@ -68,27 +68,19 @@ protected function _toHtml()
->joinTable('catalogrule/rule_product_price', 'product_id=entity_id', array('rule_price'=>'rule_price', 'rule_start_date'=>'latest_start_date'), $rulePriceWhere, 'left')
;
-//public function join($table, $cond, $cols='*')
$rulePriceCollection = Mage::getResourceModel('catalogrule/rule_product_price_collection')
->addFieldToFilter('website_id', $websiteId)
->addFieldToFilter('customer_group_id', $custGroup)
->addFieldToFilter('rule_date', $todayDate)
;
-//echo $rulePriceCollection->getSelect();
+
$productIds = $rulePriceCollection->getProductIds();
if (!empty($productIds)) {
$specials->getSelect()->orWhere('e.entity_id in ('.implode(',',$productIds).')');
}
- /*
- *need to put status and visibility after orWhere clause for catalog price rule products
- */
- Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($specials);
- Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($specials);
-
-
-//echo $specials->getSelect();
+ $specials->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$newurl = Mage::getUrl('rss/catalog/new');
$title = Mage::helper('rss')->__('%s - Special Discounts', Mage::app()->getStore()->getName());
@@ -112,33 +104,40 @@ protected function _toHtml()
->walk($specials->getSelect(), array(array($this, 'addSpecialXmlCallback')), array('rssObj'=> $rssObj, 'results'=> &$results));
if(sizeof($results)>0){
- usort($results, array(&$this, 'sortByStartDate'));
- foreach($results as $result){
- $product->setData($result);
- //$product->unsetData()->load($result['entity_id']);
-
- $special_price = ($result['use_special'] ? $result['special_price'] : $result['rule_price']);
- $description = ''.
- ' '.
- ''.$product->getDescription().
- ' Price:'.Mage::helper('core')->currency($product->getPrice()).
- ' Special Price:'. Mage::helper('core')->currency($special_price).
- ($result['use_special'] && $result['special_to_date'] ? ' Special Expires on: '.$this->formatDate($result['special_to_date'], Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM) : '').
- '
'.
- ' '.
- '
';
+ usort($results, array(&$this, 'sortByStartDate'));
+ foreach($results as $result){
+ $product->setData($result);
+
+ $description = ''.
+ ' '.
+ ''.$product->getDescription();
+
+ if ($product->getAllowedPriceInRss()) {
+ $specialPrice = ($result['use_special'] ? $result['special_price'] : $result['rule_price']);
+ $description .= ' Price:'.Mage::helper('core')->currency($product->getPrice()).
+ ' Special Price:'. Mage::helper('core')->currency($specialPrice).
+ ($result['use_special'] && $result['special_to_date'] ? ' Special Expires on: '.$this->formatDate($result['special_to_date'], Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM) : '').
+ '
';
+ }
+
+ $description .= '
';
+
$data = array(
'title' => $product->getName(),
'link' => $product->getProductUrl(),
- 'description' => $description,
-
- );
+ 'description' => $description
+ );
$rssObj->_addEntry($data);
- }
+ }
}
return $rssObj->createRssXml();
}
+ /**
+ * Preparing data and adding to rss object
+ *
+ * @param array $args
+ */
public function addSpecialXmlCallback($args)
{
/*
@@ -156,17 +155,21 @@ public function addSpecialXmlCallback($args)
return;
}
-//echo "";
-//print_r($args['row']);
$row = $args['row'];
- $special_price = $row['special_price'];
- $rule_price = $row['rule_price'];
- if (!$rule_price || ($rule_price && $special_price && $special_price<=$rule_price)) {
- $row['start_date'] = $row['special_from_date'];
- $row['use_special'] = true;
+
+ if ($product->getAllowedPriceInRss()) {
+ $specialPrice = $row['special_price'];
+ $rule_price = $row['rule_price'];
+ if (!$rulePrice || ($rulePrice && $specialPrice && $specialPrice<=$rulePrice)) {
+ $row['start_date'] = $row['special_from_date'];
+ $row['use_special'] = true;
+ } else {
+ $row['start_date'] = $row['rule_start_date'];
+ $row['use_special'] = false;
+ }
+ $row['allowed_price_in_rss'] = true;
} else {
- $row['start_date'] = $row['rule_start_date'];
- $row['use_special'] = false;
+ $row['allowed_price_in_rss'] = false;
}
$args['results'][] = $row;
}
diff --git a/app/code/core/Mage/Rss/Block/Catalog/Tag.php b/app/code/core/Mage/Rss/Block/Catalog/Tag.php
index 1bf0b34726..be79fdcaad 100644
--- a/app/code/core/Mage/Rss/Block/Catalog/Tag.php
+++ b/app/code/core/Mage/Rss/Block/Catalog/Tag.php
@@ -64,6 +64,8 @@ protected function _toHtml()
->addTagFilter($tagModel->getId())
->addStoreFilter($storeId);
+ $_collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
+
$product = Mage::getModel('catalog/product');
Mage::getSingleton('core/resource_iterator')
@@ -72,6 +74,11 @@ protected function _toHtml()
return $rssObj->createRssXml();
}
+ /**
+ * Preparing data and adding to rss object
+ *
+ * @param array $args
+ */
public function addTaggedItemXml($args)
{
$product = $args['product'];
@@ -84,20 +91,25 @@ public function addTaggedItemXml($args)
return;
}
+ $allowedPriceInRss = $product->getAllowedPriceInRss();
+
$product->unsetData()->load($args['row']['entity_id']);
$description = ' '.
' '.
- ''.$product->getDescription().
- ' Price:'.Mage::helper('core')->currency($product->getFinalPrice()).'
'.
- ' '.
- '
';
+ ''.$product->getDescription();
+
+ if ($allowedPriceInRss) {
+ $description .= ' Price:'.Mage::helper('core')->currency($product->getFinalPrice()).'
';
+ }
+
+ $description .=' ';
+
$rssObj = $args['rssObj'];
$data = array(
'title' => $product->getName(),
'link' => $product->getProductUrl(),
'description' => $description,
-
- );
+ );
$rssObj->_addEntry($data);
}
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Rss/Block/Order/New.php b/app/code/core/Mage/Rss/Block/Order/New.php
index 310ed82b71..d2c34fd2ad 100644
--- a/app/code/core/Mage/Rss/Block/Order/New.php
+++ b/app/code/core/Mage/Rss/Block/Order/New.php
@@ -29,12 +29,21 @@
*
* @category Mage
* @package Mage_Rss
- * @author Magento Core Team
+ * @author Magento Core Team
*/
class Mage_Rss_Block_Order_New extends Mage_Core_Block_Template
{
+
+ /**
+ * Cache tag constant for feed new orders
+ *
+ * @var string
+ */
+ const CACHE_TAG = 'block_html_rss_order_new';
+
protected function _construct()
{
+ $this->setCacheTags(array(self::CACHE_TAG));
/*
* setting cache to save the rss for 10 minutes
*/
@@ -64,6 +73,9 @@ protected function _toHtml()
;
$detailBlock = Mage::getBlockSingleton('rss/order_details');
+
+ Mage::dispatchEvent('rss_order_new_collection_select', array('collection' => $collection));
+
Mage::getSingleton('core/resource_iterator')
->walk($collection->getSelect(), array(array($this, 'addNewOrderXmlCallback')), array('rssObj'=> $rssObj, 'order'=>$order , 'detailBlock' => $detailBlock));
@@ -88,4 +100,4 @@ public function addNewOrderXmlCallback($args)
$rssObj->_addEntry($data);
}
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Rss/Helper/Catalog.php b/app/code/core/Mage/Rss/Helper/Catalog.php
index 0cf86e41a3..db227f6c59 100644
--- a/app/code/core/Mage/Rss/Helper/Catalog.php
+++ b/app/code/core/Mage/Rss/Helper/Catalog.php
@@ -38,7 +38,7 @@ public function getTagFeedUrl()
if(Mage::getStoreConfig('rss/catalog/tag') && $this->_getRequest()->getParam('tagId')){
$tagModel = Mage::getModel('tag/tag')->load($this->_getRequest()->getParam('tagId'));
if($tagModel && $tagModel->getId()){
- return Mage::getUrl('rss/catalog/tag', array('tagName' => $tagModel->getName()));
+ return Mage::getUrl('rss/catalog/tag', array('tagName' => urlencode($tagModel->getName())));
}
}
return $url;
diff --git a/app/code/core/Mage/Rss/Helper/Data.php b/app/code/core/Mage/Rss/Helper/Data.php
index 8e21ff758a..077c877328 100644
--- a/app/code/core/Mage/Rss/Helper/Data.php
+++ b/app/code/core/Mage/Rss/Helper/Data.php
@@ -66,7 +66,7 @@ public function authAdmin($path)
}
list($username, $password) = $this->authValidate();
Mage::getSingleton('adminhtml/url')->setNoSecret(true);
- $adminSession = Mage::getModel('admin/session');
+ $adminSession = Mage::getSingleton('admin/session');
$user = $adminSession->login($username, $password);
//$user = Mage::getModel('admin/user')->login($username, $password);
if($user && $user->getId() && $user->getIsActive() == '1' && $adminSession->isAllowed($path)){
@@ -96,4 +96,4 @@ public function authFailed()
{
Mage::helper('core/http')->authFailed();
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Rss/controllers/CatalogController.php b/app/code/core/Mage/Rss/controllers/CatalogController.php
index aaaef06157..f062a6cd9d 100644
--- a/app/code/core/Mage/Rss/controllers/CatalogController.php
+++ b/app/code/core/Mage/Rss/controllers/CatalogController.php
@@ -76,7 +76,7 @@ public function salesruleAction()
public function tagAction()
{
if ($this->checkFeedEnable('tag')) {
- $tagName = $this->getRequest()->getParam('tagName');
+ $tagName = urldecode($this->getRequest()->getParam('tagName'));
$tagModel = Mage::getModel('tag/tag');
$tagModel->loadByName($tagName);
if ($tagModel->getId() && $tagModel->getStatus()==$tagModel->getApprovedStatus()) {
diff --git a/app/code/core/Mage/Rss/controllers/OrderController.php b/app/code/core/Mage/Rss/controllers/OrderController.php
index c2bf035c85..3ba14169c1 100644
--- a/app/code/core/Mage/Rss/controllers/OrderController.php
+++ b/app/code/core/Mage/Rss/controllers/OrderController.php
@@ -36,7 +36,6 @@ class Mage_Rss_OrderController extends Mage_Core_Controller_Front_Action
{
public function newAction()
{
- Mage::helper('rss')->authAdmin('sales/order');
$this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
$this->loadLayout(false);
$this->renderLayout();
@@ -70,4 +69,18 @@ public function statusAction()
}
$this->_forward('nofeed', 'index', 'rss');
}
-}
\ No newline at end of file
+
+ /**
+ * Controller predispatch method to change area for some specific action.
+ *
+ * @return Mage_Rss_OrderController
+ */
+ public function preDispatch()
+ {
+ if ($this->getRequest()->getActionName() == 'new') {
+ $this->_currentArea = 'adminhtml';
+ Mage::helper('rss')->authAdmin('sales/order');
+ }
+ parent::preDispatch();
+ }
+}
diff --git a/app/code/core/Mage/Rss/etc/config.xml b/app/code/core/Mage/Rss/etc/config.xml
index f03007300c..d475a5db8b 100644
--- a/app/code/core/Mage/Rss/etc/config.xml
+++ b/app/code/core/Mage/Rss/etc/config.xml
@@ -75,28 +75,26 @@
-
-
-
-
-
-
-
-
-
- Rss Feeds Section
- 135
-
-
-
-
-
-
-
-
-
+
+
+
+
+ rss/observer
+ salesOrderItemSaveAfterNotifyStock
+
+
+
+
+
+
+ rss/observer
+ salesOrderItemSaveAfterOrderNew
+
+
+
+
diff --git a/app/code/core/Mage/Rule/Block/Editable.php b/app/code/core/Mage/Rule/Block/Editable.php
index 31171c7830..b3be739ba0 100644
--- a/app/code/core/Mage/Rule/Block/Editable.php
+++ b/app/code/core/Mage/Rule/Block/Editable.php
@@ -28,36 +28,37 @@
class Mage_Rule_Block_Editable extends Mage_Core_Block_Abstract
implements Varien_Data_Form_Element_Renderer_Interface
{
- public function render(Varien_Data_Form_Element_Abstract $element)
- {
- $valueName = $element->getValueName();
+ public function render(Varien_Data_Form_Element_Abstract $element)
+ {
+ $element->addClass('element-value-changer');
+ $valueName = $element->getValueName();
- if ($valueName==='') {
- $valueName = '...';
- } else {
- $valueName = Mage::helper('core/string')->truncate($valueName, 30);
- }
- if ($element->getShowAsText()) {
- $html = ' ';
+ if ($valueName==='') {
+ $valueName = '...';
+ } else {
+ $valueName = Mage::helper('core/string')->truncate($valueName, 30);
+ }
+ if ($element->getShowAsText()) {
+ $html = ' ';
- $html.= htmlspecialchars($valueName).' ';
- } else {
- $html = ' getParamId() ? ' id="' . $element->getParamId() . '"' : '') . '>';
+ $html.= htmlspecialchars($valueName).' ';
+ } else {
+ $html = ' getParamId() ? ' id="' . $element->getParamId() . '"' : '') . '>';
- $html.= '';
+ $html.= ' ';
- $html.= htmlspecialchars($valueName);
+ $html.= htmlspecialchars($valueName);
- $html.= ' ';
+ $html.= ' ';
- $html.= $element->getElementHtml();
+ $html.= $element->getElementHtml();
- if ($element->getExplicitApply()) {
- $html.= ' ';
- }
+ if ($element->getExplicitApply()) {
+ $html.= ' ';
+ }
- $html.= ' ';
- }
- return $html;
- }
+ $html.= ' ';
+ }
+ return $html;
+ }
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Rule/Block/Newchild.php b/app/code/core/Mage/Rule/Block/Newchild.php
index fbcbd8d3b7..180054a21d 100644
--- a/app/code/core/Mage/Rule/Block/Newchild.php
+++ b/app/code/core/Mage/Rule/Block/Newchild.php
@@ -28,14 +28,15 @@
class Mage_Rule_Block_Newchild extends Mage_Core_Block_Abstract
implements Varien_Data_Form_Element_Renderer_Interface
{
- public function render(Varien_Data_Form_Element_Abstract $element)
- {
- $html = ' getParamId() ? ' id="' . $element->getParamId() . '"' : '') . '>';
- $html.= '';
- $html.= $element->getValueName();
- $html.= ' ';
- $html.= $element->getElementHtml();
- $html.= ' ';
- return $html;
- }
+ public function render(Varien_Data_Form_Element_Abstract $element)
+ {
+ $element->addClass('element-value-changer');
+ $html = ' getParamId() ? ' id="' . $element->getParamId() . '"' : '') . '>';
+ $html.= '';
+ $html.= $element->getValueName();
+ $html.= ' ';
+ $html.= $element->getElementHtml();
+ $html.= ' ';
+ return $html;
+ }
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Rule/Model/Condition/Abstract.php b/app/code/core/Mage/Rule/Model/Condition/Abstract.php
index 915d0bfbba..065f3133ad 100644
--- a/app/code/core/Mage/Rule/Model/Condition/Abstract.php
+++ b/app/code/core/Mage/Rule/Model/Condition/Abstract.php
@@ -33,10 +33,50 @@ abstract class Mage_Rule_Model_Condition_Abstract
extends Varien_Object
implements Mage_Rule_Model_Condition_Interface
{
+ /**
+ * Defines which operators will be available for this condition
+ *
+ * @var string
+ */
+ protected $_inputType = null;
+
+ /**
+ * Default values for possible operator options
+ * @var array
+ */
+ protected $_defaultOperatorOptions;
+
+ /**
+ * Default combinations of operator options, depending on input type
+ * @var array
+ */
+ protected $_defaultOperatorInputByType = array(
+ 'string' => array('==', '!=', '>=', '>', '<=', '<', '{}', '!{}', '()', '!()'),
+ 'numeric' => array('==', '!=', '>=', '>', '<=', '<', '()', '!()'),
+ 'date' => array('==', '>=', '<='),
+ 'select' => array('==', '!='),
+ 'multiselect' => array('==', '!=', '{}', '!{}'),
+ 'grid' => array('()', '!()'),
+ );
+
public function __construct()
{
parent::__construct();
+ $this->_defaultOperatorOptions = array(
+ '==' => Mage::helper('rule')->__('is'),
+ '!=' => Mage::helper('rule')->__('is not'),
+ '>=' => Mage::helper('rule')->__('equals or greater than'),
+ '<=' => Mage::helper('rule')->__('equals or less than'),
+ '>' => Mage::helper('rule')->__('greater than'),
+ '<' => Mage::helper('rule')->__('less than'),
+ '{}' => Mage::helper('rule')->__('contains'),
+ '!{}' => Mage::helper('rule')->__('does not contain'),
+ '!{}' => Mage::helper('rule')->__('does not contain'),
+ '()' => Mage::helper('rule')->__('is one of'),
+ '!()' => Mage::helper('rule')->__('is not one of'),
+ );
+
$this->loadAttributeOptions()->loadOperatorOptions()->loadValueOptions();
if ($options = $this->getAttributeOptions()) {
@@ -123,39 +163,24 @@ public function getAttributeName()
public function loadOperatorOptions()
{
- $this->setOperatorOption(array(
- '==' => Mage::helper('rule')->__('is'),
- '!=' => Mage::helper('rule')->__('is not'),
- '>=' => Mage::helper('rule')->__('equals or greater than'),
- '<=' => Mage::helper('rule')->__('equals or less than'),
- '>' => Mage::helper('rule')->__('greater than'),
- '<' => Mage::helper('rule')->__('less than'),
- '{}' => Mage::helper('rule')->__('contains'),
- '!{}' => Mage::helper('rule')->__('does not contain'),
- '()' => Mage::helper('rule')->__('is one of'),
- '!()' => Mage::helper('rule')->__('is not one of'),
- ));
- $this->setOperatorByInputType(array(
- 'string' => array('==', '!=', '>=', '>', '<=', '<', '{}', '!{}', '()', '!()'),
- 'numeric' => array('==', '!=', '>=', '>', '<=', '<', '()', '!()'),
- 'date' => array('==', '>=', '<='),
- 'select' => array('==', '!='),
- 'multiselect' => array('==', '!=', '{}', '!{}'),
- 'grid' => array('()', '!()'),
- ));
+ $this->setOperatorOption($this->_defaultOperatorOptions);
+ $this->setOperatorByInputType($this->_defaultOperatorInputByType);
return $this;
}
/**
* This value will define which operators will be available for this condition.
*
- * Possible values are: string, numeric, date, select, multiselect, grid
+ * Possible values are: string, numeric, date, select, multiselect, grid, boolean
*
* @return string
*/
public function getInputType()
{
- return 'string';
+ if (null === $this->_inputType) {
+ return 'string';
+ }
+ return $this->_inputType;
}
public function getOperatorSelectOptions()
diff --git a/app/code/core/Mage/Rule/Model/Condition/Combine.php b/app/code/core/Mage/Rule/Model/Condition/Combine.php
index ead83c1721..4e1f7845c8 100644
--- a/app/code/core/Mage/Rule/Model/Condition/Combine.php
+++ b/app/code/core/Mage/Rule/Model/Condition/Combine.php
@@ -157,8 +157,10 @@ public function asXml($containerKey='conditions', $itemKey='condition')
public function loadArray($arr, $key='conditions')
{
- $this->setAggregator(isset($arr['aggregator']) ? $arr['aggregator'] : $arr['attribute'])
- ->setValue(isset($arr['value']) ? $arr['value'] : $arr['operator']);
+ $this->setAggregator(isset($arr['aggregator']) ? $arr['aggregator']
+ : (isset($arr['attribute']) ? $arr['attribute'] : null))
+ ->setValue(isset($arr['value']) ? $arr['value']
+ : (isset($arr['operator']) ? $arr['operator'] : null));
if (!empty($arr[$key]) && is_array($arr[$key])) {
foreach ($arr[$key] as $condArr) {
@@ -169,7 +171,7 @@ public function loadArray($arr, $key='conditions')
$cond->loadArray($condArr, $key);
}
} catch (Exception $e) {
-
+ Mage::logException($e);
}
}
}
diff --git a/app/code/core/Mage/Rule/Model/Rule.php b/app/code/core/Mage/Rule/Model/Rule.php
index 4ddb5a6014..0eda1c8516 100644
--- a/app/code/core/Mage/Rule/Model/Rule.php
+++ b/app/code/core/Mage/Rule/Model/Rule.php
@@ -44,7 +44,11 @@ class Mage_Rule_Model_Rule extends Mage_Core_Model_Abstract
*/
protected $_isReadonly = false;
-
+ /**
+ * Init resoirce
+ *
+ * @return unknown_type
+ */
protected function _construct()
{
$this->_init('rule/rule');
diff --git a/app/code/core/Mage/Sales/Block/Reorder/Sidebar.php b/app/code/core/Mage/Sales/Block/Reorder/Sidebar.php
index 6d658debb7..89ef543317 100644
--- a/app/code/core/Mage/Sales/Block/Reorder/Sidebar.php
+++ b/app/code/core/Mage/Sales/Block/Reorder/Sidebar.php
@@ -53,6 +53,17 @@ public function __construct()
}
}
+ /**
+ * Retrieve form action url and set "secure" param to avoid confirm
+ * message when we submit form from secure page to unsecure
+ *
+ * @return string
+ */
+ public function getFormActionUrl()
+ {
+ return $this->getUrl('checkout/cart/addgroup', array('_secure' => true));
+ }
+
public function getLastOrder()
{
foreach ($this->getOrders() as $order) {
diff --git a/app/code/core/Mage/Sales/Model/Mysql4/Order/Collection.php b/app/code/core/Mage/Sales/Model/Mysql4/Order/Collection.php
index 8165cb11b4..72753173a5 100644
--- a/app/code/core/Mage/Sales/Model/Mysql4/Order/Collection.php
+++ b/app/code/core/Mage/Sales/Model/Mysql4/Order/Collection.php
@@ -73,20 +73,15 @@ public function getSelectCountSql()
}
/**
- * Retrive all ids for collection
+ * Reset left join
*
- * @return array
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
*/
- public function getAllIds($limit=null, $offset=null)
+ protected function _getAllIdsSelect($limit=null, $offset=null)
{
- $idsSelect = clone $this->getSelect();
- $idsSelect->reset(Zend_Db_Select::ORDER);
- $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
- $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
- $idsSelect->reset(Zend_Db_Select::COLUMNS);
- $idsSelect->from(null, 'e.'.$this->getEntity()->getIdFieldName());
- $idsSelect->limit($limit, $offset);
+ $idsSelect = parent::_getAllIdsSelect($limit, $offset);
$idsSelect->resetJoinLeft();
- return $this->getConnection()->fetchCol($idsSelect, $this->_bindParams);
+ return $idsSelect;
}
+
}
diff --git a/app/code/core/Mage/Sales/Model/Mysql4/Order/Invoice/Collection.php b/app/code/core/Mage/Sales/Model/Mysql4/Order/Invoice/Collection.php
index 0bb13eae8c..325c3d5eec 100644
--- a/app/code/core/Mage/Sales/Model/Mysql4/Order/Invoice/Collection.php
+++ b/app/code/core/Mage/Sales/Model/Mysql4/Order/Invoice/Collection.php
@@ -34,21 +34,40 @@
class Mage_Sales_Model_Mysql4_Order_Invoice_Collection extends Mage_Eav_Model_Entity_Collection_Abstract
{
+ /**
+ * Initialize orders collection
+ *
+ */
protected function _construct()
{
$this->_init('sales/order_invoice');
}
+ /**
+ * Add order filter
+ *
+ * @return Mage_Sales_Model_Mysql4_Order_Invoice_Collection
+ */
public function setOrderFilter($order)
{
if ($order instanceof Mage_Sales_Model_Order) {
$this->addAttributeToFilter('order_id', $order->getId());
- }
- else {
+ } else {
$this->addAttributeToFilter('order_id', $order);
}
-
return $this;
}
+ /**
+ * Reset left join
+ *
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
+ */
+ protected function _getAllIdsSelect($limit = null, $offset = null)
+ {
+ $idsSelect = parent::_getAllIdsSelect($limit, $offset);
+ $idsSelect->resetJoinLeft();
+ return $idsSelect;
+ }
+
}
diff --git a/app/code/core/Mage/Sales/Model/Mysql4/Setup.php b/app/code/core/Mage/Sales/Model/Mysql4/Setup.php
index 25fa721aac..fd92965ae4 100644
--- a/app/code/core/Mage/Sales/Model/Mysql4/Setup.php
+++ b/app/code/core/Mage/Sales/Model/Mysql4/Setup.php
@@ -420,6 +420,8 @@ public function getDefaultEntities()
'base_shipping_canceled' => array('type'=>'static'),
'base_shipping_invoiced' => array('type'=>'static'),
+ 'protect_code' => array('type' => 'static'),
+
'customer_id' => array('type'=>'static', 'visible'=>false),
'customer_group_id' => array('type'=>'int', 'visible'=>false),
'customer_email' => array('type'=>'varchar', 'visible'=>false),
diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php
index 0b17f7a7a0..b61400258d 100644
--- a/app/code/core/Mage/Sales/Model/Order.php
+++ b/app/code/core/Mage/Sales/Model/Order.php
@@ -434,7 +434,6 @@ protected function _placePayment()
$this->getPayment()->place();
return $this;
}
-
/**
* Retrieve order payment model object
*
@@ -570,7 +569,23 @@ public function addStatusToHistory($status, $comment='', $isCustomerNotified = f
public function place()
{
Mage::dispatchEvent('sales_order_place_before', array('order'=>$this));
- $this->_placePayment();
+ $this->setState(self::STATE_NEW, true)->save();
+ try {
+ $this->_placePayment();
+ } catch (Mage_Core_Exception $e){
+ $message = $e->getMessage();
+ Mage::logException($e);
+ $this->addStatusToHistory(
+ $this->getStatus(),
+ Mage::helper('sales')->__('Payment failed: %s', $message)
+ )->save();
+ } catch (Exception $e){
+ Mage::logException($e);
+ $this->addStatusToHistory(
+ $this->getStatus(),
+ Mage::helper('sales')->__('Payment failed')
+ )->save();
+ }
Mage::dispatchEvent('sales_order_place_after', array('order'=>$this));
return $this;
}
@@ -1428,6 +1443,8 @@ protected function _beforeSave()
}
}
+ $this->setData('protect_code', substr(md5(uniqid(mt_rand(), true) . ':' . microtime(true)), 5, 6));
+
return $this;
}
diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php
index 53214bd9b6..4b3a2b2137 100644
--- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php
+++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php
@@ -412,6 +412,10 @@ public function register()
);
}
+ $this->getOrder()->setBaseTotalInvoicedCost(
+ $this->getOrder()->getBaseTotalInvoicedCost()-$this->getBaseCost()
+ );
+
$state = $this->getState();
if (is_null($state)) {
$this->setState(self::STATE_OPEN);
diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php
index c307ce1579..8c9acdda33 100644
--- a/app/code/core/Mage/Sales/Model/Order/Invoice.php
+++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php
@@ -484,6 +484,9 @@ public function register()
$this->getOrder()->setBaseDiscountInvoiced(
$this->getOrder()->getBaseDiscountInvoiced()+$this->getBaseDiscountAmount()
);
+ $this->getOrder()->setBaseTotalInvoicedCost(
+ $this->getOrder()->getBaseTotalInvoicedCost()+$this->getBaseCost()
+ );
$state = $this->getState();
if (is_null($state)) {
diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php
index 30efefb937..4cf2ac59dc 100644
--- a/app/code/core/Mage/Sales/Model/Order/Shipment.php
+++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php
@@ -92,6 +92,17 @@ public function setOrder(Mage_Sales_Model_Order $order)
return $this;
}
+
+ /**
+ * Retrieve hash code of current order
+ *
+ * @return string
+ */
+ public function getProtectCode()
+ {
+ return (string)$this->getOrder()->getProtectCode();
+ }
+
/**
* Retrieve the order the shipment for created for
*
diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment/Track.php b/app/code/core/Mage/Sales/Model/Order/Shipment/Track.php
index a040f8eb08..f00507e7cf 100644
--- a/app/code/core/Mage/Sales/Model/Order/Shipment/Track.php
+++ b/app/code/core/Mage/Sales/Model/Order/Shipment/Track.php
@@ -71,6 +71,16 @@ public function isCustom()
return $this->getCarrierCode() == self::CUSTOM_CARRIER_CODE;
}
+ /**
+ * Retrieve hash code of current order
+ *
+ * @return string
+ */
+ public function getProtectCode()
+ {
+ return (string)$this->getShipment()->getProtectCode();
+ }
+
/**
* Retrieve detail for shipment track
*
diff --git a/app/code/core/Mage/Sales/Model/Quote.php b/app/code/core/Mage/Sales/Model/Quote.php
index fd717ffee5..c1d28afc05 100644
--- a/app/code/core/Mage/Sales/Model/Quote.php
+++ b/app/code/core/Mage/Sales/Model/Quote.php
@@ -894,6 +894,12 @@ public function removePayment()
*/
public function collectTotals()
{
+ /**
+ * Protect double totals collection
+ */
+ if ($this->getTotalsCollectedFlag()) {
+ return $this;
+ }
Mage::dispatchEvent(
$this->_eventPrefix . '_collect_totals_before',
array(
@@ -966,6 +972,7 @@ public function collectTotals()
)
);
+ $this->setTotalsCollectedFlag(true);
return $this;
}
@@ -984,14 +991,25 @@ public function getTotals()
if ($this->isVirtual()) {
return $this->getBillingAddress()->getTotals();
}
-
- $totals = $this->getShippingAddress()->getTotals();
- foreach ($this->getBillingAddress()->getTotals() as $code => $total) {
- if (isset($totals[$code])) {
- $totals[$code]->setValue($totals[$code]->getValue()+$total->getValue());
+
+ $totals = null;
+ // Going through all quote addresses and sum their totals
+ foreach ($this->getAddressesCollection() as $address) {
+ if ($address->isDeleted()) {
+ continue;
}
- else {
- $totals[$code] = $total;
+ if (!$totals) {
+ $totals = $address->getTotals();
+ } else {
+ foreach ($address->getTotals() as $code => $total) {
+ if (isset($totals[$code])) {
+ $totals[$code]->setValue($totals[$code]->getValue()+$total->getValue());
+ $totals[$code]->setValueExclTax($totals[$code]->getValueExclTax()+$total->getValueExclTax());
+ $totals[$code]->setValueInclTax($totals[$code]->getValueInclTax()+$total->getValueInclTax());
+ } else {
+ $totals[$code] = $total;
+ }
+ }
}
}
diff --git a/app/code/core/Mage/Sales/Model/Quote/Address.php b/app/code/core/Mage/Sales/Model/Quote/Address.php
index fc53b6d161..8bb04bbd9d 100644
--- a/app/code/core/Mage/Sales/Model/Quote/Address.php
+++ b/app/code/core/Mage/Sales/Model/Quote/Address.php
@@ -265,8 +265,7 @@ public function getAllItems()
if ($this->getAddressType() == self::TYPE_BILLING) {
$items[] = $qItem;
}
- }
- else {
+ } else {
if ($this->getAddressType() == self::TYPE_SHIPPING) {
$items[] = $qItem;
}
@@ -568,9 +567,10 @@ public function collectShippingRates()
$this->removeAllShippingRates();
- $havingOptionalZip = Mage::helper('directory')->getCountriesWithOptionalZip();
- $postcodeValid = $this->getPostcode() || in_array($this->getCountryId(), $havingOptionalZip);
- if (!$this->getCountryId() && !$postcodeValid) {
+ $countryId = $this->getCountryId();
+ $postCode = $this->getPostcode();
+ if ((!$countryId && !$postCode)
+ || ($countryId && !$postCode && !Mage::helper('directory')->isZipCodeOptional($countryId))) {
return $this;
}
@@ -844,6 +844,34 @@ public function setBaseTotalAmount($code, $amount)
return $this;
}
+ /**
+ * Add amount total amount value
+ *
+ * @param string $code
+ * @param float $amount
+ * @return Mage_Sales_Model_Quote_Address
+ */
+ public function addTotalAmount($code, $amount)
+ {
+ $amount = $this->getTotalAmount($code)+$amount;
+ $this->setTotalAmount($code, $amount);
+ return $this;
+ }
+
+ /**
+ * Add amount total amount value in base store currency
+ *
+ * @param string $code
+ * @param float $amount
+ * @return Mage_Sales_Model_Quote_Address
+ */
+ public function addBaseTotalAmount($code, $amount)
+ {
+ $amount = $this->getBaseTotalAmount($code)+$amount;
+ $this->setBaseTotalAmount($code, $amount);
+ return $this;
+ }
+
/**
* Get total amount value by code
*
diff --git a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php
index 7336a398a2..95fd306e06 100644
--- a/app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php
+++ b/app/code/core/Mage/Sales/Model/Quote/Address/Total/Abstract.php
@@ -153,10 +153,7 @@ protected function _setBaseAmount($baseAmount)
*/
protected function _addAmount($amount)
{
- $this->_getAddress()->setTotalAmount(
- $this->getCode(),
- $this->_getAddress()->getTotalAmount($this->getCode())+$amount
- );
+ $this->_getAddress()->addTotalAmount($this->getCode(),$amount);
return $this;
}
@@ -168,10 +165,7 @@ protected function _addAmount($amount)
*/
protected function _addBaseAmount($baseAmount)
{
- $this->_getAddress()->setBaseTotalAmount(
- $this->getCode(),
- $this->_getAddress()->getBaseTotalAmount($this->getCode())+$baseAmount
- );
+ $this->_getAddress()->addBaseTotalAmount($this->getCode(), $baseAmount);
return $this;
}
diff --git a/app/code/core/Mage/Sales/Model/Quote/Item.php b/app/code/core/Mage/Sales/Model/Quote/Item.php
index 9f9f227496..6091f7c26b 100644
--- a/app/code/core/Mage/Sales/Model/Quote/Item.php
+++ b/app/code/core/Mage/Sales/Model/Quote/Item.php
@@ -215,6 +215,23 @@ public function getQtyOptions()
return $return;
}
+ /**
+ * Checking item data
+ *
+ * @return Mage_Sales_Model_Quote_Item_Abstract
+ */
+ public function checkData()
+ {
+ $parent = parent::checkData();
+ if ($this->getProduct()->getHasError()) {
+ $this->setHasError(true);
+ $this->setMessage(Mage::helper('sales')->__('Item options declare error'));
+ $this->getQuote()->setHasError(true);
+ $this->getQuote()->addMessage($this->getProduct()->getMessage(), 'options');
+ }
+ return $parent;
+ }
+
/**
* Setup product for quote item
*
@@ -233,8 +250,10 @@ public function setProduct($product)
->setName($product->getName())
->setWeight($this->getProduct()->getWeight())
->setTaxClassId($product->getTaxClassId())
- ->setCost($product->getCost())
- ->setIsQtyDecimal($product->getIsQtyDecimal());
+ ->setBaseCost($product->getCost());
+ if ($product->getStockItem()) {
+ $this->setIsQtyDecimal($product->getStockItem()->getIsQtyDecimal());
+ }
Mage::dispatchEvent('sales_quote_item_set_product', array(
'product' => $product,
@@ -261,6 +280,7 @@ public function getProduct()
$product = Mage::getModel('catalog/product')
->setStoreId($this->getQuote()->getStoreId())
->load($this->getProductId());
+
$this->setProduct($product);
}
diff --git a/app/code/core/Mage/Sales/etc/config.xml b/app/code/core/Mage/Sales/etc/config.xml
index d68e0d08b2..96f885efb2 100644
--- a/app/code/core/Mage/Sales/etc/config.xml
+++ b/app/code/core/Mage/Sales/etc/config.xml
@@ -28,7 +28,7 @@
- 0.9.40
+ 0.9.44
@@ -73,6 +73,7 @@
*
+ *
*
*
@@ -190,6 +191,7 @@
*
*
*
+ *
@@ -294,7 +296,7 @@
*
base_price * *
- cost *
+ * * *
@@ -465,14 +467,7 @@
Mage_Sales
Mage_Sales_Model_Mysql4_Setup
- core_setup
-
- core_write
-
-
- core_read
-
Mage_Sales_Block
@@ -520,13 +515,13 @@
+
Pending
- Pending PayPal
Processing
On Hold
Complete
@@ -537,48 +532,46 @@
New
-
+
Pending Payment
-
-
-
+
Processing
-
+
Complete
-
+
Closed
-
+
Canceled
-
+
On Hold
-
+
@@ -601,6 +594,9 @@
sales/order_invoice_total_grand
+
+ sales/order_invoice_total_cost
+
@@ -620,6 +616,9 @@
sales/order_creditmemo_total_grand
+
+ sales/order_creditmemo_total_cost
+
@@ -714,104 +713,6 @@
-
-
- Sales
- 20
- Mage_Sales
-
-
- Orders
- adminhtml/sales_order
- 10
-
-
- Invoices
- adminhtml/sales_invoice
- 20
-
-
- Shipments
- adminhtml/sales_shipment
- 30
-
-
- Credit Memos
- adminhtml/sales_creditmemo
- 40
-
-
-
-
-
-
-
-
-
- Sales
-
-
- Orders
-
-
- Actions
-
- Create
- View
- Reorder
- Edit
- Cancel
- Capture
- Invoice
- Creditmemo
- Hold
- Unhold
- Ship
- Comment
- Reorder
-
-
-
- 10
-
-
- Invoices
- 20
-
-
- Shipments
- 30
-
-
- Credit Memos
- 40
-
-
-
-
-
-
-
-
- Sales Section
- 60
-
-
- Sales Emails Section
- 65
-
-
- PDF Print-outs
- 66
-
-
-
-
-
-
-
-
-
@@ -832,7 +733,6 @@
- singleton
sales/observer
substractQtyFromQuotes
@@ -841,7 +741,6 @@
- singleton
sales/observer
markQuotesRecollectOnCatalogRules
@@ -850,7 +749,6 @@
- singleton
sales/observer
markQuotesRecollectOnCatalogRules
@@ -859,7 +757,6 @@
- singleton
sales/observer
catalogProductSaveAfter
@@ -868,7 +765,6 @@
- singleton
sales/observer
catalogProductStatusUpdate
diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-install-0.9.0.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-install-0.9.0.php
index 23d5e96c85..7778662198 100644
--- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-install-0.9.0.php
+++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-install-0.9.0.php
@@ -28,6 +28,7 @@
/* @var $installer Mage_Sales_Model_Entity_Setup */
$installer->startSetup();
$installer->run("
+DROP TABLE IF EXISTS `{$installer->getTable('sales_flat_quote')}`;
CREATE TABLE `{$installer->getTable('sales_flat_quote')}` (
`entity_id` int(10) unsigned NOT NULL auto_increment,
`store_id` smallint(5) unsigned NOT NULL default '0',
@@ -79,7 +80,7 @@
KEY `IDX_CUSTOMER` (`customer_id`,`store_id`,`is_active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
+DROP TABLE IF EXISTS `{$installer->getTable('sales_flat_quote_address')}`;
CREATE TABLE `{$installer->getTable('sales_flat_quote_address')}` (
`address_id` int(10) unsigned NOT NULL auto_increment,
`quote_id` int(10) unsigned NOT NULL default '0',
@@ -134,6 +135,7 @@
CONSTRAINT `FK_SALES_QUOTE_ADDRESS_SALES_QUOTE` FOREIGN KEY (`quote_id`) REFERENCES `{$installer->getTable('sales_flat_quote')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_flat_quote_address_item')}`;
CREATE TABLE `{$installer->getTable('sales_flat_quote_address_item')}` (
`address_item_id` int(10) unsigned NOT NULL auto_increment,
`quote_address_id` int(10) unsigned NOT NULL default '0',
@@ -161,6 +163,7 @@
CONSTRAINT `FK_SALES_QUOTE_ADDRESS_ITEM_QUOTE_ITEM` FOREIGN KEY (`quote_item_id`) REFERENCES `{$installer->getTable('sales_flat_quote_item')}` (`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_flat_quote_item')}`;
CREATE TABLE `{$installer->getTable('sales_flat_quote_item')}` (
`item_id` int(10) unsigned NOT NULL auto_increment,
`quote_id` int(10) unsigned NOT NULL default '0',
@@ -201,6 +204,7 @@
CONSTRAINT `FK_SALES_QUOTE_ITEM_SALES_QUOTE` FOREIGN KEY (`quote_id`) REFERENCES `{$installer->getTable('sales_flat_quote')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_flat_quote_item_option')}`;
CREATE TABLE `{$installer->getTable('sales_flat_quote_item_option')}` (
`option_id` int(10) unsigned NOT NULL auto_increment,
`item_id` int(10) unsigned NOT NULL,
@@ -212,6 +216,7 @@
CONSTRAINT `FK_SALES_QUOTE_ITEM_OPTION_ITEM_ID` FOREIGN KEY (`item_id`) REFERENCES `{$installer->getTable('sales_flat_quote_item')}` (`item_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Additional options for quote item';
+DROP TABLE IF EXISTS `{$installer->getTable('sales_flat_quote_payment')}`;
CREATE TABLE `{$installer->getTable('sales_flat_quote_payment')}` (
`payment_id` int(10) unsigned NOT NULL auto_increment,
`quote_id` int(10) unsigned NOT NULL default '0',
@@ -240,6 +245,7 @@
CONSTRAINT `FK_SALES_QUOTE_PAYMENT_SALES_QUOTE` FOREIGN KEY (`quote_id`) REFERENCES `{$installer->getTable('sales_flat_quote')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_flat_quote_shipping_rate')}`;
CREATE TABLE `{$installer->getTable('sales_flat_quote_shipping_rate')}` (
`rate_id` int(10) unsigned NOT NULL auto_increment,
`address_id` int(10) unsigned NOT NULL default '0',
@@ -257,6 +263,7 @@
CONSTRAINT `FK_SALES_QUOTE_SHIPPING_RATE_ADDRESS` FOREIGN KEY (`address_id`) REFERENCES `{$installer->getTable('sales_flat_quote_address')}` (`address_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_order')}`;
CREATE TABLE `{$installer->getTable('sales_order')}` (
`entity_id` int(10) unsigned NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -320,6 +327,7 @@
CONSTRAINT `FK_SALE_ORDER_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_order')}_datetime`;
CREATE TABLE `{$this->getTable('sales_order')}_datetime` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -335,6 +343,7 @@
CONSTRAINT `FK_SALES_ORDER_DATETIME_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_order')}_decimal`;
CREATE TABLE `{$this->getTable('sales_order')}_decimal` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -350,6 +359,7 @@
CONSTRAINT `FK_SALES_ORDER_DECIMAL_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_order')}_int`;
CREATE TABLE `{$this->getTable('sales_order')}_int` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -365,6 +375,7 @@
CONSTRAINT `FK_SALES_ORDER_INT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_order')}_text`;
CREATE TABLE `{$this->getTable('sales_order')}_text` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -380,6 +391,7 @@
CONSTRAINT `FK_SALES_ORDER_TEXT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_order')}_varchar`;
CREATE TABLE `{$this->getTable('sales_order')}_varchar` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -395,6 +407,7 @@
CONSTRAINT `FK_SALES_ORDER_VARCHAR_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$installer->getTable('sales_order_entity')}`;
CREATE TABLE `{$installer->getTable('sales_order_entity')}` (
`entity_id` int(10) unsigned NOT NULL auto_increment,
`entity_type_id` smallint(8) unsigned NOT NULL default '0',
@@ -412,6 +425,7 @@
CONSTRAINT `FK_SALE_ORDER_ENTITY_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
+DROP TABLE IF EXISTS `{$this->getTable('sales_order_entity')}_datetime`;
CREATE TABLE `{$this->getTable('sales_order_entity')}_datetime` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -427,6 +441,7 @@
CONSTRAINT `FK_SALES_ORDER_ENTITY_DATETIME_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$this->getTable('sales_order_entity')}_decimal`;
CREATE TABLE `{$installer->getTable('sales_order_entity')}_decimal` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -442,6 +457,7 @@
CONSTRAINT `FK_SALES_ORDER_ENTITY_DECIMAL_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$this->getTable('sales_order_entity')}_int`;
CREATE TABLE `{$installer->getTable('sales_order_entity')}_int` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -457,6 +473,7 @@
CONSTRAINT `FK_SALES_ORDER_ENTITY_INT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$this->getTable('sales_order_entity')}_text`;
CREATE TABLE `{$installer->getTable('sales_order_entity')}_text` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
@@ -472,6 +489,7 @@
CONSTRAINT `FK_SALES_ORDER_ENTITY_TEXT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `{$this->getTable('sales_order_entity')}_varchar`;
CREATE TABLE `{$installer->getTable('sales_order_entity')}_varchar` (
`value_id` int(11) NOT NULL auto_increment,
`entity_type_id` smallint(5) unsigned NOT NULL default '0',
diff --git a/app/code/core/Mage/SalesRule/Helper/Data.php b/app/code/core/Mage/SalesRule/Helper/Data.php
index 73d4d25248..bffe4f4cb3 100644
--- a/app/code/core/Mage/SalesRule/Helper/Data.php
+++ b/app/code/core/Mage/SalesRule/Helper/Data.php
@@ -29,5 +29,39 @@
*/
class Mage_SalesRule_Helper_Data extends Mage_Core_Helper_Abstract
{
+ /**
+ * Set store and base price which will be used duering discount calculation to item object
+ *
+ * @param Mage_Sales_Model_Quote_Item_Abstract $item
+ * @param float $basePrice
+ * @param float $price
+ * @return Mage_SalesRule_Helper_Data
+ */
+ public function setItemDiscountPrices(Mage_Sales_Model_Quote_Item_Abstract $item, $basePrice, $price)
+ {
+ $item->setDiscountCalculationPrice($price);
+ $item->setBaseDiscountCalculationPrice($basePrice);
+ return $this;
+ }
+ /**
+ * Add additional amounts to discount calculation prices
+ *
+ * @param Mage_Sales_Model_Quote_Item_Abstract $item
+ * @param float $basePrice
+ * @param float $price
+ * @return Mage_SalesRule_Helper_Data
+ */
+ public function addItemDiscountPrices(Mage_Sales_Model_Quote_Item_Abstract $item, $basePrice, $price)
+ {
+ $discountPrice = $item->getDiscountCalculationPrice();
+ $baseDiscountPrice = $item->getBaseDiscountCalculationPrice();
+
+ if ($discountPrice || $baseDiscountPrice || $basePrice || $price) {
+ $discountPrice = $discountPrice ? $discountPrice : $item->getCalculationPrice();
+ $baseDiscountPrice = $baseDiscountPrice ? $baseDiscountPrice : $item->getBaseCalculationPrice();
+ $this->setItemDiscountPrices($item, $baseDiscountPrice+$basePrice, $discountPrice+$price);
+ }
+ return $this;
+ }
}
diff --git a/app/code/core/Mage/SalesRule/Model/Rule.php b/app/code/core/Mage/SalesRule/Model/Rule.php
index 740ae254d5..b2fee2b90e 100644
--- a/app/code/core/Mage/SalesRule/Model/Rule.php
+++ b/app/code/core/Mage/SalesRule/Model/Rule.php
@@ -30,6 +30,22 @@ class Mage_SalesRule_Model_Rule extends Mage_Rule_Model_Rule
const FREE_SHIPPING_ITEM = 1;
const FREE_SHIPPING_ADDRESS = 2;
+ /**
+ * Prefix of model events names
+ *
+ * @var string
+ */
+ protected $_eventPrefix = 'salesrule_rule';
+
+ /**
+ * Parameter name in event
+ *
+ * In observe method you can use $observer->getEvent()->getRule() in this case
+ *
+ * @var string
+ */
+ protected $_eventObject = 'rule';
+
protected $_labels = array();
protected function _construct()
diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Combine.php b/app/code/core/Mage/SalesRule/Model/Rule/Condition/Combine.php
index dd8c91a057..aaa06e3899 100644
--- a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Combine.php
+++ b/app/code/core/Mage/SalesRule/Model/Rule/Condition/Combine.php
@@ -49,6 +49,13 @@ public function getNewChildSelectOptions()
array('value'=>'salesrule/rule_condition_combine', 'label'=>Mage::helper('salesrule')->__('Conditions combination')),
array('label'=>Mage::helper('salesrule')->__('Cart Attribute'), 'value'=>$attributes),
));
+
+ $additional = new Varien_Object();
+ Mage::dispatchEvent('salesrule_rule_condition_combine', array('additional' => $additional));
+ if ($additionalConditions = $additional->getConditions()) {
+ $conditions = array_merge_recursive($conditions, $additionalConditions);
+ }
+
return $conditions;
}
}
diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Found.php b/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Found.php
index acf798b717..0e8130b35f 100644
--- a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Found.php
+++ b/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Found.php
@@ -66,27 +66,24 @@ public function validate(Varien_Object $object)
$true = (bool)$this->getValue();
$found = false;
foreach ($object->getAllItems() as $item) {
- $found = $all ? true : false;
+ $found = $all;
foreach ($this->getConditions() as $cond) {
$validated = $cond->validate($item);
- if ($all && !$validated) {
- $found = false;
+ if (($all && !$validated) || (!$all && $validated)) {
+ $found = $validated;
break;
- } elseif (!$all && $validated) {
- $found = true;
- break 2;
}
}
- if ($found && $true) {
+ if (($found && $true) || (!$true && $found)) {
break;
}
}
+ // found an item and we're looking for existing one
if ($found && $true) {
- // found an item and we're looking for existing one
-
return true;
- } elseif (!$found && !$true) {
- // not found and we're making sure it doesn't exist
+ }
+ // not found and we're making sure it doesn't exist
+ elseif (!$found && !$true) {
return true;
}
return false;
diff --git a/app/code/core/Mage/SalesRule/Model/Validator.php b/app/code/core/Mage/SalesRule/Model/Validator.php
index 4f56703cca..8cc9bcd69b 100644
--- a/app/code/core/Mage/SalesRule/Model/Validator.php
+++ b/app/code/core/Mage/SalesRule/Model/Validator.php
@@ -167,7 +167,7 @@ public function processFreeShipping(Mage_Sales_Model_Quote_Item_Abstract $item)
{
$address = $this->_getAddress($item);
$item->setFreeShipping(false);
-
+
foreach ($this->_getRules() as $rule) {
/* @var $rule Mage_SalesRule_Model_Rule */
if (!$this->_canProcessRule($rule, $address)) {
@@ -221,7 +221,7 @@ public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
if (!$this->_canProcessRule($rule, $address)) {
continue;
}
-
+
if (!$rule->getActions()->validate($item)) {
continue;
}
@@ -274,8 +274,8 @@ public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
/**
* We can't use row total here because row total not include tax
*/
- $discountAmount = min($itemPrice*$qty, $quoteAmount);
- $baseDiscountAmount = min($baseItemPrice*$qty, $cartRules[$rule->getId()]);
+ $discountAmount = min($itemPrice*$qty - $item->getDiscountAmount(), $quoteAmount);
+ $baseDiscountAmount = min($baseItemPrice*$qty - $item->getBaseDiscountAmount(), $cartRules[$rule->getId()]);
$cartRules[$rule->getId()] -= $baseDiscountAmount;
}
$address->setCartFixedRules($cartRules);
@@ -284,7 +284,7 @@ public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
case 'buy_x_get_y':
$x = $rule->getDiscountStep();
$y = $rule->getDiscountAmount();
- if (!$x || $y>=$x) {
+ if (!$x) {
break;
}
$buy = 0; $free = 0;
@@ -386,7 +386,7 @@ public function processShippingAmount(Mage_Sales_Model_Quote_Address $address)
if (!$rule->getApplyToShipping() || !$this->_canProcessRule($rule, $address)) {
continue;
}
-
+
$discountAmount = 0;
$baseDiscountAmount = 0;
$rulePercent = min(100, $rule->getDiscountAmount());
@@ -417,8 +417,8 @@ public function processShippingAmount(Mage_Sales_Model_Quote_Address $address)
}
if ($cartRules[$rule->getId()] > 0) {
$quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]);
- $discountAmount = min($shippingAmount, $quoteAmount);
- $baseDiscountAmount = min($baseShippingAmount, $cartRules[$rule->getId()]);
+ $discountAmount = min($shippingAmount-$address->getShippingDiscountAmount(), $quoteAmount);
+ $baseDiscountAmount = min($baseShippingAmount-$address->getBaseShippingDiscountAmount(), $cartRules[$rule->getId()]);
$cartRules[$rule->getId()] -= $baseDiscountAmount;
}
$address->setCartFixedRules($cartRules);
@@ -476,7 +476,7 @@ protected function _addDiscountDescription($address, $rule)
} elseif ($rule->getCouponCode()) {
$label = $rule->getCouponCode();
}
-
+
if (!empty($label)) {
$description[$rule->getId()] = $label;
}
diff --git a/app/code/core/Mage/SalesRule/etc/config.xml b/app/code/core/Mage/SalesRule/etc/config.xml
index 1c81493168..13d5e14ff7 100644
--- a/app/code/core/Mage/SalesRule/etc/config.xml
+++ b/app/code/core/Mage/SalesRule/etc/config.xml
@@ -57,20 +57,7 @@
Mage_SalesRule
Mage_Sales_Model_Mysql4_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -83,7 +70,6 @@
- singleton
salesrule/observer
sales_order_afterPlace
@@ -108,33 +94,6 @@
-
-
-
-
- Shopping Cart Price Rules
- adminhtml/promo_quote/
- promo/quote
- Mage_Sales
-
-
-
-
-
-
-
-
-
-
-
- Shopping Cart Price Rules
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Sendfriend/etc/config.xml b/app/code/core/Mage/Sendfriend/etc/config.xml
index 255e62463e..9d525bd546 100644
--- a/app/code/core/Mage/Sendfriend/etc/config.xml
+++ b/app/code/core/Mage/Sendfriend/etc/config.xml
@@ -53,20 +53,7 @@
Mage_Sendfriend
Mage_Sendfriend_Model_Mysql4_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
Mage_Sendfriend_Block
@@ -99,7 +86,6 @@
- singleton
sendfriend/observer
register
diff --git a/app/code/core/Mage/Shipping/Block/Tracking/Popup.php b/app/code/core/Mage/Shipping/Block/Tracking/Popup.php
index 51fdda5632..54496c3872 100644
--- a/app/code/core/Mage/Shipping/Block/Tracking/Popup.php
+++ b/app/code/core/Mage/Shipping/Block/Tracking/Popup.php
@@ -26,51 +26,77 @@
class Mage_Shipping_Block_Tracking_Popup extends Mage_Core_Block_Template
{
-
+ /**
+ * @deprecated after 1.3.2.3
+ */
protected $_track_id;
+ /**
+ * @deprecated after 1.3.2.3
+ */
protected $_order_id;
+ /**
+ * @deprecated after 1.3.2.3
+ */
protected $_ship_id;
+ /**
+ * @deprecated after 1.3.2.3
+ */
public function setOrderId($oid)
{
- $this->_order_id=$oid;
+ return $this->setData('order_id', $oid);
}
+ /**
+ * @deprecated after 1.3.2.3
+ */
public function getOrderId()
{
- return $this->_order_id;
+ return $this->_getData('order_id');
}
+ /**
+ * @deprecated after 1.3.2.3
+ */
public function setShipId($oid)
{
- $this->_ship_id=$oid;
+ return $this->setData('ship_id', $oid);
}
+ /**
+ * @deprecated after 1.3.2.3
+ */
public function getShipId()
{
- return $this->_ship_id;
+ return $this->_getData('ship_id');
}
+ /**
+ * @deprecated after 1.3.2.3
+ */
public function setTrackId($tid='')
{
- $this->_track_id=$tid;
+ return $this->setData('track_id', $tid);
}
+ /**
+ * @deprecated after 1.3.2.3
+ */
public function getTrackId()
{
- return $this->_track_id;
+ return $this->_getData('track_id');
}
/**
- * Initialize order model instance
- *
- * @return Mage_Sales_Model_Order || false
- */
+ * Initialize order model instance
+ *
+ * @return Mage_Sales_Model_Order || false
+ */
protected function _initOrder()
{
- $order = Mage::getModel('sales/order')->load($this->_order_id);
+ $order = Mage::getModel('sales/order')->load($this->getOrderId());
- if (!$order->getId()) {
+ if (!$order->getId() || $this->getProtectCode() != $order->getProtectCode()) {
return false;
}
@@ -84,9 +110,9 @@ protected function _initOrder()
*/
protected function _initShipment()
{
- $ship = Mage::getModel('sales/order_shipment')->load($this->_ship_id);
+ $ship = Mage::getModel('sales/order_shipment')->load($this->getShipId());
- if (!$ship->getEntityId()) {
+ if (!$ship->getEntityId() || $this->getProtectCode() != $ship->getProtectCode()) {
return false;
}
@@ -96,9 +122,11 @@ protected function _initShipment()
public function getTrackingInfo()
{
- $this->setOrderId($this->getRequest()->getParam('order_id'));
- $this->setTrackId($this->getRequest()->getParam('track_id'));
- $this->setShipId($this->getRequest()->getParam('ship_id'));
+ $hash = Mage::helper('shipping')->decodeTrackingHash($this->getRequest()->getParam('hash'));
+ if (!empty($hash)) {
+ $this->setData($hash['key'], $hash['id']);
+ $this->setProtectCode($hash['hash']);
+ }
if ($this->getOrderId()>0) {
return $this->getTrackingInfoByOrder();
@@ -109,9 +137,11 @@ public function getTrackingInfo()
}
}
- /*
- * retrieve all tracking by orders id
- */
+ /**
+ * Retrieve all tracking by orders id
+ *
+ * @return array
+ */
public function getTrackingInfoByOrder()
{
$shipTrack = array();
@@ -131,9 +161,11 @@ public function getTrackingInfoByOrder()
return $shipTrack;
}
- /*
- * retrieve all tracking by ship id
- */
+ /**
+ * Retrieve all tracking by ship id
+ *
+ * @return array
+ */
public function getTrackingInfoByShip()
{
$shipTrack = array();
@@ -151,14 +183,18 @@ public function getTrackingInfoByShip()
return $shipTrack;
}
- /*
- * retrieve tracking by tracking entity id
- */
+ /**
+ * Retrieve tracking by tracking entity id
+ *
+ * @return array
+ */
public function getTrackingInfoByTrackId()
{
- $shipTrack[] = array(Mage::getModel('sales/order_shipment_track')->load($this->getTrackId())
- ->getNumberDetail());
- return $shipTrack;
+ $track = Mage::getModel('sales/order_shipment_track')->load($this->getTrackId());
+ if ($this->getProtectCode() == $track->getProtectCode()) {
+ return array(array($track->getNumberDetail()));
+ }
+ return array(array());
}
/**
diff --git a/app/code/core/Mage/Shipping/Helper/Data.php b/app/code/core/Mage/Shipping/Helper/Data.php
index db21ba12aa..e5aaa1e105 100644
--- a/app/code/core/Mage/Shipping/Helper/Data.php
+++ b/app/code/core/Mage/Shipping/Helper/Data.php
@@ -29,33 +29,100 @@
*/
class Mage_Shipping_Helper_Data extends Mage_Core_Helper_Abstract
{
- public function getTrackingAjaxUrl()
+ /**
+ * Allowed hash keys
+ *
+ * @var array
+ */
+ protected $_allowedHashKeys = array('ship_id', 'order_id', 'track_id');
+
+ /**
+ * Decode url hash
+ *
+ * @param string $hash
+ * @return array
+ */
+ public function decodeTrackingHash($hash)
{
- return $this->_getUrl('shipping/tracking/ajax');
+ $hash = explode(':', Mage::helper('core')->urlDecode($hash));
+ if (count($hash) === 3 && in_array($hash[0], $this->_allowedHashKeys)) {
+ return array('key' => $hash[0], 'id' => (int)$hash[1], 'hash' => $hash[2]);
+ }
+ return array();
+ }
+
+ /**
+ * Retrieve tracking url with params
+ *
+ * @param string $key
+ * @param integer|Mage_Sales_Model_Order|Mage_Sales_Model_Order_Shipment|Mage_Sales_Model_Order_Shipment_Track $model
+ * @param string $method - option
+ * @return string
+ */
+ protected function _getTrackingUrl($key, $model, $method = 'getId')
+ {
+ if (empty($model)) {
+ $param = array($key => '');
+ } else if (!is_object($model)) {
+ $param = array($key => $model);
+ } else {
+ $param = array(
+ 'hash' => Mage::helper('core')->urlEncode("{$key}:{$model->$method()}:{$model->getProtectCode()}")
+ );
+ }
+ return $this->_getUrl('shipping/tracking/popup', $param);
+ }
+
+ /**
+ * Retrieve tracking pop up url by order id or object
+ *
+ * @param int|Mage_Sales_Model_Order $order
+ * @return string
+ */
+ public function getTrackingPopUpUrlByOrderId($order = '')
+ {
+ return $this->_getTrackingUrl('order_id', $order);
}
- public function getTrackingPopUpUrlByOrderId($oid='')
+ /**
+ * Retrieve tracking pop up url by track id or object
+ *
+ * @param int|Mage_Sales_Model_Order_Shipment_Track $track
+ * @return string
+ */
+ public function getTrackingPopUpUrlByTrackId($track = '')
{
- return $this->_getUrl('shipping/tracking/popup',array("order_id"=>$oid));
+ return $this->_getTrackingUrl('track_id', $track, 'getEntityId');
}
- public function getTrackingPopUpUrlByTrackID($tracknum='')
+ /**
+ * Retrieve tracking pop up url by ship id or object
+ *
+ * @param int|Mage_Sales_Model_Order_Shipment $track
+ * @return string
+ */
+ public function getTrackingPopUpUrlByShipId($ship = '')
{
- return $this->_getUrl('shipping/tracking/popup',array("track_id"=>$tracknum));
+ return $this->_getTrackingUrl('ship_id', $ship);
}
- public function getTrackingPopUpUrlByShipId($shipid='')
+ /**
+ * Retrieve tracking ajax url
+ *
+ * @return string
+ */
+ public function getTrackingAjaxUrl()
{
- return $this->_getUrl('shipping/tracking/popup',array("ship_id"=>$shipid));
+ return $this->_getUrl('shipping/tracking/ajax');
}
- public function isFreeMethod($method, $storeId=null)
+ public function isFreeMethod($method, $storeId = null)
{
$arr = explode('_', $method, 2);
if (!isset($arr[1])) {
return false;
}
- $freeMethod = Mage::getStoreConfig('carriers/'.$arr[0].'/free_method', $storeId);
+ $freeMethod = Mage::getStoreConfig('carriers/' . $arr[0] . '/free_method', $storeId);
return $freeMethod == $arr[1];
}
}
diff --git a/app/code/core/Mage/Shipping/Model/Config.php b/app/code/core/Mage/Shipping/Model/Config.php
index aba41e063b..86eb003519 100644
--- a/app/code/core/Mage/Shipping/Model/Config.php
+++ b/app/code/core/Mage/Shipping/Model/Config.php
@@ -41,7 +41,10 @@ public function getActiveCarriers($store=null)
$config = Mage::getStoreConfig('carriers', $store);
foreach ($config as $code => $carrierConfig) {
if (Mage::getStoreConfigFlag('carriers/'.$code.'/active', $store)) {
- $carriers[$code] = $this->_getCarrier($code, $carrierConfig, $store);
+ $carrierModel = $this->_getCarrier($code, $carrierConfig, $store);
+ if ($carrierModel) {
+ $carriers[$code] = $carrierModel;
+ }
}
}
return $carriers;
@@ -58,7 +61,10 @@ public function getAllCarriers($store=null)
$carriers = array();
$config = Mage::getStoreConfig('carriers', $store);
foreach ($config as $code => $carrierConfig) {
- $carriers[$code] = $this->_getCarrier($code, $carrierConfig, $store);
+ $model = $this->_getCarrier($code, $carrierConfig, $store);
+ if ($model) {
+ $carriers[$code] = $model;
+ }
}
return $carriers;
}
@@ -79,6 +85,14 @@ public function getCarrierInstance($carrierCode, $store=null)
return false;
}
+ /**
+ * Get carrier model object
+ *
+ * @param string $code
+ * @param array $config
+ * @param mixed $store
+ * @return Mage_Shipping_Model_Carrier_Abstract
+ */
protected function _getCarrier($code, $config, $store=null)
{
/*
@@ -90,7 +104,19 @@ protected function _getCarrier($code, $config, $store=null)
throw Mage::exception('Mage_Shipping', 'Invalid model for shipping method: '.$code);
}
$modelName = $config['model'];
- $carrier = Mage::getModel($modelName);
+ if ($modelName == 'usa/shipping_carrier_ups') {
+ $modelName.= '_test';
+ }
+ /**
+ * Added protection from not existing models usage.
+ * Related with module uninstall process
+ */
+ try {
+ $carrier = Mage::getModel($modelName);
+ } catch (Exception $e) {
+ Mage::logException($e);
+ return false;
+ }
$carrier->setId($code)->setStore($store);
self::$_carriers[$code] = $carrier;
return self::$_carriers[$code];
diff --git a/app/code/core/Mage/Shipping/controllers/ShippingController.php b/app/code/core/Mage/Shipping/controllers/ShippingController.php
index d0267432df..12629c9cbe 100644
--- a/app/code/core/Mage/Shipping/controllers/ShippingController.php
+++ b/app/code/core/Mage/Shipping/controllers/ShippingController.php
@@ -19,27 +19,23 @@
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
- * @package Mage_Sales
+ * @package Mage_Shipping
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
- * Sales orders controller
- *
- * @category Mage
- * @package Mage_Sales
- * @author Magento Core Team
+ * @deprecated after 1.3.2.3 - this controller is not used anywhere
*/
-
class Mage_Shipping_ShippingController extends Mage_Core_Controller_Front_Action
{
+ /**
+ * @deprecated after 1.3.2.3
+ */
public function viewAction()
{
$params = $this->getRequest()->getPost();
- var_dump($params);
$this->loadLayout();
$this->renderLayout();
}
-
}
diff --git a/app/code/core/Mage/Shipping/etc/config.xml b/app/code/core/Mage/Shipping/etc/config.xml
index bfa648d7db..ea8b04369d 100644
--- a/app/code/core/Mage/Shipping/etc/config.xml
+++ b/app/code/core/Mage/Shipping/etc/config.xml
@@ -51,20 +51,7 @@
Mage_Shipping
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -102,30 +89,6 @@
-
-
-
-
-
-
-
-
-
- Shipping Settings Section
- 0
-
-
- Shipping Methods Section
- 0
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Category.php b/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Category.php
index 049029971d..f30ba493a8 100644
--- a/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Category.php
+++ b/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Category.php
@@ -184,7 +184,7 @@ protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
$this->_getWriteAdapter()->quoteInto('t1_'.$attributeCode.'.entity_id = t2_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.attribute_id = t2_'.$attributeCode.'.attribute_id AND t2_'.$attributeCode.'.store_id=?', $storeId),
array()
)
- ->where('IFNULL(t2_'.$attributeCode.'.value, t1_'.$attributeCode.'.value)'.$conditionRule, $value);
+ ->where('IF(t2_'.$attributeCode.'.value_id>0, t2_'.$attributeCode.'.value, t1_'.$attributeCode.'.value)'.$conditionRule, $value);
}
}
diff --git a/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Product.php b/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Product.php
index e8cd244544..7346f5f57a 100644
--- a/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Product.php
+++ b/app/code/core/Mage/Sitemap/Model/Mysql4/Catalog/Product.php
@@ -118,7 +118,7 @@ protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
$this->_getWriteAdapter()->quoteInto('t1_'.$attributeCode.'.entity_id = t2_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.attribute_id = t2_'.$attributeCode.'.attribute_id AND t2_'.$attributeCode.'.store_id=?', $storeId),
array()
)
- ->where('IFNULL(t2_'.$attributeCode.'.value, t1_'.$attributeCode.'.value)'.$conditionRule, $value);
+ ->where('IF(t2_'.$attributeCode.'.value_id>0, t2_'.$attributeCode.'.value, t1_'.$attributeCode.'.value)'.$conditionRule, $value);
}
}
diff --git a/app/code/core/Mage/Sitemap/etc/config.xml b/app/code/core/Mage/Sitemap/etc/config.xml
index c656da193b..e8ff985a66 100644
--- a/app/code/core/Mage/Sitemap/etc/config.xml
+++ b/app/code/core/Mage/Sitemap/etc/config.xml
@@ -51,20 +51,7 @@
Mage_Sitemap
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -77,43 +64,6 @@
-
-
-
-
- Google Sitemap
- 180
- adminhtml/sitemap/
-
-
-
-
-
-
-
-
-
-
-
- Google Sitemap
-
-
-
-
-
-
-
-
- Google Sitemap Section
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Tag/Block/Customer/Tags.php b/app/code/core/Mage/Tag/Block/Customer/Tags.php
index 6728d216f0..01fa76fbb1 100644
--- a/app/code/core/Mage/Tag/Block/Customer/Tags.php
+++ b/app/code/core/Mage/Tag/Block/Customer/Tags.php
@@ -44,9 +44,8 @@ protected function _loadTags()
$this->_tags = array();
$tags = Mage::getResourceModel('tag/tag_collection')
- ->addPopularity()
+ ->addPopularity(null, Mage::app()->getStore()->getId())
->setOrder('popularity', 'DESC')
- #->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED)
->addCustomerFilter(Mage::getSingleton('customer/session')->getCustomerId())
->setActiveFilter()
->load()
diff --git a/app/code/core/Mage/Tag/Block/Product/List.php b/app/code/core/Mage/Tag/Block/Product/List.php
index c694457c48..e8e9e6f334 100644
--- a/app/code/core/Mage/Tag/Block/Product/List.php
+++ b/app/code/core/Mage/Tag/Block/Product/List.php
@@ -52,7 +52,7 @@ protected function _getCollection()
$model = Mage::getModel('tag/tag');
$this->_collection = $model->getResourceCollection()
- ->addPopularity()
+ ->addPopularity(null, Mage::app()->getStore()->getId())
->addStatusFilter($model->getApprovedStatus())
->addProductFilter($this->getProductId())
->addStoreFilter(Mage::app()->getStore()->getId())
diff --git a/app/code/core/Mage/Tag/Model/Mysql4/Customer/Collection.php b/app/code/core/Mage/Tag/Model/Mysql4/Customer/Collection.php
index 774448cd19..7062039883 100644
--- a/app/code/core/Mage/Tag/Model/Mysql4/Customer/Collection.php
+++ b/app/code/core/Mage/Tag/Model/Mysql4/Customer/Collection.php
@@ -35,7 +35,11 @@
class Mage_Tag_Model_Mysql4_Customer_Collection extends Mage_Customer_Model_Entity_Customer_Collection
{
protected $_allowDisableGrouping = true;
- protected $_countAttribute = 'tr.tag_relation_id';
+ protected $_countAttribute = 'tr.tag_id';
+
+ /**
+ * @deprecated after 1.3.2.3
+ */
protected $_joinFlags = array();
public function _initSelect()
@@ -46,25 +50,44 @@ public function _initSelect()
return $this;
}
+ /**
+ * Set flag about joined table.
+ * setFlag method must be used in future.
+ *
+ * @deprecated after 1.3.2.3
+ * @param string $table
+ * @return Mage_Tag_Model_Mysql4_Customer_Collection
+ */
public function setJoinFlag($table)
{
- $this->_joinFlags[$table] = true;
+ $this->setFlag($table, true);
return $this;
}
+ /**
+ * Get flag's status about joined table.
+ * getFlag method must be used in future.
+ *
+ * @deprecated after 1.3.2.3
+ * @param $table
+ * @return bool
+ */
public function getJoinFlag($table)
{
- return isset($this->_joinFlags[$table]);
+ return $this->getFlag($table);
}
+ /**
+ * Unset value of join flag.
+ * Set false (bool) value to flag instead in future.
+ *
+ * @deprecated after 1.3.2.3
+ * @param $table
+ * @return Mage_Tag_Model_Mysql4_Customer_Collection
+ */
public function unsetJoinFlag($table=null)
{
- if (is_null($table)) {
- $this->_joinFlags = array();
- } elseif ($this->getJoinFlag($table)) {
- unset($this->_joinFlags[$table]);
- }
-
+ $this->setFlag($table, false);
return $this;
}
@@ -82,6 +105,18 @@ public function addProductFilter($productId)
return $this;
}
+ /**
+ * Apply filter by store id(s).
+ *
+ * @param int|array $storeId
+ * @return Mage_Tag_Model_Mysql4_Customer_Collection
+ */
+ public function addStoreFilter($storeId)
+ {
+ $this->getSelect()->where('tr.store_id IN (?)', $storeId);
+ return $this;
+ }
+
public function addStatusFilter($status)
{
$this->getSelect()
@@ -99,9 +134,9 @@ public function addDescOrder()
public function addGroupByTag()
{
$this->getSelect()
- ->group('tr.tag_relation_id');
+ ->group('tr.tag_id');
- $this->_allowDisableGrouping = false;
+ $this->_allowDisableGrouping = true;
return $this;
}
@@ -144,18 +179,14 @@ protected function _joinFields()
public function getSelectCountSql()
{
- $countSelect = clone $this->getSelect();
- $countSelect->reset(Zend_Db_Select::ORDER);
- $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
- $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
+ $countSelect = parent::getSelectCountSql();
- if( $this->_allowDisableGrouping ) {
+ if ($this->_allowDisableGrouping) {
+ $countSelect->reset(Zend_Db_Select::COLUMNS);
$countSelect->reset(Zend_Db_Select::GROUP);
+ $countSelect->from('', 'COUNT(DISTINCT ' . $this->getCountAttribute() . ')');
}
-
- $sql = $countSelect->__toString();
- $sql = preg_replace('/^select\s+.+?\s+from\s+/is', "select count({$this->getCountAttribute()}) from ", $sql);
- return $sql;
+ return $countSelect;
}
public function addProductName()
@@ -229,4 +260,4 @@ public function addFieldToFilter($attribute, $condition=null){
return parent::addFieldToFilter($attribute, $condition);
}
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Tag/Model/Mysql4/Popular/Collection.php b/app/code/core/Mage/Tag/Model/Mysql4/Popular/Collection.php
index 6e2f4a688b..2fd1344230 100644
--- a/app/code/core/Mage/Tag/Model/Mysql4/Popular/Collection.php
+++ b/app/code/core/Mage/Tag/Model/Mysql4/Popular/Collection.php
@@ -40,20 +40,31 @@ protected function _construct()
$this->_init('tag/tag');
}
+ /**
+ * Replacing popularity by sum of popularity and base_popularity
+ *
+ * @param int $storeId
+ * @return Mage_Tag_Model_Mysql4_Popular_Collection
+ */
public function joinFields($storeId = 0)
{
$this->getSelect()
->reset()
- ->from(array('main_table' => $this->getTable('tag/summary')))
+ ->from(
+ array('main_table' => $this->getTable('tag/summary')),
+ array(
+ 'tag_id',
+ 'popularity' => '(main_table.popularity + main_table.base_popularity)'
+ )
+ )
->join(
- array('tag' => $this->getTable('tag/tag')),
+ array('tag' => $this->getTable('tag/tag')),
'tag.tag_id = main_table.tag_id AND tag.status = '.Mage_Tag_Model_Tag::STATUS_APPROVED)
->where('main_table.store_id = ?', $storeId)
->order('popularity desc');
-
return $this;
}
-
+
public function load($printQuery = false, $logQuery = false)
{
if ($this->isLoaded()) {
@@ -62,7 +73,7 @@ public function load($printQuery = false, $logQuery = false)
parent::load($printQuery, $logQuery);
return $this;
}
-
+
public function limit($limit)
{
$this->getSelect()->limit($limit);
diff --git a/app/code/core/Mage/Tag/Model/Mysql4/Product/Collection.php b/app/code/core/Mage/Tag/Model/Mysql4/Product/Collection.php
index 8bdc13ca71..cf7e9413c1 100644
--- a/app/code/core/Mage/Tag/Model/Mysql4/Product/Collection.php
+++ b/app/code/core/Mage/Tag/Model/Mysql4/Product/Collection.php
@@ -51,6 +51,7 @@ class Mage_Tag_Model_Mysql4_Product_Collection extends Mage_Catalog_Model_Resour
/**
* Join Flags
*
+ * @deprecated after 1.3.2.3
* @var array
*/
protected $_joinFlags = array();
@@ -71,43 +72,43 @@ protected function _initSelect()
}
/**
- * Set join flag
+ * Set flag about joined table.
+ * setFlag method must be used in future.
*
+ * @deprecated after 1.3.2.3
* @param string $table
* @return Mage_Tag_Model_Mysql4_Product_Collection
*/
public function setJoinFlag($table)
{
- $this->_joinFlags[$table] = true;
+ $this->setFlag($table, true);
return $this;
}
/**
- * Retrieve join flag
+ * Get flag's status about joined table.
+ * getFlag method must be used in future.
*
- * @param string $table
+ * @deprecated after 1.3.2.3
+ * @param $table
* @return bool
*/
public function getJoinFlag($table)
{
- return isset($this->_joinFlags[$table]);
+ return $this->getFlag($table);
}
/**
- * Unset join flag
+ * Unset value of join flag.
+ * Set false (bool) value to flag instead in future.
*
- * @param string $table
+ * @deprecated after 1.3.2.3
+ * @param $table
* @return Mage_Tag_Model_Mysql4_Product_Collection
*/
- public function unsetJoinFlag($table = null)
+ public function unsetJoinFlag($table=null)
{
- if (is_null($table)) {
- $this->_joinFlags = array();
- }
- elseif ($this->getJoinFlag($table)) {
- unset($this->_joinFlags[$table]);
- }
-
+ $this->setFlag($table, false);
return $this;
}
@@ -118,7 +119,7 @@ public function unsetJoinFlag($table = null)
*/
public function addStoresVisibility()
{
- $this->setJoinFlag('add_stores_after');
+ $this->setFlag('add_stores_after', true);
return $this;
}
@@ -172,16 +173,37 @@ public function addGroupByTag()
return $this;
}
+ /**
+ * Add Store ID filter
+ *
+ * @param int|array $store
+ * @return Mage_Tag_Model_Mysql4_Product_Collection
+ */
+ public function addStoreFilter($store=null)
+ {
+ if (!is_null($store)) {
+ $this->getSelect()->where('relation.store_id IN (?)', $store);
+ }
+ return $this;
+ }
+
/**
* Set Customer filter
+ * If incoming parameter is array and has element with key 'null'
+ * then condition with IS NULL or IS NOT NULL will be added.
+ * Otherwise condition with IN() will be added
*
- * @param int $customerId
+ * @param int|array $customerId
* @return Mage_Tag_Model_Mysql4_Product_Collection
*/
public function addCustomerFilter($customerId)
{
- $this->getSelect()
- ->where('relation.customer_id = ?', $customerId);
+ if (is_array($customerId) && isset($customerId['null'])) {
+ $condition = ($customerId['null']) ? 'IS NULL' : 'IS NOT NULL';
+ $this->getSelect()->where('relation.customer_id ' . $condition);
+ return $this;
+ }
+ $this->getSelect()->where('relation.customer_id IN(?)', $customerId);
$this->_customerFilterId = $customerId;
return $this;
}
@@ -195,7 +217,7 @@ public function addCustomerFilter($customerId)
public function addTagFilter($tagId)
{
$this->getSelect()->where('relation.tag_id = ?', $tagId);
- $this->setJoinFlag('distinct');
+ $this->setFlag('distinct', true);
return $this;
}
@@ -237,9 +259,9 @@ public function addPopularity($tagId, $storeId=null)
$condition = array(
'prelation.product_id=e.entity_id'
);
+
if (!is_null($storeId)) {
- $condition[] = $this->getConnection()
- ->quoteInto('prelation.store_id=?', $storeId);
+ $condition[] = $this->getConnection()->quoteInto('prelation.store_id = ?', $storeId);
}
$condition = join(' AND ', $condition);
@@ -251,7 +273,7 @@ public function addPopularity($tagId, $storeId=null)
->where('prelation.tag_id = ?', $tagId);
$this->_tagIdFilter = $tagId;
- $this->setJoinFlag('prelation');
+ $this->setFlag('prelation', true);
return $this;
}
@@ -296,7 +318,7 @@ public function setActiveFilter()
{
$active = Mage_Tag_Model_Tag_Relation::STATUS_ACTIVE;
$this->getSelect()->where('relation.active=?', $active);
- if ($this->getJoinFlag('prelation')) {
+ if ($this->getFlag('prelation')) {
$this->getSelect()->where('prelation.active=?', $active);
}
return $this;
@@ -344,11 +366,15 @@ protected function _joinFields()
->addAttributeToSelect('small_image');
$this->getSelect()
- ->join(array('relation' => $tagRelationTable), 'relation.product_id = e.entity_id')
+ ->join(array('relation' => $tagRelationTable), 'relation.product_id = e.entity_id', array(
+ 'product_id' => 'product_id',
+ 'item_store_id' => 'store_id',
+ ))
->join(array('t' => $tagTable),
't.tag_id = relation.tag_id',
array('tag_id', 'name', 'tag_status' => 'status', 'tag_name' => 'name')
);
+
return $this;
}
@@ -361,7 +387,7 @@ protected function _afterLoad()
{
parent::_afterLoad();
- if ($this->getJoinFlag('add_stores_after')) {
+ if ($this->getFlag('add_stores_after')) {
$this->_addStoresVisibility();
}
@@ -389,14 +415,14 @@ public function getSelectCountSql()
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
$countSelect->reset(Zend_Db_Select::GROUP);
- if ($this->getJoinFlag('group_tag')) {
+ if ($this->getFlag('group_tag')) {
$field = 'relation.tag_id';
}
else {
$field = 'e.entity_id';
}
$expr = new Zend_Db_Expr('COUNT('
- . ($this->getJoinFlag('distinct') ? 'DISTINCT ' : '')
+ . ($this->getFlag('distinct') ? 'DISTINCT ' : '')
. $field . ')');
$countSelect->from(null, $expr);
diff --git a/app/code/core/Mage/Tag/Model/Mysql4/Tag.php b/app/code/core/Mage/Tag/Model/Mysql4/Tag.php
index ca093b4f58..2bab2bf8da 100644
--- a/app/code/core/Mage/Tag/Model/Mysql4/Tag.php
+++ b/app/code/core/Mage/Tag/Model/Mysql4/Tag.php
@@ -53,10 +53,17 @@ protected function _initUniqueFields()
return $this;
}
+ /**
+ * Loading tag by name
+ *
+ * @param Mage_Tag_Model_Tag $model
+ * @param string $name
+ * @return unknown
+ */
public function loadByName($model, $name)
{
if( $name ) {
- $read = $this->_getReadAdapter();
+ $read = $this->_getWriteAdapter();
$select = $read->select();
if (Mage::helper('core/string')->strlen($name) > 255) {
$name = Mage::helper('core/string')->substr($name, 0, 255);
@@ -89,9 +96,35 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object)
return parent::_beforeSave($object);
}
- public function aggregate($object)
+ /**
+ * Getting base popularity per store view for specified tag
+ *
+ * @param int $tagId
+ * @return array
+ */
+ protected function _getExistingBasePopularity($tagId)
+ {
+ $selectSummary = $this->_getWriteAdapter()->select()
+ ->from(
+ array('main' => $this->getTable('summary')),
+ array('store_id', 'base_popularity')
+ )
+ ->where('main.tag_id = ?', $tagId)
+ ->where('main.store_id != 0');
+
+ return $this->_getWriteAdapter()->fetchAssoc($selectSummary);
+ }
+
+
+ /**
+ * Get aggregation data per store view
+ *
+ * @param int $tagId
+ * @return array
+ */
+ protected function _getAggregationPerStoreView($tagId)
{
- $selectLocal = $this->_getReadAdapter()->select()
+ $selectLocal = $this->_getWriteAdapter()->select()
->from(
array('main' => $this->getTable('relation')),
array(
@@ -109,19 +142,18 @@ public function aggregate($object)
'product_website.website_id=store.website_id AND product_website.product_id=main.product_id',
array()
)
- ->where('main.tag_id = ?', $object->getId())
+ ->where('main.tag_id = ?', $tagId)
->where('main.active')
+ ->where('main.customer_id IS NOT NULL')
->group('main.store_id');
- $selectGlobal = $this->_getReadAdapter()->select()
+ $selectLocalResult = $this->_getWriteAdapter()->fetchAll($selectLocal);
+
+ $selectHistorical = $this->_getWriteAdapter()->select()
->from(
array('main'=>$this->getTable('relation')),
- array(
- 'customers'=>'COUNT(DISTINCT main.customer_id)',
- 'products'=>'COUNT(DISTINCT main.product_id)',
- 'store_id'=>'( 0 )' /* Workaround*/,
- 'uses'=>'COUNT(main.tag_relation_id)'
- )
+ array('historical_uses'=>'COUNT(main.tag_relation_id)',
+ 'store_id')
)
->join(array('store' => $this->getTable('core/store')),
'store.store_id=main.store_id AND store.store_id>0',
@@ -131,14 +163,42 @@ public function aggregate($object)
'product_website.website_id=store.website_id AND product_website.product_id=main.product_id',
array()
)
- ->where('main.tag_id = ?', $object->getId())
- ->where('main.active');
+ ->group('main.store_id')
+ ->where('main.customer_id IS NOT NULL')
+ ->where('main.tag_id = ?', $tagId);
- $selectHistorical = $this->_getReadAdapter()->select()
+ $selectHistoricalResult = $this->_getWriteAdapter()->fetchAll($selectHistorical);
+
+ foreach ($selectHistoricalResult as $historical) {
+ foreach ($selectLocalResult as $key => $local) {
+ if ($local['store_id'] == $historical['store_id']) {
+ $selectLocalResult[$key]['historical_uses'] = $historical['historical_uses'];
+ break;
+ }
+ }
+ }
+
+ return $selectLocalResult;
+ }
+
+ /**
+ * Get global aggregation data for row with store_id = 0
+ *
+ * @param int $tagId
+ * @return array
+ */
+ protected function _getGlobalAggregation($tagId)
+ {
+ // customers and products stats
+ $selectGlobal = $this->_getWriteAdapter()->select()
->from(
array('main'=>$this->getTable('relation')),
- array('historical_uses'=>'COUNT(main.tag_relation_id)',
- 'store_id')
+ array(
+ 'customers'=>'COUNT(DISTINCT main.customer_id)',
+ 'products'=>'COUNT(DISTINCT main.product_id)',
+ 'store_id'=>'( 0 )' /* Workaround*/,
+ 'uses'=>'COUNT(main.tag_relation_id)'
+ )
)
->join(array('store' => $this->getTable('core/store')),
'store.store_id=main.store_id AND store.store_id>0',
@@ -148,10 +208,16 @@ public function aggregate($object)
'product_website.website_id=store.website_id AND product_website.product_id=main.product_id',
array()
)
- ->group('main.store_id')
- ->where('main.tag_id = ?', $object->getId());
+ ->where('main.tag_id = ?', $tagId)
+ ->where('main.customer_id IS NOT NULL')
+ ->where('main.active');
+ $result = $this->_getWriteAdapter()->fetchRow($selectGlobal);
+ if (!$result) {
+ return array();
+ }
- $selectHistoricalGlobal = $this->_getReadAdapter()->select()
+ // historical uses stats
+ $selectHistoricalGlobal = $this->_getWriteAdapter()->select()
->from(
array('main'=>$this->getTable('relation')),
array('historical_uses'=>'COUNT(main.tag_relation_id)')
@@ -164,53 +230,102 @@ public function aggregate($object)
'product_website.website_id=store.website_id AND product_website.product_id=main.product_id',
array()
)
- ->where('main.tag_id = ?', $object->getId());
+ ->where('main.tag_id = ?', $tagId)
+ ->where('main.customer_id IS NOT NULL');
+ $result['historical_uses'] = (int)$this->_getWriteAdapter()->fetchOne($selectHistoricalGlobal);
- $historicalAll = $this->_getReadAdapter()->fetchAll($selectHistorical);
- $historicalCache = array();
- foreach ($historicalAll as $historical) {
- $historicalCache[$historical['store_id']] = $historical['historical_uses'];
- }
-
- $summaries = $this->_getReadAdapter()->fetchAll($selectLocal);
- if ($row = $this->_getReadAdapter()->fetchRow($selectGlobal)) {
- $historical = $this->_getReadAdapter()->fetchOne($selectHistoricalGlobal);
+ return $result;
+ }
- if($historical) {
- $row['historical_uses'] = $historical;
- }
+ /**
+ * Getting statistics data into buffer.
+ * Replacing our buffer array with new statistics and incoming data.
+ *
+ * @param Mage_Tag_Model_Tag $object
+ * @return Mage_Tag_Model_Tag
+ */
+ public function aggregate($object)
+ {
+ $tagId = (int)$object->getId();
+ $storeId = (int)$object->getStoreId();
- $summaries[] = $row;
+ // create final summary from existing data and add specified base popularity
+ $finalSummary = $this->_getExistingBasePopularity($tagId);
+ if ($object->hasBasePopularity() && $storeId) {
+ $finalSummary[$storeId]['store_id'] = $storeId;
+ $finalSummary[$storeId]['base_popularity'] = $object->getBasePopularity();
}
- $this->_getReadAdapter()->delete($this->getTable('summary'), $this->_getReadAdapter()->quoteInto('tag_id = ?', $object->getId()));
+ // calculate aggregation data
+ $summaries = $this->_getAggregationPerStoreView($tagId);
+ $summariesGlobal = $this->_getGlobalAggregation($tagId);
+ if ($summariesGlobal) {
+ $summaries[] = $summariesGlobal;
+ }
- foreach ($summaries as $summary) {
- if(!isset($summary['historical_uses'])) {
- $summary['historical_uses'] = isset($historicalCache[$summary['store_id']]) ? $historicalCache[$summary['store_id']] : 0;
- }
- $summary['tag_id'] = $object->getId();
- $summary['popularity'] = $summary['historical_uses'];
- if (is_null($summary['uses'])) {
- $summary['uses'] = 0;
+ // override final summary with aggregated data
+ foreach ($summaries as $row) {
+ $storeId = (int)$row['store_id'];
+ foreach ($row as $key => $value) {
+ $finalSummary[$storeId][$key] = $value;
}
+ }
- $this->_getReadAdapter()->insert($this->getTable('summary'), $summary);
+ // prepare static parameters to final summary for insertion
+ foreach ($finalSummary as $key => $row) {
+ $finalSummary[$key]['tag_id'] = $tagId;
+ foreach (array('base_popularity', 'popularity', 'historical_uses', 'uses', 'products', 'customers') as $k) {
+ if (!isset($row[$k])) {
+ $finalSummary[$key][$k] = 0;
+ }
+ }
+ $finalSummary[$key]['popularity'] = $finalSummary[$key]['historical_uses'];
}
+ // remove old and insert new data
+ $this->_getWriteAdapter()->delete(
+ $this->getTable('summary'), $this->_getWriteAdapter()->quoteInto('tag_id = ?', $tagId)
+ );
+ $this->_getWriteAdapter()->insertMultiple($this->getTable('summary'), $finalSummary);
+
return $object;
}
+ /**
+ * Add summary data
+ *
+ * @param Mage_Tag_Model_Tag $object
+ * @return Mage_Tag_Model_Tag
+ */
public function addSummary($object)
{
- $select = $this->_getReadAdapter()->select()
+ $select = $this->_getWriteAdapter()->select()
->from($this->getTable('summary'))
- ->where('tag_id = ?', $object->getId())
- ->where('store_id = ?', $object->getStoreId());
+ ->where('tag_id = ?', (int)$object->getId())
+ ->where('store_id = ?', (int)$object->getStoreId())
+ ->limit(1);
- $row = $this->_getReadAdapter()->fetchAll($select);
-
- $object->addData($row);
+ $row = $this->_getWriteAdapter()->fetchRow($select);
+ if ($row) {
+ $object->addData($row);
+ }
return $object;
}
-}
\ No newline at end of file
+
+ /**
+ * Fetch store ids in which tag visible
+ *
+ * @param Mage_Tag_Model_Mysql4_Tag $object
+ */
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
+ {
+ $select = $this->_getWriteAdapter()->select()
+ ->from($this->getTable('tag/summary'), array('store_id'))
+ ->where('tag_id = ?', $object->getId());
+ $storeIds = $this->_getWriteAdapter()->fetchCol($select);
+
+ $object->setVisibleInStoreIds($storeIds);
+
+ return $this;
+ }
+}
diff --git a/app/code/core/Mage/Tag/Model/Mysql4/Tag/Collection.php b/app/code/core/Mage/Tag/Model/Mysql4/Tag/Collection.php
index ff0a21e07f..dc426bf605 100644
--- a/app/code/core/Mage/Tag/Model/Mysql4/Tag/Collection.php
+++ b/app/code/core/Mage/Tag/Model/Mysql4/Tag/Collection.php
@@ -34,7 +34,16 @@
class Mage_Tag_Model_Mysql4_Tag_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
+ /**
+ * Use getFlag('store_filter') & setFlag('store_filter', true) instead.
+ *
+ * @deprecated after 1.3.2.3
+ */
protected $_isStoreFilter = false;
+
+ /**
+ * @deprecated after 1.3.2.3
+ */
protected $_joinFlags = array();
var $_map = array(
@@ -54,82 +63,110 @@ public function load($printQuery = false, $logQuery = false)
return $this;
}
parent::load($printQuery, $logQuery);
- if ($this->getJoinFlag('add_stores_after')) {
+ if ($this->getFlag('add_stores_after')) {
$this->_addStoresVisibility();
}
return $this;
}
+ /**
+ * Set flag about joined table.
+ * setFlag method must be used in future.
+ *
+ * @deprecated after 1.3.2.3
+ * @param string $table
+ * @return Mage_Tag_Model_Mysql4_Tag_Collection
+ */
public function setJoinFlag($table)
{
- $this->_joinFlags[$table] = true;
+ $this->setFlag($table, true);
return $this;
}
+ /**
+ * Get flag's status about joined table.
+ * getFlag method must be used in future.
+ *
+ * @deprecated after 1.3.2.3
+ * @param $table
+ * @return bool
+ */
public function getJoinFlag($table)
{
- return isset($this->_joinFlags[$table]);
+ return $this->getFlag($table);
}
+ /**
+ * Unset value of join flag.
+ * Set false (bool) value to flag instead in future.
+ *
+ * @deprecated after 1.3.2.3
+ * @param $table
+ * @return Mage_Tag_Model_Mysql4_Tag_Collection
+ */
public function unsetJoinFlag($table=null)
{
- if (is_null($table)) {
- $this->_joinFlags = array();
- } elseif ($this->getJoinFlag($table)) {
- unset($this->_joinFlags[$table]);
- }
-
+ $this->setFlag($table, false);
return $this;
}
-
public function limit($limit)
{
$this->getSelect()->limit($limit);
return $this;
}
-
- public function addPopularity($limit=null)
+ /**
+ * Replacing popularity by sum of popularity and base_popularity
+ *
+ * @param int $limit
+ * @return Mage_Tag_Model_Mysql4_Tag_Collection
+ */
+ public function addPopularity($limit = null)
{
- $this->getSelect()
- ->joinLeft(
- array('prelation'=>$this->getTable('tag/relation')),
- 'main_table.tag_id=prelation.tag_id',
- array('popularity' => 'COUNT(DISTINCT relation.tag_relation_id)'
- ))
- ->group('main_table.tag_id');
- $this->joinRel();
- if (! is_null($limit)) {
- $this->getSelect()->limit($limit);
+ if (!$this->getFlag('popularity')) {
+ $this->getSelect()
+ ->joinLeft(array('relation'=>$this->getTable('tag/relation')), 'main_table.tag_id=relation.tag_id')
+ ->joinLeft(array('summary'=>$this->getTable('tag/summary')), 'main_table.tag_id=summary.tag_id',
+ array('popularity' => '(summary.popularity + summary.base_popularity)')
+ )
+ ->group('main_table.tag_id');
+
+ if (! is_null($limit)) {
+ $this->getSelect()->limit($limit);
+ }
+
+ $this->setFlag('popularity');
}
- $this->setJoinFlag('prelation');
return $this;
}
public function addSummary($storeId)
{
- $joinCondition = '';
- if (is_array($storeId)) {
- $joinCondition = ' AND summary.store_id IN (' . implode(',', $storeId) . ')';
- } else {
- $joinCondition = $this->getConnection()->quoteInto(' AND summary.store_id = ?', (int)$storeId);
- }
+ if (!$this->getFlag('summary')) {
+ $joinCondition = '';
+ if (is_array($storeId)) {
+ $joinCondition = ' AND summary.store_id IN (' . implode(',', $storeId) . ')';
+ } else {
+ $joinCondition = $this->getConnection()->quoteInto(' AND summary.store_id = ?', (int)$storeId);
+ }
- $this->getSelect()
- ->joinLeft(
- array('summary'=>$this->getTable('tag/summary')),
- 'main_table.tag_id=summary.tag_id' . $joinCondition,
- array('store_id','popularity', 'customers', 'products', 'uses', 'historical_uses'
- ));
+ $this->getSelect()
+ ->joinLeft(
+ array('summary'=>$this->getTable('tag/summary')),
+ 'main_table.tag_id=summary.tag_id' . $joinCondition,
+ array('store_id','popularity', 'base_popularity', 'customers', 'products', 'uses', 'historical_uses'
+ ));
- $this->setJoinFlag('summary');
+ $this->setFlag('summary', true);
+ }
return $this;
}
public function addStoresVisibility()
{
- $this->setJoinFlag('add_stores_after');
+ $this->setFlag('add_stores_after', true);
+
return $this;
}
@@ -143,6 +180,7 @@ protected function _addStoresVisibility()
->from($this->getTable('summary'), array('store_id', 'tag_id'))
->where('tag_id IN(?)', $tagIds);
$tagsRaw = $this->getConnection()->fetchAll($select);
+
foreach ($tagsRaw as $tag) {
if (!isset($tagsStores[$tag['tag_id']])) {
$tagsStores[$tag['tag_id']] = array();
@@ -165,10 +203,10 @@ protected function _addStoresVisibility()
public function addFieldToFilter($field, $condition=null)
{
- if ($this->getJoinFlag('relation') && 'popularity' == $field) {
+ if ($this->getFlag('relation') && 'popularity' == $field) {
// TOFIX
$this->getSelect()->having($this->_getConditionSql('count(relation.tag_relation_id)', $condition));
- } elseif ($this->getJoinFlag('summary') && in_array($field, array('customers', 'products', 'uses', 'historical_uses', 'popularity'))) {
+ } elseif ($this->getFlag('summary') && in_array($field, array('customers', 'products', 'uses', 'historical_uses', 'popularity'))) {
$this->getSelect()->where($this->_getConditionSql('summary.'.$field, $condition));
} else {
parent::addFieldToFilter($field, $condition);
@@ -199,28 +237,28 @@ public function getSelectCountSql()
public function addStoreFilter($storeId, $allFilter = true)
{
- if ($this->_isStoreFilter) {
- return $this;
- }
- if (!is_array($storeId)) {
- $storeId = array($storeId);
- }
- $this->getSelect()->join(array(
- 'summary_store'=>$this->getTable('summary')),
- 'main_table.tag_id = summary_store.tag_id
- AND summary_store.store_id IN (' . implode(',', $storeId) . ')',
- array());
+ if (!$this->getFlag('store_filter')) {
+ if (!is_array($storeId)) {
+ $storeId = array($storeId);
+ }
+ $this->getSelect()->join(array(
+ 'summary_store'=>$this->getTable('summary')),
+ 'main_table.tag_id = summary_store.tag_id
+ AND summary_store.store_id IN (' . implode(',', $storeId) . ')',
+ array());
- $this->getSelect()->group('summary_store.tag_id');
+ $this->getSelect()->group('summary_store.tag_id');
- if($this->getJoinFlag('relation') && $allFilter) {
- $this->getSelect()->where('relation.store_id IN (' . implode(',', $storeId) . ')');
- }
+ if($this->getFlag('relation') && $allFilter) {
+ $this->getSelect()->where('relation.store_id IN (' . implode(',', $storeId) . ')');
+ }
+
+ if($this->getFlag('prelation') && $allFilter) {
+ $this->getSelect()->where('prelation.store_id IN (' . implode(',', $storeId) . ')');
+ }
- if($this->getJoinFlag('prelation') && $allFilter) {
- $this->getSelect()->where('prelation.store_id IN (' . implode(',', $storeId) . ')');
+ $this->setFlag('store_filter', true);
}
- $this->_isStoreFilter = true;
return $this;
}
@@ -228,7 +266,7 @@ public function addStoreFilter($storeId, $allFilter = true)
public function setActiveFilter()
{
$this->getSelect()->where('relation.active = 1');
- if($this->getJoinFlag('prelation')) {
+ if($this->getFlag('prelation')) {
$this->getSelect()->where('prelation.active = 1');
}
return $this;
@@ -243,7 +281,7 @@ public function addStatusFilter($status)
public function addProductFilter($productId)
{
$this->addFieldToFilter('relation.product_id', $productId);
- if($this->getJoinFlag('prelation')) {
+ if($this->getFlag('prelation')) {
$this->addFieldToFilter('prelation.product_id', $productId);
}
return $this;
@@ -253,7 +291,7 @@ public function addCustomerFilter($customerId)
{
$this->getSelect()
->where('relation.customer_id = ?', $customerId);
- if($this->getJoinFlag('prelation')) {
+ if($this->getFlag('prelation')) {
$this->getSelect()
->where('prelation.customer_id = ?', $customerId);
}
@@ -270,8 +308,8 @@ public function addTagGroup()
public function joinRel()
{
- $this->setJoinFlag('relation');
+ $this->setFlag('relation', true);
$this->getSelect()->joinLeft(array('relation'=>$this->getTable('tag/relation')), 'main_table.tag_id=relation.tag_id');
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/app/code/core/Mage/Tag/Model/Mysql4/Tag/Relation.php b/app/code/core/Mage/Tag/Model/Mysql4/Tag/Relation.php
index bda66117b5..8d89f666c4 100644
--- a/app/code/core/Mage/Tag/Model/Mysql4/Tag/Relation.php
+++ b/app/code/core/Mage/Tag/Model/Mysql4/Tag/Relation.php
@@ -84,11 +84,18 @@ public function getProductIds($model)
{
$select = $this->_getReadAdapter()->select()
->from($this->getMainTable(), 'product_id')
- ->where("tag_id=?", $model->getTagId())
- ->where('customer_id=?', $model->getCustomerId());
+ ->where("tag_id=?", $model->getTagId());
+
+ if (is_null($model->getCustomerId())) {
+ $select->where('customer_id IS NULL');
+ } else {
+ $select->where('customer_id=?', $model->getCustomerId());
+ }
+
if ($model->hasStoreId()) {
$select->where('store_id = ?', $model->getStoreId());
}
+
return $this->_getReadAdapter()->fetchCol($select);
}
@@ -107,4 +114,49 @@ public function deactivate($tagId, $customerId)
$this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition);
return $this;
}
+
+ /**
+ * Add TAG to PRODUCT relations
+ *
+ * @param Mage_Tag_Model_Tag_Relation $model
+ * @return Mage_Tag_Model_Mysql4_Tag_Relation
+ */
+ public function addRelations($model)
+ {
+ $addedIds = $model->getAddedProductIds();
+
+ $select = $this->_getWriteAdapter()->select()
+ ->from($this->getMainTable(), 'product_id')
+ ->where("tag_id = ?", $model->getTagId())
+ ->where("store_id = ?", $model->getStoreId())
+ ->where("customer_id IS NULL");
+ $oldRelationIds = $this->_getWriteAdapter()->fetchCol($select);
+
+ $insert = array_diff($addedIds, $oldRelationIds);
+ $delete = array_diff($oldRelationIds, $addedIds);
+
+ if (!empty($insert)) {
+ $insertData = array();
+ foreach ($insert as $value) {
+ $insertData[] = array(
+ 'tag_id' => $model->getTagId(),
+ 'store_id' => $model->getStoreId(),
+ 'product_id' => $value,
+ 'customer_id' => $model->getCustomerId(),
+ 'created_at' => $this->formatDate(time())
+ );
+ }
+ $this->_getWriteAdapter()->insertMultiple($this->getMainTable(), $insertData);
+ }
+
+ if (!empty($delete)) {
+ $this->_getWriteAdapter()->delete($this->getMainTable(), array(
+ $this->_getWriteAdapter()->quoteInto('product_id IN (?)', $delete),
+ $this->_getWriteAdapter()->quoteInto('store_id = ?', $model->getStoreId()),
+ 'customer_id IS NULL'
+ ));
+ }
+
+ return $this;
+ }
}
diff --git a/app/code/core/Mage/Tag/Model/Tag.php b/app/code/core/Mage/Tag/Model/Tag.php
index 62a3a15e01..47e8ab8c85 100644
--- a/app/code/core/Mage/Tag/Model/Tag.php
+++ b/app/code/core/Mage/Tag/Model/Tag.php
@@ -149,6 +149,20 @@ public function getPopularCollection()
return Mage::getResourceModel('tag/popular_collection');
}
+ /**
+ * Retrieves array of related product IDs
+ *
+ * @return array
+ */
+ public function getRelatedProductIds()
+ {
+ return Mage::getModel('tag/tag_relation')
+ ->setTagId($this->getTagId())
+ ->setStoreId($this->getStoreId())
+ ->setCustomerId(null)
+ ->getProductIds();
+ }
+
protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
diff --git a/app/code/core/Mage/Tag/Model/Tag/Relation.php b/app/code/core/Mage/Tag/Model/Tag/Relation.php
index e794aa017e..192d16e564 100644
--- a/app/code/core/Mage/Tag/Model/Tag/Relation.php
+++ b/app/code/core/Mage/Tag/Model/Tag/Relation.php
@@ -101,4 +101,21 @@ public function deactivate()
$this->_getResource()->deactivate($this->getTagId(), $this->getCustomerId());
return $this;
}
+
+ /**
+ * Add TAG to PRODUCT relations
+ *
+ * @param Mage_Tag_Model_Tag $model
+ * @param array $productIds
+ * @return Mage_Tag_Model_Tag_Relation
+ */
+ public function addRelations(Mage_Tag_Model_Tag $model, $productIds = array())
+ {
+ $this->setAddedProductIds($productIds);
+ $this->setTagId($model->getTagId());
+ $this->setCustomerId(null);
+ $this->setStoreId($model->getStoreId());
+ $this->_getResource()->addRelations($this);
+ return $this;
+ }
}
diff --git a/app/code/core/Mage/Tag/controllers/CustomerController.php b/app/code/core/Mage/Tag/controllers/CustomerController.php
index 5bbd01d3e9..ced84adf2d 100644
--- a/app/code/core/Mage/Tag/controllers/CustomerController.php
+++ b/app/code/core/Mage/Tag/controllers/CustomerController.php
@@ -94,25 +94,14 @@ public function viewAction()
}
}
+ /**
+ * @deprecated after 1.3.2.3
+ * This functionality was removed
+ *
+ */
public function editAction()
{
- if( !Mage::getSingleton('customer/session')->getCustomerId() ) {
- Mage::getSingleton('customer/session')->authenticate($this);
- return;
- }
-
- if ($tagId = $this->_getTagId()) {
- $this->loadLayout();
- $this->_initLayoutMessages('tag/session');
- $this->_initLayoutMessages('customer/session');
- if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) {
- $navigationBlock->setActive('tag/customer');
- }
- $this->renderLayout();
- }
- else {
- $this->_forward('noRoute');
- }
+ $this->_forward('noRoute');
}
public function removeAction()
@@ -131,7 +120,6 @@ public function removeAction()
$this->getResponse()->setRedirect(Mage::getUrl('*/*/', array(
self::PARAM_NAME_URL_ENCODED => Mage::helper('core')->urlEncode(Mage::getUrl('customer/account/'))
)));
- //$this->
return;
} catch (Exception $e) {
Mage::getSingleton('tag/session')->addError(Mage::helper('tag')->__('Unable to remove tag. Please, try again later.'));
@@ -142,97 +130,13 @@ public function removeAction()
}
}
+ /**
+ * @deprecated after 1.3.2.3
+ * This functionality was removed
+ *
+ */
public function saveAction()
{
- if( !Mage::getSingleton('customer/session')->getCustomerId() ) {
- Mage::getSingleton('customer/session')->authenticate($this);
- return;
- }
-
- $tagId = (int) $this->getRequest()->getParam('tagId');
- $customerId = Mage::getSingleton('customer/session')->getCustomerId();
- $tagName = (string) $this->getRequest()->getPost('productTagName');
-
- if (strlen($tagName) === 0) {
- Mage::getSingleton('tag/session')->addError(Mage::helper('tag')->__('Tag can\'t be empty.'));
- $this->_redirect('*/*/edit', array('tagId'=>$tagId));
- return;
- }
-
- if ($tagId) {
- try {
- $productId = 0;
- $message = false;
- $storeId = Mage::app()->getStore()->getId();
-
- $tagModel = Mage::getModel('tag/tag');
- $tagModel->load($tagId);
-
- /* @var $tagRelationModel Mage_Tag_Model_Tag_Relation */
- $tagRelationModel = Mage::getModel('tag/tag_relation');
- // rename isset tag
- if ($tagModel->getName() != $tagName) {
- // deactivate old tagged products
- $tagRelationModel->loadByTagCustomer(null, $tagModel->getId(), $customerId, $storeId)
- ->deactivate();
-
- $existingTagModel = Mage::getModel('tag/tag')->loadByName($tagName);
-
- if($existingTagModel->getId()) {
- $status = $existingTagModel->getStatus();
- }
- else {
- $message= Mage::helper('tag')->__('Thank you. Your tag has been accepted for moderation.');
- $status = $existingTagModel->getPendingStatus();
- }
-
- $tagModel->setName($tagName)
- ->setStatus($status)
- ->setStoreId($storeId)
- ->save();
- }
-
- $tagRelationModel->loadByTagCustomer(null, $tagId, $customerId, $storeId);
-
- if ($tagRelationModel->getCustomerId() == $customerId ) {
- $productIds = $tagRelationModel->getProductIds();
- if ($tagRelationModel->getTagId()!=$tagModel->getId()) {
- $tagRelationModel->deactivate();
- } else {
- $tagRelationModel->delete();
- }
-
- foreach ($productIds as $productId) {
- Mage::getModel('tag/tag_relation')
- ->setTagId($tagModel->getId())
- ->setCustomerId($customerId)
- ->setStoreId($storeId)
- ->setActive(true)
- ->setProductId($productId)
- ->setCreatedAt( $tagRelationModel->getResource()->formatDate(time()) )
- ->save();
- }
- }
-
- if ($tagModel->getId()) {
- $tagModel->aggregate();
- $this->getResponse()->setRedirect(Mage::getUrl('*/*/'));
- }
-
- $message = ($message) ? $message : Mage::helper('tag')->__('Your tag was successfully saved');
- Mage::getSingleton('tag/session')->addSuccess($message);
- $this->_redirect('*/*/');
- return;
- }
- catch (Mage_Core_Exception $e) {
- Mage::getSingleton('tag/session')->addError($e->getMessage());
- }
- catch (Exception $e) {
- Mage::getSingleton('tag/session')->addException($e,
- Mage::helper('tag')->__('Unable to save your tag. Please, try again later.')
- );
- }
- }
- $this->_redirectReferer();
+ $this->_forward('noRoute');
}
}
diff --git a/app/code/core/Mage/Tag/etc/config.xml b/app/code/core/Mage/Tag/etc/config.xml
index bd19783a4d..841aee1ac4 100644
--- a/app/code/core/Mage/Tag/etc/config.xml
+++ b/app/code/core/Mage/Tag/etc/config.xml
@@ -28,7 +28,7 @@
- 0.7.2
+ 0.7.3
@@ -64,20 +64,7 @@
Mage_Tag
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
Mage_Tag_Block
@@ -131,58 +118,6 @@
-
-
-
-
- Tags
-
-
- Pending Tags
- adminhtml/tag/pending
-
-
- All Tags
- adminhtml/tag/index
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Tags
-
-
- All Tags
-
-
- Pending Tags
-
-
-
-
-
-
-
-
-
@@ -192,5 +127,12 @@
+
+
+
+ tag.xml
+
+
+
diff --git a/app/code/core/Mage/Tax/Helper/Data.php b/app/code/core/Mage/Tax/Helper/Data.php
index 70d42e470a..9b09cecf54 100644
--- a/app/code/core/Mage/Tax/Helper/Data.php
+++ b/app/code/core/Mage/Tax/Helper/Data.php
@@ -47,11 +47,32 @@ class Mage_Tax_Helper_Data extends Mage_Core_Helper_Abstract
protected $_priceDisplayType;
protected $_shippingPriceDisplayType;
+ /**
+ * Postcode cut to this length when creating search templates
+ *
+ * @var integer
+ */
+ protected $_postCodeSubStringLength = 10;
+
public function __construct()
{
$this->_config = Mage::getSingleton('tax/config');
}
+ /**
+ * Return max postcode length to create search templates
+ *
+ * @return integer $len
+ */
+ public function getPostCodeSubStringLength()
+ {
+ $len = (int)$this->_postCodeSubStringLength;
+ if ($len <= 0) {
+ $len = 10;
+ }
+ return $len;
+ }
+
/**
* Get tax configuration object
*
@@ -438,24 +459,46 @@ public function getPrice($product, $price, $includingTax = null, $shippingAddres
return $store->roundPrice($price);
}
+ /**
+ * Check if we have display in catalog prices including tax
+ *
+ * @return bool
+ */
public function displayPriceIncludingTax()
{
return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX;
}
+ /**
+ * Check if we have display in catalog prices excluding tax
+ *
+ * @return bool
+ */
public function displayPriceExcludingTax()
{
return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX;
}
+ /**
+ * Check if we have display in catalog prices including and excluding tax
+ *
+ * @return bool
+ */
public function displayBothPrices()
{
return $this->getPriceDisplayType() == Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH;
}
+ /**
+ * Calculate price imcluding/excluding tax base on tax rate percent
+ *
+ * @param float $price
+ * @param float $percent
+ * @param bool $type true - for calculate price including tax and false if price excluding tax
+ * @return float
+ */
protected function _calculatePrice($price, $percent, $type)
{
- $store = Mage::app()->getStore();
if ($type) {
return $price * (1+($percent/100));
} else {
diff --git a/app/code/core/Mage/Tax/Model/Calculation/Rate.php b/app/code/core/Mage/Tax/Model/Calculation/Rate.php
index 6ff5d18c0e..d9c9d0189b 100644
--- a/app/code/core/Mage/Tax/Model/Calculation/Rate.php
+++ b/app/code/core/Mage/Tax/Model/Calculation/Rate.php
@@ -43,12 +43,25 @@ protected function _construct()
}
/**
- * Prepare location settings before save rate
+ * Prepare location settings and tax postcode before save rate
*
* @return Mage_Tax_Model_Calculation_Rate
*/
protected function _beforeSave()
{
+ $zipIsRange = null;
+ $zipFrom = null;
+ $zipTo = null;
+ if (preg_match('/(\d+)\s*-\s*(\d+)/m', $this->getTaxPostcode(), $matchArr)) {
+ list(, $zipFrom, $zipTo) = $matchArr;
+ $this->setTaxPostcode("{$zipFrom}-{$zipTo}");
+ $zipIsRange = 1;
+ }
+ $this
+ ->setZipFrom($zipFrom)
+ ->setZipTo($zipTo)
+ ->setZipIsRange($zipIsRange);
+
parent::_beforeSave();
$country = $this->getTaxCountryId();
$region = $this->getTaxRegionId();
@@ -129,8 +142,8 @@ public function deleteAllRates()
}
/**
- * Load rate model by code
- *
+ * Load rate model by code
+ *
* @param string $code
* @return Mage_Tax_Model_Calculation_Rate
*/
@@ -139,5 +152,5 @@ public function loadByCode($code)
$this->load($code, 'code');
return $this;
}
-
-}
\ No newline at end of file
+
+}
diff --git a/app/code/core/Mage/Tax/Model/Mysql4/Calculation.php b/app/code/core/Mage/Tax/Model/Mysql4/Calculation.php
index 17d562d3b5..5f30280be4 100644
--- a/app/code/core/Mage/Tax/Model/Mysql4/Calculation.php
+++ b/app/code/core/Mage/Tax/Model/Mysql4/Calculation.php
@@ -72,7 +72,8 @@ public function getCalculationProcess($request, $rates = null)
$ids = array();
$currentRate = 0;
$totalPercent = 0;
- for ($i=0; $igetPostCodeSubStringLength();
+ $strlen = strlen($postcode);
+ if ($strlen > $len) {
+ $postcode = substr($postcode, 0, $len);
+ $strlen = $len;
+ }
+
+ $strArr = array($postcode);
+ if ($strlen > 1) {
+ for ($i = 1; $i < $strlen; $i++) {
+ $strArr[] = sprintf('%s*', substr($postcode, 0, - $i));
+ }
+ }
+
+ return $strArr;
+
+ }
+
+ /**
+ * Load select and return tax rates
+ *
+ * @param Varien_Object $request
+ * @return array
+ */
protected function _getRates($request)
{
+
$storeId = Mage::app()->getStore($request->getStore())->getId();
$select = $this->_getReadAdapter()->select();
@@ -143,24 +178,40 @@ protected function _getRates($request)
$select->join(array('rule'=>$this->getTable('tax/tax_calculation_rule')), 'rule.tax_calculation_rule_id = main_table.tax_calculation_rule_id', array('rule.priority', 'rule.position'));
$select->join(array('rate'=>$this->getTable('tax/tax_calculation_rate')), 'rate.tax_calculation_rate_id = main_table.tax_calculation_rate_id', array('value'=>'rate.rate', 'rate.tax_country_id', 'rate.tax_region_id', 'rate.tax_postcode', 'rate.tax_calculation_rate_id', 'rate.code'));
+ $select->joinLeft(array('title_table'=>$this->getTable('tax/tax_calculation_rate_title')), "rate.tax_calculation_rate_id = title_table.tax_calculation_rate_id AND title_table.store_id = '{$storeId}'", array('title'=>'IFNULL(title_table.value, rate.code)'));
+
$select
->where("rate.tax_country_id = ?", $request->getCountryId())
- ->where("rate.tax_region_id in ('*', '', ?)", $request->getRegionId())
- ->where("rate.tax_postcode in ('*', '', ?)", $request->getPostcode());
-
- $select->joinLeft(array('title_table'=>$this->getTable('tax/tax_calculation_rate_title')), "rate.tax_calculation_rate_id = title_table.tax_calculation_rate_id AND title_table.store_id = '{$storeId}'", array('title'=>'IFNULL(title_table.value, rate.code)'));
+ ->where("rate.tax_region_id in ('*', '', ?)", $request->getRegionId());
$order = array('rule.priority ASC', 'rule.tax_calculation_rule_id ASC', 'rate.tax_country_id DESC', 'rate.tax_region_id DESC', 'rate.tax_postcode DESC', 'rate.rate DESC');
$select->order($order);
+ $selectClone = clone $select;
+
+ $select
+ ->where("rate.zip_is_range IS NULL")
+ ->where("rate.tax_postcode in ('*', '', ?)", $this->_createSearchPostCodeTemplates($request->getPostcode()));
+
+ $selectClone
+ ->where("rate.zip_is_range IS NOT NULL")
+ ->where("? BETWEEN rate.zip_from AND rate.zip_to", $request->getPostcode());
+
+ /**
+ * @see ZF-7592 issue http://framework.zend.com/issues/browse/ZF-7592
+ */
+ $select = $this->_getReadAdapter()->select()->union(array('(' . $select . ')', '(' . $selectClone . ')'));
+
return $this->_getReadAdapter()->fetchAll($select);
+
}
protected function _calculateRate($rates)
{
$result = 0;
$currentRate = 0;
- for ($i=0; $i_getRates($request);
- for ($i=0; $igetEvent()->getOrder();
- if (!$order->getConvertingFromQuote()) {
+ if (!$order->getConvertingFromQuote() || $order->getAppliedTaxIsSaved()) {
return;
}
@@ -92,6 +92,7 @@ public function salesEventOrderAfterSave(Varien_Event_Observer $observer)
Mage::getModel('sales/order_tax')->setData($data)->save();
}
}
+ $order->setAppliedTaxIsSaved(true);
}
/**
@@ -109,7 +110,7 @@ public function prepareCatalogIndexPriceSelect(Varien_Event_Observer $observer)
$additionalCalculations = $response->getAdditionalCalculations();
$calculation = Mage::helper('tax')->getPriceTaxSql(
- $table . '.value', 'IFNULL(tax_class_c.value, tax_class_d.value)'
+ $table . '.min_price', 'IFNULL(tax_class_c.value, tax_class_d.value)'
);
if (!empty($calculation)) {
diff --git a/app/code/core/Mage/Tax/etc/config.xml b/app/code/core/Mage/Tax/etc/config.xml
index 4c7d4106b1..948cec90c1 100644
--- a/app/code/core/Mage/Tax/etc/config.xml
+++ b/app/code/core/Mage/Tax/etc/config.xml
@@ -28,7 +28,7 @@
- 0.7.9
+ 0.7.10
@@ -64,20 +64,7 @@
Mage_Tax
Mage_Tax_Model_Mysql4_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -99,7 +86,6 @@
- singleton
tax/observer
salesEventConvertQuoteAddressToOrder
@@ -108,7 +94,6 @@
- singleton
tax/observer
salesEventOrderAfterSave
@@ -117,7 +102,6 @@
- singleton
tax/observer
prepareCatalogIndexPriceSelect
@@ -126,7 +110,6 @@
- singleton
tax/observer
addTaxPercentToProductCollection
@@ -189,88 +172,6 @@
-
-
-
-
- Tax
- 500
-
-
- Manage Tax Rules
- adminhtml/tax_rule
-
-
- Manage Tax Zones & Rates
- adminhtml/tax_rate
-
-
- Import / Export Tax Rates
- adminhtml/tax_rate/importExport
-
-
- Customer Tax Classes
- adminhtml/tax_class_customer
-
-
- Product Tax Classes
- adminhtml/tax_class_product
-
-
-
-
-
-
-
-
-
-
-
-
-
- Tax
- 500
-
-
- Customer Tax Classes
- 0
-
-
- Product Tax Classes
- 10
-
-
- Import / Export Tax Rates
- 20
-
-
- Manage Tax Zones & Rates
- 30
-
-
- Manage Tax Rules
- 40
-
-
-
-
-
-
-
-
-
-
- Tax Section
- 55
-
-
-
-
-
-
-
-
-
diff --git a/app/code/core/Mage/Usa/etc/config.xml b/app/code/core/Mage/Usa/etc/config.xml
index 3ee75f858f..b20f10d52d 100644
--- a/app/code/core/Mage/Usa/etc/config.xml
+++ b/app/code/core/Mage/Usa/etc/config.xml
@@ -28,7 +28,7 @@
- 0.7.0
+ 0.7.1
@@ -37,15 +37,7 @@
Mage_Usa
-
- directory_setup
-
-
-
- core_read
-
-
@@ -158,7 +150,7 @@
RES
GND
http://www.ups.com/using/services/rave/qcostcgi.cgi
- https://www.ups.com/ups.app/xml/Rate
+ https://onlinetools.ups.com/ups.app/xml/Rate
0
usa/shipping_carrier_ups
CC
diff --git a/app/code/core/Mage/Weee/Helper/Data.php b/app/code/core/Mage/Weee/Helper/Data.php
index 74004e6115..55250f0f82 100644
--- a/app/code/core/Mage/Weee/Helper/Data.php
+++ b/app/code/core/Mage/Weee/Helper/Data.php
@@ -34,86 +34,93 @@ class Mage_Weee_Helper_Data extends Mage_Core_Helper_Abstract
protected $_storeDisplayConfig = array();
+ /**
+ * Get weee amount display type on product view page
+ *
+ * @param mixed $store
+ * @return int
+ */
public function getPriceDisplayType($store = null)
{
- if (!is_null($store)) {
- if ($store instanceof Mage_Core_Model_Store) {
- $key = $store->getId();
- } else {
- $key = $store;
- }
- } else {
- $key = 'current';
- }
-
- if (!isset($this->_storeDisplayConfig[$key])) {
- $value = Mage::getStoreConfig('tax/weee/display', $store);
- $this->_storeDisplayConfig[$key] = $value;
- }
-
- return $this->_storeDisplayConfig[$key];
+ return Mage::getStoreConfig('tax/weee/display', $store);
}
+ /**
+ * Get weee amount display type on product list page
+ *
+ * @param mixed $store
+ * @return int
+ */
public function getListPriceDisplayType($store = null)
{
- if (!is_null($store)) {
- if ($store instanceof Mage_Core_Model_Store) {
- $key = $store->getId();
- } else {
- $key = $store;
- }
- } else {
- $key = 'current';
- }
-
- if (!isset($this->_storeDisplayConfig[$key])) {
- $value = Mage::getStoreConfig('tax/weee/display_list', $store);
- $this->_storeDisplayConfig[$key] = $value;
- }
-
- return $this->_storeDisplayConfig[$key];
+ return Mage::getStoreConfig('tax/weee/display_list', $store);
}
+ /**
+ * Get weee amount display type in sales modules
+ *
+ * @param mixed $store
+ * @return int
+ */
public function getSalesPriceDisplayType($store = null)
{
- if (!is_null($store)) {
- if ($store instanceof Mage_Core_Model_Store) {
- $key = $store->getId();
- } else {
- $key = $store;
- }
- } else {
- $key = 'current';
- }
-
- if (!isset($this->_storeDisplayConfig[$key])) {
- $value = Mage::getStoreConfig('tax/weee/display_sales', $store);
- $this->_storeDisplayConfig[$key] = $value;
- }
-
- return $this->_storeDisplayConfig[$key];
+ return Mage::getStoreConfig('tax/weee/display_sales', $store);
}
+ /**
+ * Get weee amount display type in email templates
+ *
+ * @param mixed $store
+ * @return int
+ */
public function getEmailPriceDisplayType($store = null)
{
- if (!is_null($store)) {
- if ($store instanceof Mage_Core_Model_Store) {
- $key = $store->getId();
- } else {
- $key = $store;
- }
- } else {
- $key = 'current';
- }
+ return Mage::getStoreConfig('tax/weee/display_email', $store);
+ }
- if (!isset($this->_storeDisplayConfig[$key])) {
- $value = Mage::getStoreConfig('tax/weee/display_email', $store);
- $this->_storeDisplayConfig[$key] = $value;
- }
+ /**
+ * Check if weee tax amount should be discounted
+ *
+ * @param mixed $store
+ * @return bool
+ */
+ public function isDiscounted($store = null)
+ {
+ return Mage::getStoreConfigFlag('tax/weee/discount', $store);
+ }
- return $this->_storeDisplayConfig[$key];
+ /**
+ * Check if weee tax amount should be taxable
+ *
+ * @param mixed $store
+ * @return bool
+ */
+ public function isTaxable($store = null)
+ {
+ return Mage::getStoreConfigFlag('tax/weee/apply_vat', $store);
}
+ /**
+ * Check if weee tax amount should be included to subtotal
+ *
+ * @param mixed $store
+ * @return bool
+ */
+ public function includeInSubtotal($store = null)
+ {
+ return Mage::getStoreConfigFlag('tax/weee/include_in_subtotal', $store);
+ }
+
+ /**
+ * Get weee tax amount for product based on shipping and billing addresses, website and tax settings
+ *
+ * @param Mage_Catalog_Model_Product $product
+ * @param null|Mage_Customer_Model_Address_Abstract $shipping
+ * @param null|Mage_Customer_Model_Address_Abstract $billing
+ * @param mixed $website
+ * @param bool $calculateTaxes
+ * @return float
+ */
public function getAmount($product, $shipping = null, $billing = null, $website = null, $calculateTaxes = false)
{
if ($this->isEnabled()) {
@@ -125,30 +132,29 @@ public function getAmount($product, $shipping = null, $billing = null, $website
public function typeOfDisplay($product, $compareTo = null, $zone = null, $store = null)
{
$type = 0;
+ if (!$this->isEnabled($store)) {
+ return false;
+ }
switch ($zone) {
case 'product_view':
- $type = $this->getPriceDisplayType($store);
- break;
-
+ $type = $this->getPriceDisplayType($store);
+ break;
case 'product_list':
- $type = $this->getListPriceDisplayType($store);
- break;
-
+ $type = $this->getListPriceDisplayType($store);
+ break;
case 'sales':
- $type = $this->getSalesPriceDisplayType($store);
- break;
-
+ $type = $this->getSalesPriceDisplayType($store);
+ break;
case 'email':
- $type = $this->getEmailPriceDisplayType($store);
- break;
-
+ $type = $this->getEmailPriceDisplayType($store);
+ break;
default:
- if (Mage::registry('current_product')) {
- $type = $this->getPriceDisplayType($store);
- } else {
- $type = $this->getListPriceDisplayType($store);
- }
- break;
+ if (Mage::registry('current_product')) {
+ $type = $this->getPriceDisplayType($store);
+ } else {
+ $type = $this->getListPriceDisplayType($store);
+ }
+ break;
}
if (is_null($compareTo)) {
@@ -199,21 +205,6 @@ public function setApplied($item, $value)
return $this;
}
- public function isDiscounted($store = null)
- {
- return Mage::getStoreConfigFlag('tax/weee/discount', $store);
- }
-
- public function isTaxable($store = null)
- {
- return Mage::getStoreConfigFlag('tax/weee/apply_vat', $store);
- }
-
- public function includeInSubtotal($store = null)
- {
- return Mage::getStoreConfigFlag('tax/weee/include_in_subtotal', $store);
- }
-
public function getProductWeeeAttributesForDisplay($product)
{
if ($this->isEnabled()) {
diff --git a/app/code/core/Mage/Weee/Model/Config/Source/Display.php b/app/code/core/Mage/Weee/Model/Config/Source/Display.php
index 09d27ec9bd..4268711729 100644
--- a/app/code/core/Mage/Weee/Model/Config/Source/Display.php
+++ b/app/code/core/Mage/Weee/Model/Config/Source/Display.php
@@ -28,12 +28,27 @@ class Mage_Weee_Model_Config_Source_Display
public function toOptionArray()
{
+ /**
+ * VAT is not applicable to FPT separately (we can't have FPT incl/excl VAT)
+ */
return array(
- array('value'=>0, 'label'=>Mage::helper('weee')->__('Including FPT only')),
- array('value'=>1, 'label'=>Mage::helper('weee')->__('Including FPT and FPT description [excl. FPT VAT]')),
- array('value'=>4, 'label'=>Mage::helper('weee')->__('Including FPT and FPT description [incl. FPT VAT]')),
- array('value'=>2, 'label'=>Mage::helper('weee')->__('Excluding FPT, FPT description, final price')),
- array('value'=>3, 'label'=>Mage::helper('weee')->__('Excluding FPT')),
+ array(
+ 'value' => 0,
+ 'label' => Mage::helper('weee')->__('Including FPT only')
+ ),
+ array(
+ 'value' => 1,
+ 'label' => Mage::helper('weee')->__('Including FPT and FPT description')
+ ),
+ //array('value'=>4, 'label'=>Mage::helper('weee')->__('Including FPT and FPT description [incl. FPT VAT]')),
+ array(
+ 'value' => 2,
+ 'label' => Mage::helper('weee')->__('Excluding FPT, FPT description, final price')
+ ),
+ array(
+ 'value' => 3,
+ 'label' => Mage::helper('weee')->__('Excluding FPT')
+ ),
);
}
diff --git a/app/code/core/Mage/Weee/Model/Mysql4/Tax.php b/app/code/core/Mage/Weee/Model/Mysql4/Tax.php
index 146425f793..814a4ed005 100644
--- a/app/code/core/Mage/Weee/Model/Mysql4/Tax.php
+++ b/app/code/core/Mage/Weee/Model/Mysql4/Tax.php
@@ -1,10 +1,30 @@
_init('weee/tax', 'value_id');
}
-
+
public function fetchOne($select)
{
return $this->_getReadAdapter()->fetchOne($select);
@@ -17,27 +37,68 @@ public function fetchCol($select)
public function updateDiscountPercents()
{
- $this->_getWriteAdapter()->delete($this->getTable('weee/discount'));
+ return $this->_updateDiscountPercents();
+ }
+
+ public function updateProductsDiscountPercent($condition)
+ {
+ return $this->_updateDiscountPercents($condition);
+ }
+
+ /**
+ * Update tax percents for WEEE based on products condition
+ *
+ * @param mixed $productCondition
+ * @return Mage_Weee_Model_Mysql4_Tax
+ */
+ protected function _updateDiscountPercents($productCondition = null)
+ {
$now = strtotime(now());
$select = $this->_getReadAdapter()->select();
- $select->from(array('data'=>$this->getTable('catalogrule/rule_product')))
- ->where('(from_time <= ? OR from_time = 0)', $now)
- ->where('(to_time >= ? OR to_time = 0)', $now)
- ->order(array('data.website_id', 'data.customer_group_id', 'data.product_id', 'data.sort_order'));
+ $select->from(array('data'=>$this->getTable('catalogrule/rule_product')));
+
+ $deleteCondition = '';
+ if ($productCondition) {
+ if ($productCondition instanceof Mage_Catalog_Model_Product) {
+ $select->where('product_id=?', $productCondition->getId());
+ $deleteCondition = $this->_getWriteAdapter()->quoteInto('entity_id=?', $productCondition->getId());
+ } elseif ($productCondition instanceof Mage_Catalog_Model_Product_Condition_Interface) {
+ $productCondition = $productCondition->getIdsSelect($this->_getWriteAdapter())->__toString();
+ $select->where('product_id IN ('.$productCondition.')');
+ $deleteCondition = 'entity_id IN ('.$productCondition.')';
+ } else {
+ $select->where('product_id=?', $productCondition);
+ $deleteCondition = $this->_getWriteAdapter()->quoteInto('entity_id=?', $productCondition);
+ }
+ } else {
+ $select->where('(from_time <= ? OR from_time = 0)', $now)
+ ->where('(to_time >= ? OR to_time = 0)', $now);
+ }
+ $this->_getWriteAdapter()->delete($this->getTable('weee/discount'), $deleteCondition);
+
+ $select->order(array('data.website_id', 'data.customer_group_id', 'data.product_id', 'data.sort_order'));
+
+ $data = $this->_getReadAdapter()->query($select);
- $data = $this->_getReadAdapter()->fetchAll($select);
$productData = array();
$stops = array();
- foreach ($data as $row) {
+ $prevKey = false;
+ while ($row = $data->fetch()) {
$key = "{$row['product_id']}-{$row['website_id']}-{$row['customer_group_id']}";
if (isset($stops[$key]) && $stops[$key]) {
continue;
}
+ if ($prevKey && ($prevKey != $key)) {
+ foreach ($productData as $product) {
+ $this->_getWriteAdapter()->insert($this->getTable('weee/discount'), $product);
+ }
+ $productData = array();
+ }
if ($row['action_operator'] == 'by_percent') {
if (isset($productData[$key])) {
- $productData[$key]['value'] += $productData[$key]['value']/100*$row['action_amount'];
+ $productData[$key]['value'] -= $productData[$key]['value']/100*$row['action_amount'];
} else {
$productData[$key] = array(
'entity_id' => $row['product_id'],
@@ -45,17 +106,18 @@ public function updateDiscountPercents()
'website_id' => $row['website_id'],
'value' => 100-max(0, min(100, $row['action_amount'])),
);
- }
+ }
}
if ($row['action_stop']) {
$stops[$key] = true;
}
+ $prevKey = $key;
}
-
foreach ($productData as $product) {
$this->_getWriteAdapter()->insert($this->getTable('weee/discount'), $product);
}
+ return $this;
}
public function getProductDiscountPercent($product, $website, $group)
diff --git a/app/code/core/Mage/Weee/Model/Observer.php b/app/code/core/Mage/Weee/Model/Observer.php
index 05147f0972..ce545e2f26 100644
--- a/app/code/core/Mage/Weee/Model/Observer.php
+++ b/app/code/core/Mage/Weee/Model/Observer.php
@@ -26,6 +26,11 @@
class Mage_Weee_Model_Observer extends Mage_Core_Model_Abstract
{
+ /**
+ * Assign custom renderer for product create/edit form weee attribute element
+ *
+ * @param Varien_Event_Observer $observer
+ */
public function setWeeeRendererInForm(Varien_Event_Observer $observer)
{
//adminhtml_catalog_product_edit_prepare_form
@@ -43,6 +48,11 @@ public function setWeeeRendererInForm(Varien_Event_Observer $observer)
}
}
+ /**
+ * Exclude WEEE attributes from standard form generation
+ *
+ * @param Varien_Event_Observer $observer
+ */
public function updateExcludedFieldList(Varien_Event_Observer $observer)
{
//adminhtml_catalog_product_form_prepare_excluded_field_list
@@ -56,6 +66,11 @@ public function updateExcludedFieldList(Varien_Event_Observer $observer)
$block->setFormExcludedFieldList($list);
}
+ /**
+ * Add additional price calculation to select object which is using for select indexed data
+ *
+ * @param Varien_Event_Observer $observer
+ */
public function prepareCatalogIndexSelect(Varien_Event_Observer $observer)
{
if (!Mage::helper('weee')->isEnabled($observer->getEvent()->getStoreId())) {
@@ -63,14 +78,14 @@ public function prepareCatalogIndexSelect(Varien_Event_Observer $observer)
}
switch(Mage::helper('weee')->getListPriceDisplayType()) {
- case 2:
- case 3:
+ case Mage_Weee_Model_Tax::DISPLAY_EXCL_DESCR_INCL:
+ case Mage_Weee_Model_Tax::DISPLAY_EXCL:
return $this;
}
$select = $observer->getEvent()->getSelect();
- $table = $observer->getEvent()->getTable();
- $storeId = $observer->getEvent()->getStoreId();
+ $table = $observer->getEvent()->getTable();
+ $storeId= $observer->getEvent()->getStoreId();
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
$customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
@@ -133,11 +148,21 @@ public function prepareCatalogIndexSelect(Varien_Event_Observer $observer)
}
}
+ /**
+ * Get empty select object
+ *
+ * @return Varien_Db_Select
+ */
protected function _getSelect()
{
return Mage::getSingleton('weee/tax')->getResource()->getReadConnection()->select();
}
+ /**
+ * Add new attribute type to manage attributes interface
+ *
+ * @param Varien_Event_Observer $observer
+ */
public function addWeeeTaxAttributeType(Varien_Event_Observer $observer)
{
// adminhtml_product_attribute_types
@@ -165,6 +190,11 @@ public function addWeeeTaxAttributeType(Varien_Event_Observer $observer)
$response->setTypes($types);
}
+ /**
+ * Automaticaly assign backend model to weee attributes
+ *
+ * @param Varien_Event_Observer $observer
+ */
public function assignBackendModelToAttribute(Varien_Event_Observer $observer)
{
$backendModel = 'weee/attribute_backend_weee_tax';
@@ -184,6 +214,11 @@ public function assignBackendModelToAttribute(Varien_Event_Observer $observer)
}
}
+ /**
+ * Add custom element type for attributes form
+ *
+ * @param Varien_Event_Observer $observer
+ */
public function updateElementTypes(Varien_Event_Observer $observer)
{
$response = $observer->getEvent()->getResponse();
@@ -193,12 +228,33 @@ public function updateElementTypes(Varien_Event_Observer $observer)
return $this;
}
+ /**
+ * Update WEEE amounts discount percents
+ *
+ * @param Varien_Event_Observer $observer
+ * @return Mage_Weee_Model_Observer
+ */
public function updateDiscountPercents(Varien_Event_Observer $observer)
{
- Mage::getModel('weee/tax')->updateDiscountPercents();
+ if (!Mage::helper('weee')->isEnabled()) {
+ return $this;
+ }
+
+ $eventProduct = $observer->getEvent()->getProduct();
+ $productCondition = $observer->getEvent()->getProductCondition();
+ if ($productCondition) {
+ $eventProduct = $productCondition;
+ }
+ Mage::getModel('weee/tax')->updateProductsDiscountPercent($eventProduct);
return $this;
}
+ /**
+ * Update configurable options of the product view page
+ *
+ * @param Varien_Event_Observer $observer
+ * @return Mage_Weee_Model_Observer
+ */
public function updateCofigurableProductOptions(Varien_Event_Observer $observer)
{
if (!Mage::helper('weee')->isEnabled()) {
@@ -226,6 +282,12 @@ public function updateCofigurableProductOptions(Varien_Event_Observer $observer)
return $this;
}
+ /**
+ * Process bundle options selection for prepare view json
+ *
+ * @param Varien_Event_Observer $observer
+ * @return Mage_Weee_Model_Observer
+ */
public function updateBundleProductOptions(Varien_Event_Observer $observer)
{
if (!Mage::helper('weee')->isEnabled()) {
diff --git a/app/code/core/Mage/Weee/Model/Tax.php b/app/code/core/Mage/Weee/Model/Tax.php
index f8c11f80b9..c0327fee8f 100644
--- a/app/code/core/Mage/Weee/Model/Tax.php
+++ b/app/code/core/Mage/Weee/Model/Tax.php
@@ -20,14 +20,35 @@
class Mage_Weee_Model_Tax extends Mage_Core_Model_Abstract
{
+ /**
+ * Including FPT only
+ */
+ const DISPLAY_INCL = 0;
+ /**
+ * Including FPT and FPT description
+ */
+ const DISPLAY_INCL_DESCR = 1;
+ /**
+ * Excluding FPT, FPT description, final price
+ */
+ const DISPLAY_EXCL_DESCR_INCL = 2;
+ /**
+ * Excluding FPT
+ */
+ const DISPLAY_EXCL = 3;
+
protected $_allAttributes = null;
protected $_productDiscounts = array();
+ /**
+ * Initialize resource
+ */
protected function _construct()
{
$this->_init('weee/tax', 'weee/tax');
}
+
public function getWeeeAmount($product, $shipping = null, $billing = null, $website = null, $calculateTax = false, $ignoreDiscount = false)
{
$amount = 0;
@@ -66,14 +87,20 @@ public function getProductWeeeAttributes($product, $shipping = null, $billing =
$websiteId = Mage::app()->getWebsite($website)->getId();
$store = Mage::app()->getWebsite($website)->getDefaultGroup()->getDefaultStore();
+ $customer = null;
if ($shipping) {
$customerTaxClass = $shipping->getQuote()->getCustomerTaxClassId();
+ $customer = $shipping->getQuote()->getCustomer();
} else {
$customerTaxClass = null;
}
- $rateRequest = Mage::getModel('tax/calculation')->getRateRequest($shipping, $billing, $customerTaxClass, $store);
- $defaultRateRequest = Mage::getModel('tax/calculation')->getRateRequest(false, false, false, $store);
+ $calculator = Mage::getModel('tax/calculation');
+ if ($customer) {
+ $calculator->setCustomer($customer);
+ }
+ $rateRequest = $calculator->getRateRequest($shipping, $billing, $customerTaxClass, $store);
+ $defaultRateRequest = $calculator->getRateRequest(false, false, false, $store);
$discountPercent = 0;
if (!$ignoreDiscount && Mage::helper('weee')->isDiscounted($store)) {
@@ -115,14 +142,16 @@ public function getProductWeeeAttributes($product, $shipping = null, $billing =
$taxAmount = $amount = 0;
$amount = $value;
-
- if ($calculateTax && Mage::helper('weee')->isTaxable($store)) {
- $defaultPercent = Mage::getModel('tax/calculation')->getRate($defaultRateRequest->setProductClassId($product->getTaxClassId()));
- $currentPercent = $product->getTaxPercent();
-
- $taxAmount = Mage::app()->getStore()->roundPrice($value/(100+$defaultPercent)*$currentPercent);
- $amount = $value - $taxAmount;
- }
+ /**
+ * We can't use FPT imcluding/excluding tax
+ */
+// if ($calculateTax && Mage::helper('weee')->isTaxable($store)) {
+// $defaultPercent = Mage::getModel('tax/calculation')->getRate($defaultRateRequest->setProductClassId($product->getTaxClassId()));
+// $currentPercent = $product->getTaxPercent();
+//
+// $taxAmount = Mage::app()->getStore()->roundPrice($value/(100+$defaultPercent)*$currentPercent);
+// $amount = $value - $taxAmount;
+// }
$one = new Varien_Object();
$one->setName(Mage::helper('catalog')->__($attribute->getFrontend()->getLabel()))
@@ -152,9 +181,26 @@ protected function _getDiscountPercentForProduct($product)
}
}
+ /**
+ * Update discounts for FPT amounts of all products
+ *
+ * @return Mage_Weee_Model_Tax
+ */
public function updateDiscountPercents()
{
$this->getResource()->updateDiscountPercents();
return $this;
}
+
+ /**
+ * Update discounts for FPT amounts base on products condiotion
+ *
+ * @param mixed $products
+ * @return Mage_Weee_Model_Tax
+ */
+ public function updateProductsDiscountPercent($products)
+ {
+ $this->getResource()->updateProductsDiscountPercent($products);
+ return $this;
+ }
}
diff --git a/app/code/core/Mage/Weee/Model/Total/Quote/Weee.php b/app/code/core/Mage/Weee/Model/Total/Quote/Weee.php
index 45506d1be4..98f9c34f04 100644
--- a/app/code/core/Mage/Weee/Model/Total/Quote/Weee.php
+++ b/app/code/core/Mage/Weee/Model/Total/Quote/Weee.php
@@ -25,61 +25,311 @@
*/
-class Mage_Weee_Model_Total_Quote_Weee extends Mage_Sales_Model_Quote_Address_Total_Tax
+class Mage_Weee_Model_Total_Quote_Weee extends Mage_Tax_Model_Sales_Total_Quote_Tax
{
- public function __construct(){
+ /**
+ * Weee module helper object
+ *
+ * @var Mage_Weee_Helper_Data
+ */
+ protected $_helper;
+ protected $_store;
+
+ /**
+ * Flag which notify what tax amount can be affected by fixed porduct tax
+ *
+ * @var bool
+ */
+ protected $_isTaxAffected;
+
+ /**
+ * Initialize Weee totals collector
+ */
+ public function __construct()
+ {
$this->setCode('weee');
+ $this->_helper = Mage::helper('weee');
}
+ /**
+ * Collect Weee taxes amount ant prepare items prices for taxation and discount
+ *
+ * @param Mage_Sales_Model_Quote_Address $address
+ * @return Mage_Weee_Model_Total_Quote_Weee
+ */
public function collect(Mage_Sales_Model_Quote_Address $address)
{
- $totalWeeeTax = 0;
- $baseTotalWeeeTax = 0;
-
+ Mage_Sales_Model_Quote_Address_Total_Abstract::collect($address);
+ $this->_isTaxAffected = false;
$items = $address->getAllItems();
if (!count($items)) {
return $this;
}
+ $address->setAppliedTaxesReset(true);
+ $address->setAppliedTaxes(array());
+
+ $this->_store = $address->getQuote()->getStore();
foreach ($items as $item) {
if ($item->getParentItemId()) {
continue;
}
-
$this->_resetItemData($item);
-
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
foreach ($item->getChildren() as $child) {
$this->_resetItemData($child);
- $this->_processItem($address, $child, true);
-
- $totalWeeeTax += $child->getWeeeTaxAppliedRowAmount();
- $baseTotalWeeeTax += $child->getBaseWeeeTaxAppliedRowAmount();
+ $this->_process($address, $child);
}
+ $this->_recalculateParent($item);
} else {
- $this->_processItem($address, $item);
-
- $totalWeeeTax += $item->getWeeeTaxAppliedRowAmount();
- $baseTotalWeeeTax += $item->getBaseWeeeTaxAppliedRowAmount();
+ $this->_process($address, $item);
}
}
- $address->setGrandTotal($address->getGrandTotal() + $totalWeeeTax);
- $address->setBaseGrandTotal($address->getBaseGrandTotal() + $baseTotalWeeeTax);
+ if ($this->_isTaxAffected) {
+ $address->unsSubtotalInclTax();
+ $address->unsBaseSubtotalInclTax();
+ }
+
+ return $this;
+ }
+
+ /**
+ * Calculate item fixed tax and prepare information for discount and recular taxation
+ *
+ * @param Mage_Sales_Model_Quote_Address $address
+ * @param Mage_Sales_Model_Quote_Item_Abstract $item
+ * @return Mage_Weee_Model_Total_Quote_Weee
+ */
+ protected function _process(Mage_Sales_Model_Quote_Address $address, $item)
+ {
+ if (!$this->_helper->isEnabled($this->_store)) {
+ return $this;
+ }
+
+ $attributes = $this->_helper->getProductWeeeAttributes(
+ $item->getProduct(),
+ $address,
+ $address->getQuote()->getBillingAddress(),
+ $this->_store->getWebsiteId()
+ );
+
+ $applied = array();
+ $productTaxes = array();
+
+ $totalValue = 0;
+ $baseTotalValue = 0;
+ $totalRowValue = 0;
+ $baseTotalRowValue = 0;
+
+ foreach ($attributes as $k=>$attribute) {
+ $baseValue = $attribute->getAmount();
+ $value = $this->_store->convertPrice($baseValue);
+ $rowValue = $value*$item->getTotalQty();
+ $baseRowValue = $baseValue*$item->getTotalQty();
+ $title = $attribute->getName();
+
+ $totalValue += $value;
+ $baseTotalValue += $baseValue;
+ $totalRowValue += $rowValue;
+ $baseTotalRowValue += $baseRowValue;
+
+ $productTaxes[] = array(
+ 'title' => $title,
+ 'base_amount' => $baseValue,
+ 'amount' => $value,
+ 'row_amount' => $rowValue,
+ 'base_row_amount'=> $baseRowValue,
+ /**
+ * Tax value can't be presented as include/exclude tax
+ */
+ 'base_amount_incl_tax' => $baseValue,
+ 'amount_incl_tax' => $value,
+ 'row_amount_incl_tax' => $rowValue,
+ 'base_row_amount_incl_tax' => $baseRowValue,
+ );
+
+ $applied[] = array(
+ 'id' => $attribute->getCode(),
+ 'percent' => null,
+ 'hidden' => $this->_helper->includeInSubtotal($this->_store),
+ 'rates' => array(array(
+ 'base_real_amount'=> $baseRowValue,
+ 'base_amount' => $baseRowValue,
+ 'amount' => $rowValue,
+ 'code' => $attribute->getCode(),
+ 'title' => $title,
+ 'percent' => null,
+ 'position' => 1,
+ 'priority' => -1000+$k,
+ ))
+ );
+ }
+
+ $item->setWeeeTaxAppliedAmount($totalValue)
+ ->setBaseWeeeTaxAppliedAmount($baseTotalValue)
+ ->setWeeeTaxAppliedRowAmount($totalRowValue)
+ ->setBaseWeeeTaxAppliedRowAmount($baseTotalRowValue);
+
+ $this->_processTaxSettings($item, $totalValue, $baseTotalValue, $totalRowValue, $baseTotalRowValue)
+ ->_processTotalAmount($address, $totalRowValue, $baseTotalRowValue)
+ ->_processDiscountSettings($item, $totalValue, $baseTotalValue);
+
+ $this->_helper->setApplied($item, array_merge($this->_helper->getApplied($item), $productTaxes));
+ if ($applied) {
+ $this->_saveAppliedTaxes($address, $applied,
+ $item->getWeeeTaxAppliedAmount(),
+ $item->getBaseWeeeTaxAppliedAmount(),
+ null
+ );
+ }
+
+ }
+
+ /**
+ * Check if discount should be applied to weee and add weee to discounted price
+ *
+ * @param Mage_Sales_Model_Quote_Item_Abstract $item
+ * @param float $value
+ * @param float $baseValue
+ * @return Mage_Weee_Model_Total_Quote_Weee
+ */
+ protected function _processDiscountSettings($item, $value, $baseValue)
+ {
+ if ($this->_helper->isDiscounted($this->_store)) {
+ Mage::helper('salesrule')->addItemDiscountPrices($item, $baseValue, $value);
+ }
+ return $this;
+ }
+
+ /**
+ * Add extra amount which should be taxable by regular tax
+ *
+ * @param Mage_Sales_Model_Quote_Item_Abstract $item
+ * @param float $value
+ * @param float $baseValue
+ * @param float $rowValue
+ * @param float $baseRowValue
+ * @return Mage_Weee_Model_Total_Quote_Weee
+ */
+ protected function _processTaxSettings($item, $value, $baseValue, $rowValue, $baseRowValue)
+ {
+ if ($this->_helper->isTaxable($this->_store) && $rowValue) {
+ $item->setExtraTaxableAmount($value)
+ ->setBaseExtraTaxableAmount($baseValue)
+ ->setExtraRowTaxableAmount($rowValue)
+ ->setBaseExtraRowTaxableAmount($baseRowValue)
+ ->unsRowTotalInclTax()
+ ->unsBaseRowTotalInclTax()
+ ->unsPriceInclTax()
+ ->unsBasePriceInclTax();
+ $this->_isTaxAffected = true;
+ }
return $this;
}
+ /**
+ * Proces row amount based on FPT total amount configuration setting
+ *
+ * @param Mage_Sales_Model_Quote_Address $address
+ * @param float $rowValue
+ * @param float $baseRowValue
+ * @return Mage_Weee_Model_Total_Quote_Weee
+ */
+ protected function _processTotalAmount($address, $rowValue, $baseRowValue)
+ {
+ if ($this->_helper->includeInSubtotal($this->_store)) {
+ $address->addTotalAmount('subtotal', $rowValue);
+ $address->addBaseTotalAmount('subtotal', $baseRowValue);
+ $this->_isTaxAffected = true;
+ } else {
+ $address->setExtraTaxAmount($address->getExtraTaxAmount() + $rowValue);
+ $address->setBaseExtraTaxAmount($address->getBaseExtraTaxAmount() + $baseRowValue);
+ }
+ return $this;
+ }
+
+ /**
+ * Recalculate parent item amounts based on children results
+ *
+ * @param Mage_Sales_Model_Quote_Item_Abstract $item
+ * @return Mage_Weee_Model_Total_Quote_Weee
+ */
+ protected function _recalculateParent(Mage_Sales_Model_Quote_Item_Abstract $item)
+ {
+
+ }
+
+ /**
+ * Reset information about FPT for shopping cart item
+ *
+ * @param Mage_Sales_Model_Quote_Item_Abstract $item
+ * @return Mage_Weee_Model_Total_Quote_Weee
+ */
+ protected function _resetItemData($item)
+ {
+ $this->_helper->setApplied($item, array());
+
+ $item->setBaseWeeeTaxDisposition(0);
+ $item->setWeeeTaxDisposition(0);
+
+ $item->setBaseWeeeTaxRowDisposition(0);
+ $item->setWeeeTaxRowDisposition(0);
+
+ $item->setBaseWeeeTaxAppliedAmount(0);
+ $item->setBaseWeeeTaxAppliedRowAmount(0);
+
+ $item->setWeeeTaxAppliedAmount(0);
+ $item->setWeeeTaxAppliedRowAmount(0);
+ }
+
+ /**
+ * Fetch FPT data to address object for display in totals block
+ *
+ * @param Mage_Sales_Model_Quote_Address $address
+ * @return Mage_Weee_Model_Total_Quote_Weee
+ */
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
+ {
+ return $this;
+ }
+
+ /**
+ * Process model configuration array.
+ * This method can be used for changing totals collect sort order
+ *
+ * @param array $config
+ * @param store $store
+ * @return array
+ */
+ public function processConfigArray($config, $store)
+ {
+ return $config;
+ }
+
+ /**
+ * Process item fixed taxes
+ *
+ * @deprecated since 1.3.2.3
+ * @param Mage_Sales_Model_Quote_Address $address
+ * @param Mage_Sales_Model_Quote_Item_Abstract $item
+ * @param bool $updateParent
+ * @return Mage_Weee_Model_Total_Quote_Weee
+ */
protected function _processItem(Mage_Sales_Model_Quote_Address $address, $item, $updateParent = false)
{
- $custTaxClassId = $address->getQuote()->getCustomerTaxClassId();
$store = $address->getQuote()->getStore();
+ if (!$this->_helper->isEnabled($store)) {
+ return $this;
+ }
+ $custTaxClassId = $address->getQuote()->getCustomerTaxClassId();
$taxCalculationModel = Mage::getSingleton('tax/calculation');
/* @var $taxCalculationModel Mage_Tax_Model_Calculation */
$request = $taxCalculationModel->getRateRequest($address, $address->getQuote()->getBillingAddress(), $custTaxClassId, $store);
$defaultRateRequest = $taxCalculationModel->getRateRequest(false, false, false, $store);
- $attributes = Mage::helper('weee')->getProductWeeeAttributes(
+ $attributes = $this->_helper->getProductWeeeAttributes(
$item->getProduct(),
$address,
$address->getQuote()->getBillingAddress(),
@@ -98,30 +348,29 @@ protected function _processItem(Mage_Sales_Model_Quote_Address $address, $item,
$title = $attribute->getName();
- if ($item->getDiscountPercent() && Mage::helper('weee')->isDiscounted($store)) {
+ /**
+ * Apply discount to fixed tax
+ */
+ if ($item->getDiscountPercent() && $this->_helper->isDiscounted($store)) {
$valueDiscount = $value/100*$item->getDiscountPercent();
$baseValueDiscount = $baseValue/100*$item->getDiscountPercent();
$rowValueDiscount = $rowValue/100*$item->getDiscountPercent();
$baseRowValueDiscount = $baseRowValue/100*$item->getDiscountPercent();
-
-// $value = $store->roundPrice($value-$valueDiscount);
-// $baseValue = $store->roundPrice($baseValue-$baseValueDiscount);
-// $rowValue = $store->roundPrice($rowValue-$rowValueDiscount);
-// $baseRowValue = $store->roundPrice($baseRowValue-$baseRowValueDiscount);
-
-
$address->setDiscountAmount($address->getDiscountAmount()+$rowValueDiscount);
$address->setBaseDiscountAmount($address->getBaseDiscountAmount()+$baseRowValueDiscount);
-
+
$address->setGrandTotal($address->getGrandTotal() - $rowValueDiscount);
$address->setBaseGrandTotal($address->getBaseGrandTotal() - $baseRowValueDiscount);
}
$oneDisposition = $baseOneDisposition = $disposition = $baseDisposition = 0;
- if (Mage::helper('weee')->isTaxable($store)) {
+ /**
+ * Apply tax percent to fixed tax
+ */
+ if ($this->_helper->isTaxable($store)) {
$currentPercent = $item->getTaxPercent();
$defaultPercent = $taxCalculationModel->getRate($defaultRateRequest->setProductClassId($item->getProduct()->getTaxClassId()));
@@ -134,13 +383,9 @@ protected function _processItem(Mage_Sales_Model_Quote_Address $address, $item,
$disposition = $store->roundPrice($rowValue/(100+$defaultPercent)*$currentPercent);
$baseDisposition = $store->roundPrice($baseRowValue/(100+$defaultPercent)*$currentPercent);
- //$totalWeeeTax += $disposition;
- //$baseTotalWeeeTax += $baseDisposition;
-
$item->setBaseTaxAmount($item->getBaseTaxAmount()+$baseDisposition);
$item->setTaxAmount($item->getTaxAmount()+$disposition);
-
$value -= $oneDisposition;
$baseValue -= $baseOneDisposition;
@@ -152,14 +397,14 @@ protected function _processItem(Mage_Sales_Model_Quote_Address $address, $item,
$item->setWeeeTaxRowDisposition($item->getWeeeTaxRowDisposition() + $disposition);
$item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxRowDisposition() + $baseDisposition);
- $item->setTaxBeforeDiscount($item->getTaxBeforeDiscount() + $disposition);
- $item->setBaseTaxBeforeDiscount($item->getBaseTaxBeforeDiscount() + $baseDisposition);
+// $item->setTaxBeforeDiscount($item->getTaxBeforeDiscount() + $disposition);
+// $item->setBaseTaxBeforeDiscount($item->getBaseTaxBeforeDiscount() + $baseDisposition);
$address->setTaxAmount($address->getTaxAmount() + $disposition);
$address->setBaseTaxAmount($address->getBaseTaxAmount() + $baseDisposition);
$rate = $taxCalculationModel->getRate($request->setProductClassId($item->getProduct()->getTaxClassId()));
-
+
$this->_saveAppliedTaxes(
$address,
$taxCalculationModel->getAppliedRates($request),
@@ -172,12 +417,15 @@ protected function _processItem(Mage_Sales_Model_Quote_Address $address, $item,
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $store->roundPrice($baseValueBeforeVAT-$baseRowValue));
}
- if (Mage::helper('weee')->includeInSubtotal($store)) {
+ /**
+ * Check if need include fixed tax amount to subtotal
+ */
+ if ($this->_helper->includeInSubtotal($store)) {
$address->setSubtotal($address->getSubtotal() + $rowValue);
$address->setBaseSubtotal($address->getBaseSubtotal() + $baseRowValue);
- $address->setSubtotalWithDiscount($address->getSubtotalWithDiscount() + $rowValue);
- $address->setBaseSubtotalWithDiscount($address->getBaseSubtotalWithDiscount() + $baseRowValue);
+// $address->setSubtotalWithDiscount($address->getSubtotalWithDiscount() + $rowValue);
+// $address->setBaseSubtotalWithDiscount($address->getBaseSubtotalWithDiscount() + $baseRowValue);
} else {
$address->setTaxAmount($address->getTaxAmount() + $rowValue);
$address->setBaseTaxAmount($address->getBaseTaxAmount() + $baseRowValue);
@@ -202,7 +450,7 @@ protected function _processItem(Mage_Sales_Model_Quote_Address $address, $item,
$applied[] = array(
'id'=>$attribute->getCode(),
'percent'=>null,
- 'hidden'=>Mage::helper('weee')->includeInSubtotal($store),
+ 'hidden'=>$this->_helper->includeInSubtotal($store),
'rates' => array(array(
'amount'=>$rowValue,
'base_amount'=>$baseRowValue,
@@ -222,7 +470,7 @@ protected function _processItem(Mage_Sales_Model_Quote_Address $address, $item,
$item->setWeeeTaxAppliedRowAmount($item->getWeeeTaxAppliedRowAmount() + $rowValue);
}
- Mage::helper('weee')->setApplied($item, array_merge(Mage::helper('weee')->getApplied($item), $productTaxes));
+ $this->_helper->setApplied($item, array_merge($this->_helper->getApplied($item), $productTaxes));
if ($updateParent) {
$parent = $item->getParentItem();
@@ -250,26 +498,4 @@ protected function _processItem(Mage_Sales_Model_Quote_Address $address, $item,
);
}
}
-
- protected function _resetItemData($item)
- {
- Mage::helper('weee')->setApplied($item, array());
-
- $item->setBaseWeeeTaxDisposition(0);
- $item->setWeeeTaxDisposition(0);
-
- $item->setBaseWeeeTaxRowDisposition(0);
- $item->setWeeeTaxRowDisposition(0);
-
- $item->setBaseWeeeTaxAppliedAmount(0);
- $item->setBaseWeeeTaxAppliedRowAmount(0);
-
- $item->setWeeeTaxAppliedAmount(0);
- $item->setWeeeTaxAppliedRowAmount(0);
- }
-
- public function fetch(Mage_Sales_Model_Quote_Address $address)
- {
- return $this;
- }
}
\ No newline at end of file
diff --git a/app/code/core/Mage/Weee/etc/config.xml b/app/code/core/Mage/Weee/etc/config.xml
index 6003479da8..f33a4ba8b1 100644
--- a/app/code/core/Mage/Weee/etc/config.xml
+++ b/app/code/core/Mage/Weee/etc/config.xml
@@ -31,58 +31,35 @@
0.13
-
Mage_Weee_Model
weee_mysql4
-
Mage_Weee_Model_Mysql4
-
-
-
-
-
-
+
+
-
Mage_Weee
Mage_Weee_Model_Mysql4_Setup
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
-
Mage_Weee_Block
-
- singleton
weee/observer
setWeeeRendererInForm
@@ -91,7 +68,6 @@
- singleton
weee/observer
updateExcludedFieldList
@@ -129,7 +105,6 @@
- singleton
weee/observer
updateElementTypes
@@ -139,7 +114,6 @@
- singleton
weee/observer
updateDiscountPercents
@@ -149,7 +123,6 @@
- singleton
weee/observer
updateCofigurableProductOptions
@@ -158,7 +131,6 @@
- singleton
weee/observer
updateBundleProductOptions
@@ -241,8 +213,8 @@
weee/total_quote_weee
- subtotal,shipping,tax
- grand_total
+ subtotal,tax_subtotal
+ tax,discount
@@ -291,9 +263,7 @@
-
- weee.xml
-
+ weee.xml
diff --git a/app/code/core/Mage/Weee/etc/system.xml b/app/code/core/Mage/Weee/etc/system.xml
index f9f9f6f6f8..b5afd54822 100644
--- a/app/code/core/Mage/Weee/etc/system.xml
+++ b/app/code/core/Mage/Weee/etc/system.xml
@@ -82,7 +82,7 @@
0
- Apply Percent Discounts To FPT
+ Apply Discounts To FPT
select
adminhtml/system_config_source_yesno
50
diff --git a/app/code/core/Mage/Wishlist/Helper/Data.php b/app/code/core/Mage/Wishlist/Helper/Data.php
index 298815c940..3c9c5d7eab 100644
--- a/app/code/core/Mage/Wishlist/Helper/Data.php
+++ b/app/code/core/Mage/Wishlist/Helper/Data.php
@@ -172,9 +172,21 @@ public function getRemoveUrl($item)
* Retrieve url for adding product to wishlist
*
* @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $product
- * @return string
+ * @return string|boolean
*/
public function getAddUrl($item)
+ {
+ return $this->getAddUrlWithParams($item);
+ }
+
+ /**
+ * Retrieve url for adding product to wishlist with params
+ *
+ * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $product
+ * @param array $param
+ * @return string|boolean
+ */
+ public function getAddUrlWithParams($item, array $params = array())
{
$productId = null;
if ($item instanceof Mage_Catalog_Model_Product) {
@@ -185,9 +197,8 @@ public function getAddUrl($item)
}
if ($productId) {
- return $this->_getUrlStore($item)->getUrl('wishlist/index/add', array(
- 'product' => $productId
- ));
+ $params['product'] = $productId;
+ return $this->_getUrlStore($item)->getUrl('wishlist/index/add', $params);
}
return false;
diff --git a/app/code/core/Mage/Wishlist/Model/Mysql4/Product/Collection.php b/app/code/core/Mage/Wishlist/Model/Mysql4/Product/Collection.php
index bb6bbdfc40..c046d6f413 100644
--- a/app/code/core/Mage/Wishlist/Model/Mysql4/Product/Collection.php
+++ b/app/code/core/Mage/Wishlist/Model/Mysql4/Product/Collection.php
@@ -35,6 +35,35 @@
class Mage_Wishlist_Model_Mysql4_Product_Collection
extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
{
+
+ /**
+ * Add days in whishlist filter of product collection
+ *
+ * @var boolean
+ */
+ protected $_addDaysInWishlist = false;
+
+ /**
+ * Get add days in whishlist filter of product collection flag
+ *
+ * @return boolean
+ */
+ public function getDaysInWishlist()
+ {
+ return $this->_addDaysInWishlist;
+ }
+
+ /**
+ * Set add days in whishlist filter of product collection flag
+ *
+ * @return Mage_Wishlist_Model_Mysql4_Product_Collection
+ */
+ public function setDaysInWishlist($flag)
+ {
+ $this->_addDaysInWishlist = (bool) $flag;
+ return $this;
+ }
+
/**
* Add wishlist filter to collection
*
@@ -80,6 +109,17 @@ public function addWishListSortOrder($attribute = 'added_at', $dir = 'desc')
return $this;
}
+ /**
+ * Reset sort order
+ *
+ * @return Mage_Wishlist_Model_Mysql4_Product_Collection
+ */
+ public function resetSortOrder()
+ {
+ $this->getSelect()->reset(Zend_Db_Select::ORDER);
+ return $this;
+ }
+
/**
* Add store data (days in wishlist)
*
@@ -87,15 +127,18 @@ public function addWishListSortOrder($attribute = 'added_at', $dir = 'desc')
*/
public function addStoreData()
{
- if (!isset($this->_joinFields['e_id'])) {
+ if (!$this->getDaysInWishlist()) {
return $this;
}
- $dayTable = $this->_getAttributeTableAlias('days_in_wishlist');
- $this->joinField('store_name', 'core/store', 'name', 'store_id=store_id');
+ $this->setDaysInWishlist(false);
+
+ $dayTable = 't_wi'; //$this->_getAttributeTableAlias('days_in_wishlist');
+
+ $this->joinField('store_name', 'core/store', 'name', 'store_id=item_store_id');
$this->joinField('days_in_wishlist',
'wishlist/item',
- "(TO_DAYS('" . Mage::getSingleton('core/date')->date() . "') - TO_DAYS(DATE_ADD(".$dayTable.".added_at, INTERVAL " .(int) Mage::getSingleton('core/date')->getGmtOffset() . " SECOND)))",
+ "(TO_DAYS('" . (substr(Mage::getSingleton('core/date')->date(), 0, -2) . '00') . "') - TO_DAYS(DATE_ADD(".$dayTable.".added_at, INTERVAL " .(int) Mage::getSingleton('core/date')->getGmtOffset() . " SECOND)))",
'wishlist_item_id=wishlist_item_id'
);
diff --git a/app/code/core/Mage/Wishlist/Model/Mysql4/Wishlist/Collection.php b/app/code/core/Mage/Wishlist/Model/Mysql4/Wishlist/Collection.php
index ba8495155c..047a41a117 100644
--- a/app/code/core/Mage/Wishlist/Model/Mysql4/Wishlist/Collection.php
+++ b/app/code/core/Mage/Wishlist/Model/Mysql4/Wishlist/Collection.php
@@ -32,12 +32,13 @@
* @package Mage_Wishlist
* @author Magento Core Team
*/
-class Mage_Wishlist_Model_Mysql4_Wishlist_Collection extends Mage_Core_Model_Abstract
+class Mage_Wishlist_Model_Mysql4_Wishlist_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
-
+ /**
+ * Initialize resource
+ */
protected function _construct()
{
$this->_init('wishlist/wishlist');
}
-
}
diff --git a/app/code/core/Mage/Wishlist/Model/Observer.php b/app/code/core/Mage/Wishlist/Model/Observer.php
index 11e7fb478d..b47808adab 100644
--- a/app/code/core/Mage/Wishlist/Model/Observer.php
+++ b/app/code/core/Mage/Wishlist/Model/Observer.php
@@ -80,6 +80,7 @@ public function processCartUpdateBefore($observer)
$wishlist->addNewItem($productId);
}
$wishlist->save();
+ Mage::helper('wishlist')->calculate();
}
return $this;
}
diff --git a/app/code/core/Mage/Wishlist/controllers/IndexController.php b/app/code/core/Mage/Wishlist/controllers/IndexController.php
index a46ccfb150..6ebc181d69 100644
--- a/app/code/core/Mage/Wishlist/controllers/IndexController.php
+++ b/app/code/core/Mage/Wishlist/controllers/IndexController.php
@@ -89,6 +89,16 @@ public function indexAction()
if ($block = $this->getLayout()->getBlock('customer.wishlist')) {
$block->setRefererUrl($this->_getRefererUrl());
}
+
+ $session = Mage::getSingleton('customer/session');
+
+ /**
+ * Get referer to avoid referring to the compare popup window
+ */
+ if ($block && $referer = $session->getAddActionReferer(true)) {
+ $block->setRefererUrl($referer);
+ }
+
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('checkout/session');
$this->renderLayout();
@@ -130,6 +140,11 @@ public function addAction()
$referer = $this->_getRefererUrl();
}
+ /**
+ * Set referer to avoid referring to the compare popup window
+ */
+ $session->setAddActionReferer($referer);
+
Mage::helper('wishlist')->calculate();
$message = $this->__('%1$s was successfully added to your wishlist. Click here to continue shopping', $product->getName(), $referer);
@@ -172,6 +187,11 @@ public function updateAction()
);
}
}
+
+ if (isset($post['save_and_share'])) {
+ $this->_redirect('*/*/share');
+ return;
+ }
}
$this->_redirect('*');
}
diff --git a/app/code/core/Mage/Wishlist/etc/config.xml b/app/code/core/Mage/Wishlist/etc/config.xml
index 316d9c74fe..ffa0ee9f28 100644
--- a/app/code/core/Mage/Wishlist/etc/config.xml
+++ b/app/code/core/Mage/Wishlist/etc/config.xml
@@ -59,20 +59,7 @@
Mage_Wishlist
-
- core_setup
-
-
-
- core_write
-
-
-
-
- core_read
-
-
@@ -87,7 +74,6 @@
- singleton
wishlist/observer
processCartUpdateBefore
@@ -96,7 +82,6 @@
- singleton
wishlist/observer
processAddToCart
@@ -134,7 +119,6 @@
- singleton
wishlist/observer
customerLogin
@@ -143,7 +127,6 @@
- singleton
wishlist/observer
customerLogout
@@ -152,25 +135,6 @@
-
-
-
-
-
-
-
-
-
- Wishlist Section
-
-
-
-
-
-
-
-
-
diff --git a/app/design/adminhtml/default/default/layout/catalog.xml b/app/design/adminhtml/default/default/layout/catalog.xml
index f07de83348..db703154fb 100644
--- a/app/design/adminhtml/default/default/layout/catalog.xml
+++ b/app/design/adminhtml/default/default/layout/catalog.xml
@@ -62,6 +62,71 @@
+
+
+
+
+
+
+ catalog.product.edit.tab.related
+ getSelectedRelatedProducts
+ links[related]
+ products_related
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ catalog.product.edit.tab.upsell
+ getSelectedUpsellProducts
+ links[upsell]
+ products_upsell
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ catalog.product.edit.tab.crosssell
+ getSelectedCrossSellProducts
+ links[crosssell]
+ products_crosssell
+
+
+
+
+
+
+
+
+
+
+
@@ -71,13 +136,33 @@ Layout handle for simple products
-
super adminhtml/catalog_product_edit_tab_super_group
-
+
+
+
+
+
+
+
+ catalog.product.edit.tab.super.group
+ getSelectedGroupedProducts
+ links[grouped]
+ products_grouped
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/design/adminhtml/default/default/layout/customer.xml b/app/design/adminhtml/default/default/layout/customer.xml
index c6dc6844c1..0e80a1f000 100644
--- a/app/design/adminhtml/default/default/layout/customer.xml
+++ b/app/design/adminhtml/default/default/layout/customer.xml
@@ -31,6 +31,9 @@
+
+
+
diff --git a/app/design/adminhtml/default/default/layout/googleoptimizer.xml b/app/design/adminhtml/default/default/layout/googleoptimizer.xml
index b917096fc9..abf070185c 100644
--- a/app/design/adminhtml/default/default/layout/googleoptimizer.xml
+++ b/app/design/adminhtml/default/default/layout/googleoptimizer.xml
@@ -29,7 +29,7 @@
@@ -52,4 +52,31 @@ Layout handle for budle products
+
+
+
+
+
+
+ cms_page_edit_tabs
+ addTab
+
+ googleoptimizer_section
+ googleoptimizer/adminhtml_cms_page_edit_tab_googleoptimizer
+
+
+
+ js
+ googleoptimizer_js
+ googleoptimizer/js
+
+ googleoptimizer/js.phtml
+
+
+
+
+
+
diff --git a/app/design/adminhtml/default/default/layout/main.xml b/app/design/adminhtml/default/default/layout/main.xml
index c41de21af4..48d553ca12 100644
--- a/app/design/adminhtml/default/default/layout/main.xml
+++ b/app/design/adminhtml/default/default/layout/main.xml
@@ -94,13 +94,18 @@ Default layout, loads most of the pages
js mage/adminhtml/rules.js can_load_rules_js
+ js mage/adminhtml/wysiwyg/tiny_mce/setup.js can_load_tiny_mce
+
-
+
+
+
+
diff --git a/app/design/adminhtml/default/default/layout/sales.xml b/app/design/adminhtml/default/default/layout/sales.xml
index 82fe1921ec..a472352e6d 100644
--- a/app/design/adminhtml/default/default/layout/sales.xml
+++ b/app/design/adminhtml/default/default/layout/sales.xml
@@ -426,6 +426,7 @@
mage/adminhtml/sales.js
mage/adminhtml/giftmessage.js
+
@@ -480,7 +481,7 @@
-
+
diff --git a/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml b/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml
index 670e6ecb64..ac7c7b8e12 100644
--- a/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml
+++ b/app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml
@@ -161,7 +161,7 @@
for( i in rootNode.childNodes ) {
if(rootNode.childNodes[i].id) {
var group = rootNode.childNodes[i];
- editSet.req.groups[gIterator] = new Array(group.id, group.attributes.text, (gIterator+1));
+ editSet.req.groups[gIterator] = new Array(group.id, group.attributes.text.strip(), (gIterator+1));
var iterator = 0
for( j in group.childNodes ) {
iterator ++;
@@ -284,7 +284,7 @@
addGroup : function() {
var group_name = prompt("__('Please enter a new group name') ?>","");
-
+ group_name = group_name.strip();
if( group_name == '' ) {
this.addGroup();
} else if( group_name != false && group_name != null && group_name != '' ) {
@@ -300,6 +300,9 @@
allowDrag : true
});
TreePanels.root.appendChild(newNode);
+ newNode.addListener('beforemove', editSet.groupBeforeMove);
+ newNode.addListener('beforeinsert', editSet.groupBeforeInsert);
+ newNode.addListener('beforeappend', editSet.groupBeforeInsert);
newNode.addListener('click', editSet.register);
}
},
@@ -316,6 +319,10 @@
},
validateGroupName : function(name, exceptNodeId) {
+ name = name.strip();
+ if (name === '') {
+ return false;
+ }
for (var i=0; i < TreePanels.root.childNodes.length; i++) {
if (TreePanels.root.childNodes[i].text.toLowerCase() == name.toLowerCase() && TreePanels.root.childNodes[i].id != exceptNodeId) {
errorText = "__('Attribute group with the \"/name/\" name already exists') ?>";
diff --git a/app/design/adminhtml/default/default/template/catalog/product/edit.phtml b/app/design/adminhtml/default/default/template/catalog/product/edit.phtml
index 96d2b7dcdf..915b511112 100644
--- a/app/design/adminhtml/default/default/template/catalog/product/edit.phtml
+++ b/app/design/adminhtml/default/default/template/catalog/product/edit.phtml
@@ -112,93 +112,6 @@
return 1;
}
-getProductSetId() && $this->getIsConfigured()): ?>
- var productLinksController = Class.create();
-
- productLinksController.prototype = {
- initialize : function(fieldId, products, grid) {
- this.saveField = $(fieldId);
- this.saveFieldId = fieldId;
- this.products = $H(products);
- this.grid = grid;
- this.tabIndex = 1000;
- this.grid.rowClickCallback = this.rowClick.bind(this);
- this.grid.initRowCallback = this.rowInit.bind(this);
- this.grid.checkboxCheckCallback = this.registerProduct.bind(this);
- this.grid.rows.each(this.eachRow.bind(this));
- this.saveField.value = this.serializeObject(this.products);
- this.grid.reloadParams = {'products[]':this.products.keys()};
- },
- eachRow : function(row) {
- this.rowInit(this.grid, row);
- },
- registerProduct : function(grid, element, checked) {
- if(checked){
- if(element.inputElements) {
- this.products.set(element.value, {});
- for(var i = 0; i < element.inputElements.length; i++) {
- element.inputElements[i].disabled = false;
- this.products.get(element.value)[element.inputElements[i].name] = element.inputElements[i].value;
- }
- }
- }
- else{
- if(element.inputElements){
- for(var i = 0; i < element.inputElements.length; i++) {
- element.inputElements[i].disabled = true;
- }
- }
-
- this.products.unset(element.value);
- }
- this.saveField.value = this.serializeObject(this.products);
- this.grid.reloadParams = {'products[]':this.products.keys()};
- },
- serializeObject : function(hash) {
- var clone = hash.clone();
- clone.each(function(pair) {
- clone.set(pair.key, encode_base64(Object.toQueryString(pair.value)));
- });
- return clone.toQueryString();
- },
- rowClick : function(grid, event) {
- var trElement = Event.findElement(event, 'tr');
- var isInput = Event.element(event).tagName == 'INPUT';
- if(trElement){
- var checkbox = Element.select(trElement, 'input');
- if(checkbox[0]){
- var checked = isInput ? checkbox[0].checked : !checkbox[0].checked;
- this.grid.setCheckboxChecked(checkbox[0], checked);
- }
- }
- },
- inputChange : function(event) {
- var element = Event.element(event);
- if(element && element.checkboxElement && element.checkboxElement.checked){
- this.products.get(element.checkboxElement.value)[element.name] = element.value;
- this.saveField.value = this.serializeObject(this.products);
- }
- },
- rowInit : function(grid, row) {
- var checkbox = $(row).select('.checkbox')[0];
- var inputs = $(row).select('.input-text');
- if(checkbox && inputs.length > 0) {
- checkbox.inputElements = inputs;
- for(var i = 0; i < inputs.length; i++) {
- inputs[i].checkboxElement = checkbox;
- if(this.products.get(checkbox.value) && this.products.get(checkbox.value)[inputs[i].name]) {
- inputs[i].value = this.products.get(checkbox.value)[inputs[i].name];
- }
- inputs[i].disabled = !checkbox.checked;
- inputs[i].tabIndex = this.tabIndex++;
- Event.observe(inputs[i],'keyup', this.inputChange.bind(this));
- Event.observe(inputs[i],'change', this.inputChange.bind(this));
- }
- }
- }
- };
-
-
Event.observe(window, 'load', function() {
var objName = 'getSelectedTabId() ?>';
if (objName) {
diff --git a/app/design/adminhtml/default/default/template/catalog/product/edit/action/websites.phtml b/app/design/adminhtml/default/default/template/catalog/product/edit/action/websites.phtml
index cb1b2ff0c2..1e0d39f17b 100644
--- a/app/design/adminhtml/default/default/template/catalog/product/edit/action/websites.phtml
+++ b/app/design/adminhtml/default/default/template/catalog/product/edit/action/websites.phtml
@@ -32,7 +32,7 @@
getWebsiteCollection() as $_website): ?>
-
+ getWebsitesReadonly()): ?>disabled="disabled" class="checkbox website-checkbox" id="add_product_website_getId() ?>" type="checkbox" />
getName() ?>
@@ -70,7 +70,7 @@
getWebsiteCollection() as $_website): ?>
-
+ getWebsitesReadonly()): ?>disabled="disabled" class="checkbox website-checkbox" id="remove_product_website_getId() ?>" type="checkbox"/>
getName() ?>
diff --git a/app/design/adminhtml/default/default/template/catalog/product/edit/price/tier.phtml b/app/design/adminhtml/default/default/template/catalog/product/edit/price/tier.phtml
index 9d9323aed2..56f36bc534 100644
--- a/app/design/adminhtml/default/default/template/catalog/product/edit/price/tier.phtml
+++ b/app/design/adminhtml/default/default/template/catalog/product/edit/price/tier.phtml
@@ -23,17 +23,23 @@
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
+/* @var $this Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier */
?>
getElement()->getHtmlId() ?>
getElement()->getClass() ?>
getElement()->getName() ?>
getElement()->getReadonly() ?>
-isMultiWebsites(); ?>
+isShowWebsiteColumn(); ?>
+isAllowChangeWebsite(); ?>
+
+
+isShowWebsiteColumn(); ?>
+isMultiWebsites(); ?>
getElement()->getLabel() ?>
-
-
+
diff --git a/app/design/adminhtml/default/default/template/catalog/product/edit/serializer.phtml b/app/design/adminhtml/default/default/template/catalog/product/edit/serializer.phtml
index ea96d0820c..7768569035 100644
--- a/app/design/adminhtml/default/default/template/catalog/product/edit/serializer.phtml
+++ b/app/design/adminhtml/default/default/template/catalog/product/edit/serializer.phtml
@@ -1,3 +1,30 @@
+
+
+getCanLoadTinyMce()): // TinyMCE is broken when loaded through index.php ?>
+
+
+
helper('core/js')->getTranslatorScript() ?>
-getChildHtml('calendar');
\ No newline at end of file
+getChildHtml('calendar'); ?>
+getChildHtml('optional_zip_countries'); ?>
\ No newline at end of file
diff --git a/app/design/adminhtml/default/default/template/payment/info/pdf/cc.phtml b/app/design/adminhtml/default/default/template/payment/info/pdf/cc.phtml
index d6a41cf005..dedb7b548d 100644
--- a/app/design/adminhtml/default/default/template/payment/info/pdf/cc.phtml
+++ b/app/design/adminhtml/default/default/template/payment/info/pdf/cc.phtml
@@ -28,6 +28,4 @@
{{pdf_row_separator}}
__('Credit Card Type: %s', $this->htmlEscape($this->getCcTypeName())) ?>
{{pdf_row_separator}}
-__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?>
- {{pdf_row_separator}}
-__('Expiration Date: %s/%s', $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>
+__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?>
\ No newline at end of file
diff --git a/app/design/adminhtml/default/default/template/payment/info/pdf/ccsave.phtml b/app/design/adminhtml/default/default/template/payment/info/pdf/ccsave.phtml
index d6c761a528..dedb7b548d 100644
--- a/app/design/adminhtml/default/default/template/payment/info/pdf/ccsave.phtml
+++ b/app/design/adminhtml/default/default/template/payment/info/pdf/ccsave.phtml
@@ -28,6 +28,4 @@
{{pdf_row_separator}}
__('Credit Card Type: %s', $this->htmlEscape($this->getCcTypeName())) ?>
{{pdf_row_separator}}
-__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?>
- {{pdf_row_separator}}
-__('Expiration Date: %s/%s', $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>
\ No newline at end of file
+__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?>
\ No newline at end of file
diff --git a/app/design/adminhtml/default/default/template/paypaluk/direct/pdf/info.phtml b/app/design/adminhtml/default/default/template/paypaluk/direct/pdf/info.phtml
index 0bd5c8b780..38041d6808 100644
--- a/app/design/adminhtml/default/default/template/paypaluk/direct/pdf/info.phtml
+++ b/app/design/adminhtml/default/default/template/paypaluk/direct/pdf/info.phtml
@@ -31,8 +31,6 @@
{{pdf_row_separator}}
__('Credit Card Number: xxxx-%s', $this->getInfo()->getCcLast4()) ?>
{{pdf_row_separator}}
- __('Expiration Date: %s/%s', $this->getCcExpMonth(), $this->getInfo()->getCcExpYear()) ?>
- {{pdf_row_separator}}
getInfo()->getCcSsIssue()): ?>
__("Switch/Solo card issue number: %s", $this->getInfo()->getCcSsIssue()) ?>
{{pdf_row_separator}}
diff --git a/app/design/adminhtml/default/default/template/popup.phtml b/app/design/adminhtml/default/default/template/popup.phtml
index 962c23d17f..5ab2a1069c 100644
--- a/app/design/adminhtml/default/default/template/popup.phtml
+++ b/app/design/adminhtml/default/default/template/popup.phtml
@@ -42,7 +42,7 @@
getChildHtml('head') ?>
-
+getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>