+
-
diff --git a/app/code/Mage/AdminNotification/view/adminhtml/system/messages.phtml b/app/code/Mage/AdminNotification/view/adminhtml/system/messages.phtml
new file mode 100644
index 0000000000000..cebf108bc8b3e
--- /dev/null
+++ b/app/code/Mage/AdminNotification/view/adminhtml/system/messages.phtml
@@ -0,0 +1,49 @@
+
+
+
+getLastCritical();?>
+
+
diff --git a/app/code/Mage/AdminNotification/view/adminhtml/system/messages/popup.phtml b/app/code/Mage/AdminNotification/view/adminhtml/system/messages/popup.phtml
new file mode 100644
index 0000000000000..4cb41f72c420b
--- /dev/null
+++ b/app/code/Mage/AdminNotification/view/adminhtml/system/messages/popup.phtml
@@ -0,0 +1,43 @@
+
+
+
+
+ getUnreadMessages() as $message): ?>
+
+ getText();?>
+
+
+
+
+
diff --git a/app/code/Mage/AdminNotification/view/adminhtml/system/notification.js b/app/code/Mage/AdminNotification/view/adminhtml/system/notification.js
new file mode 100644
index 0000000000000..c9da34d50563e
--- /dev/null
+++ b/app/code/Mage/AdminNotification/view/adminhtml/system/notification.js
@@ -0,0 +1,73 @@
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+ */
+/*jshint jquery:true*/
+(function ($) {
+ $.template(
+ 'systemMessageDialog',
+ '
{{html text}} '
+ );
+
+ $.widget('mage.systemMessageDialog', $.ui.dialog, {
+ options: {
+ systemMessageTemplate: 'systemMessageDialog'
+ },
+ open: function(severity) {
+ var superMethod = $.proxy(this._super, this);
+ $.ajax({
+ url: this.options.ajaxUrl,
+ type: 'GET',
+ data: {severity: severity}
+ }).done($.proxy(function(data) {
+ this.element.html(
+ $('
', {'class': "message-system-list"}).append(
+ $.tmpl(this.options.systemMessageTemplate, data)
+ )
+ ).trigger('contentUpdated');
+ superMethod();
+ }, this));
+ return this;
+ }
+ });
+
+ $(document).ready(function(){
+ $('body').on('surveyYes surveyNo', function(e, data) {
+ if (e.type == 'surveyYes') {
+ var win = window.open(data.surveyUrl, '', 'width=900,height=600,resizable=1,scrollbars=1');
+ win.focus();
+ }
+ $.ajax({
+ url: data.surveyAction,
+ type: 'post',
+ data: {decision: data.decision}
+ })
+ });
+
+ $('#system_messages .message-system-short .error').on('click', function() {
+ $('#message-system-all').systemMessageDialog('open', 1);
+ });
+ $('#system_messages .message-system-short .warning').on('click', function() {
+ $('#message-system-all').systemMessageDialog('open', 2);
+ });
+ });
+})(jQuery);
+
diff --git a/app/code/Mage/AdminNotification/view/adminhtml/toolbar_entry.js b/app/code/Mage/AdminNotification/view/adminhtml/toolbar_entry.js
new file mode 100644
index 0000000000000..56652a04d90fe
--- /dev/null
+++ b/app/code/Mage/AdminNotification/view/adminhtml/toolbar_entry.js
@@ -0,0 +1,118 @@
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category Mage
+ * @package Mage_AdminNotification
+ * @copyright Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+ */
+
+(function($) {
+ 'use strict';
+ $(document).ready(function() {
+ // Mark notification as read via AJAX call
+ var markNotificationAsRead = function(notificationId) {
+ var requestUrl = $('.notifications .dropdown-menu').attr('data-mark-as-read-url');
+ $.ajax({
+ url: requestUrl,
+ type: 'POST',
+ dataType: 'json',
+ data: {
+ id: notificationId
+ },
+ showLoader: false
+ });
+ };
+
+ // Remove notification from the list
+ var removeNotificationFromList = function(notificationEntry) {
+ notificationEntry.remove();
+ var notificationCount = $('.notifications').attr('data-notification-count');
+ notificationCount--;
+ $('.notifications').attr('data-notification-count', notificationCount);
+
+ if (notificationCount == 0) {
+ // Change appearance of the bubble and its behavior when the last notification is removed
+ $('.notifications .dropdown-menu').remove();
+ var notificationIcon = $('.notifications .notifications-icon');
+ notificationIcon.removeAttr('data-toggle');
+ notificationIcon.off('click.dropdown');
+ $('.notifications .notifications-icon .value').text('');
+ } else {
+ $('.notifications .notifications-icon .value').text(notificationCount);
+ // Modify caption of the 'See All' link
+ var actionElement = $('.notifications .dropdown-menu .last .action-more');
+ actionElement.text(actionElement.text().replace(/\d+/, notificationCount));
+ }
+ };
+
+ // Show popup with notification details
+ var showNotificationDetails = function(notificationEntry) {
+ var popupElement = notificationEntry.find('.notification-dialog-content').clone();
+ var notificationId = notificationEntry.attr('data-notification-id');
+ var dialogClassSeverity = 'notification-entry-dialog';
+ if (notificationEntry.attr('data-notification-severity')) {
+ dialogClassSeverity = 'notification-entry-dialog notification-entry-dialog-critical';
+ }
+ popupElement.dialog({
+ title: popupElement.attr('data-title'),
+ minWidth: 500,
+ modal: true,
+ dialogClass: dialogClassSeverity,
+ buttons: [
+ {
+ text: popupElement.attr('data-acknowledge-caption'),
+ 'class': 'action-acknowledge primary',
+ click: function(event) {
+ markNotificationAsRead(notificationId);
+ removeNotificationFromList(notificationEntry);
+ $(this).dialog('close');
+ }
+ },
+ {
+ text: popupElement.attr('data-cancel-caption'),
+ 'class': 'action-cancel',
+ click: function(event) {
+ $(this).dialog('close');
+ }
+ }
+ ]
+ });
+ popupElement.parent().attr('aria-live','assertive');
+ popupElement.dialog('open');
+ };
+
+ // Show notification description when corresponding item is clicked
+ $('.notifications .dropdown-menu .notification-entry').on('click.showNotification', function(event) {
+ // hide notification dropdown
+ $('.notifications .notifications-icon').trigger('click.dropdown');
+ showNotificationDetails($(this));
+ event.stopPropagation();
+ });
+
+ // Remove corresponding notification from the list and mark it as read
+ $('.notifications .dropdown-menu .notification-entry .action-close').on('click.removeNotification', function(event) {
+ var notificationEntry = $(this).closest('.notification-entry')
+ var notificationId = notificationEntry.attr('data-notification-id');
+ markNotificationAsRead(notificationId);
+ removeNotificationFromList(notificationEntry);
+ event.stopPropagation();
+ });
+ });
+})(window.jQuery);
diff --git a/app/code/Mage/AdminNotification/view/adminhtml/toolbar_entry.phtml b/app/code/Mage/AdminNotification/view/adminhtml/toolbar_entry.phtml
new file mode 100644
index 0000000000000..9ddcb02645179
--- /dev/null
+++ b/app/code/Mage/AdminNotification/view/adminhtml/toolbar_entry.phtml
@@ -0,0 +1,63 @@
+
+
+getUnreadNotificationCount(); ?>
+
diff --git a/app/code/Mage/Adminhtml/Block/Api/Buttons.php b/app/code/Mage/Adminhtml/Block/Api/Buttons.php
index 1f8e478523f14..eb11dab8a66e6 100644
--- a/app/code/Mage/Adminhtml/Block/Api/Buttons.php
+++ b/app/code/Mage/Adminhtml/Block/Api/Buttons.php
@@ -42,11 +42,13 @@ protected function _prepareLayout()
'onclick' => 'window.location.reload()'
));
- $this->addChild('saveButton', 'Mage_Adminhtml_Block_Widget_Button', array(
- 'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Save Role'),
+ $this->addChild('saveButton', 'Mage_Backend_Block_Widget_Button', array(
+ 'label' => Mage::helper('Mage_User_Helper_Data')->__('Save Role'),
'class' => 'save',
- 'data_attr' => array(
- 'widget-button' => array('event' => 'save', 'related' => '#role-edit-form')
+ 'data_attribute' => array(
+ 'mage-init' => array(
+ 'button' => array('event' => 'save', 'target' => '#role-edit-form')
+ )
)
));
diff --git a/app/code/Mage/Adminhtml/Block/Api/Grid/Role.php b/app/code/Mage/Adminhtml/Block/Api/Grid/Role.php
index 66f3f11a7d7eb..d891b4e7dd30e 100644
--- a/app/code/Mage/Adminhtml/Block/Api/Grid/Role.php
+++ b/app/code/Mage/Adminhtml/Block/Api/Grid/Role.php
@@ -62,7 +62,7 @@ protected function _prepareColumns()
));
$this->addColumn('role_name', array(
- 'header' =>Mage::helper('Mage_Adminhtml_Helper_Data')->__('Role Name'),
+ 'header' =>Mage::helper('Mage_Adminhtml_Helper_Data')->__('Role'),
'index' =>'role_name'
));
diff --git a/app/code/Mage/Adminhtml/Block/Api/Role/Grid/User.php b/app/code/Mage/Adminhtml/Block/Api/Role/Grid/User.php
index f220af82959b6..b5363d8d5ec8f 100644
--- a/app/code/Mage/Adminhtml/Block/Api/Role/Grid/User.php
+++ b/app/code/Mage/Adminhtml/Block/Api/Role/Grid/User.php
@@ -47,7 +47,7 @@ protected function _construct()
protected function _addColumnFilterToCollection($column)
{
if ($column->getId() == 'in_role_users') {
- $inRoleIds = $this->_getUsers();
+ $inRoleIds = $this->getUsers();
if (empty($inRoleIds)) {
$inRoleIds = 0;
}
@@ -81,7 +81,7 @@ protected function _prepareColumns()
'header_css_class' => 'a-center',
'type' => 'checkbox',
'name' => 'in_role_users',
- 'values' => $this->_getUsers(),
+ 'values' => $this->getUsers(),
'align' => 'center',
'index' => 'user_id'
));
@@ -154,7 +154,7 @@ public function getGridUrl()
return $this->getUrl('*/*/editrolegrid', array('rid' => $roleId));
}
- protected function _getUsers($json=false)
+ public function getUsers($json=false)
{
if ( $this->getRequest()->getParam('in_role_user') != "" ) {
return $this->getRequest()->getParam('in_role_user');
diff --git a/app/code/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php b/app/code/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php
index 2acc4d1ec6983..6f32f01b7663b 100644
--- a/app/code/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php
+++ b/app/code/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php
@@ -56,46 +56,46 @@ protected function _construct() {
//->assign('checkedResources', join(',', $selrids));
}
+ /**
+ * Get is everything allowed
+ *
+ * @return bool
+ */
public function getEverythingAllowed()
{
return in_array('all', $this->getSelectedResources());
}
- public function getResTreeJson()
+ /**
+ * Get Resource Tree
+ *
+ * @return array
+ */
+ public function getTree()
{
- $rid = Mage::app()->getRequest()->getParam('rid', false);
- $resources = Mage::getModel('Mage_Api_Model_Roles')->getResourcesTree();
-
- $rootArray = $this->_getNodeJson($resources,1);
-
- $json = Mage::helper('Mage_Core_Helper_Data')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());
-
- return $json;
- }
-
- protected function _sortTree($a, $b)
- {
- return $a['sort_order']<$b['sort_order'] ? -1 : ($a['sort_order']>$b['sort_order'] ? 1 : 0);
+ $resource = Mage::getModel('Mage_Api_Model_Roles')->getResourcesTree();
+ $rootArray = $this->_mapResources($resource);
+ return $rootArray['children'];
}
-
- protected function _getNodeJson($node, $level=0)
+ /**
+ * Map resources
+ *
+ * @param $resources
+ * @return array
+ */
+ protected function _mapResources($resources)
{
$item = array();
- $selres = $this->getSelectedResources();
- if ($level != 0) {
- $item['text']= (string)$node->title;
- $item['sort_order']= isset($node->sort_order) ? (string)$node->sort_order : 0;
- $item['id'] = (string)$node->attributes()->aclpath;
+ $item['data'] = (string)$resources->title;
+ $item['sort_order']= isset($resources->sort_order) ? (string)$resources->sort_order : 0;
+ $item['attr']['data-id'] = (string)$resources->attributes()->aclpath;
- if (in_array($item['id'], $selres))
- $item['checked'] = true;
- }
- if (isset($node->children)) {
- $children = $node->children->children();
+ if (isset($resources->children)) {
+ $children = $resources->children->children();
} else {
- $children = $node->children();
+ $children = $resources->children();
}
if (empty($children)) {
return $item;
@@ -103,14 +103,10 @@ protected function _getNodeJson($node, $level=0)
if ($children) {
$item['children'] = array();
- //$item['cls'] = 'fiche-node';
foreach ($children as $child) {
- if ($child->getName()!='title' && $child->getName()!='sort_order' && $child->attributes()->module) {
- if ($level != 0) {
- $item['children'][] = $this->_getNodeJson($child, $level+1);
- } else {
- $item = $this->_getNodeJson($child, $level+1);
- }
+ if ($child->getName() != 'title' && $child->getName() != 'sort_order' && $child->attributes()->module) {
+ $item['state'] = 'open';
+ $item['children'][] = $this->_mapResources($child);
}
}
if (!empty($item['children'])) {
@@ -119,4 +115,16 @@ protected function _getNodeJson($node, $level=0)
}
return $item;
}
+
+ /**
+ * Sort tree by sort order
+ *
+ * @param array $a
+ * @param array $b
+ * @return int
+ */
+ protected function _sortTree($a, $b)
+ {
+ return $a['sort_order'] < $b['sort_order'] ? -1 : ($a['sort_order'] > $b['sort_order'] ? 1 : 0);
+ }
}
diff --git a/app/code/Mage/Adminhtml/Block/Api/User.php b/app/code/Mage/Adminhtml/Block/Api/User.php
index 54f560c56e1f0..45a74863b51c7 100644
--- a/app/code/Mage/Adminhtml/Block/Api/User.php
+++ b/app/code/Mage/Adminhtml/Block/Api/User.php
@@ -31,7 +31,7 @@
* @package Mage_Adminhtml
* @author Magento Core Team
*/
-class Mage_Adminhtml_Block_Api_User extends Mage_Adminhtml_Block_Widget_Grid_Container
+class Mage_Adminhtml_Block_Api_User extends Mage_Backend_Block_Widget_Grid_Container
{
protected function _construct()
diff --git a/app/code/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.php b/app/code/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.php
index 3dddfc4617796..ae98311993565 100644
--- a/app/code/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.php
+++ b/app/code/Mage/Adminhtml/Block/Api/User/Edit/Tab/Roles.php
@@ -41,7 +41,7 @@ protected function _construct()
protected function _addColumnFilterToCollection($column)
{
if ($column->getId() == 'assigned_user_role') {
- $userRoles = $this->_getSelectedRoles();
+ $userRoles = $this->getSelectedRoles();
if (empty($userRoles)) {
$userRoles = 0;
}
@@ -76,7 +76,7 @@ protected function _prepareColumns()
'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Assigned'),
'type' => 'radio',
'html_name' => 'roles[]',
- 'values' => $this->_getSelectedRoles(),
+ 'values' => $this->getSelectedRoles(),
'align' => 'center',
'index' => 'role_id'
));
@@ -89,7 +89,7 @@ protected function _prepareColumns()
));*/
$this->addColumn('role_name', array(
- 'header' =>Mage::helper('Mage_Adminhtml_Helper_Data')->__('Role Name'),
+ 'header' =>Mage::helper('Mage_Adminhtml_Helper_Data')->__('Role'),
'index' =>'role_name'
));
@@ -101,7 +101,7 @@ public function getGridUrl()
return $this->getUrl('*/*/rolesGrid', array('user_id' => Mage::registry('api_user')->getUserId()));
}
- protected function _getSelectedRoles($json=false)
+ public function getSelectedRoles($json=false)
{
if ( $this->getRequest()->getParam('user_roles') != "" ) {
return $this->getRequest()->getParam('user_roles');
diff --git a/app/code/Mage/Adminhtml/Block/Api/User/Grid.php b/app/code/Mage/Adminhtml/Block/Api/User/Grid.php
deleted file mode 100644
index 0e635df67223b..0000000000000
--- a/app/code/Mage/Adminhtml/Block/Api/User/Grid.php
+++ /dev/null
@@ -1,106 +0,0 @@
-
- */
-class Mage_Adminhtml_Block_Api_User_Grid extends Mage_Adminhtml_Block_Widget_Grid
-{
-
- protected function _construct()
- {
- parent::_construct();
- $this->setId('permissionsUserGrid');
- $this->setDefaultSort('username');
- $this->setDefaultDir('asc');
- $this->setUseAjax(true);
- }
-
- protected function _prepareCollection()
- {
- $collection = Mage::getResourceModel('Mage_Api_Model_Resource_User_Collection');
- $this->setCollection($collection);
- return parent::_prepareCollection();
- }
-
- protected function _prepareColumns()
- {
- $this->addColumn('user_id', array(
- 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('ID'),
- 'width' => 5,
- 'align' => 'right',
- 'sortable' => true,
- 'index' => 'user_id'
- ));
-
- $this->addColumn('username', array(
- 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('User Name'),
- 'index' => 'username'
- ));
-
- $this->addColumn('firstname', array(
- 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('First Name'),
- 'index' => 'firstname'
- ));
-
- $this->addColumn('lastname', array(
- 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Last Name'),
- 'index' => 'lastname'
- ));
-
- $this->addColumn('email', array(
- 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Email'),
- 'width' => 40,
- 'align' => 'left',
- 'index' => 'email'
- ));
-
- $this->addColumn('is_active', array(
- 'header' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Status'),
- 'index' => 'is_active',
- 'type' => 'options',
- 'options' => array('1' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Active'), '0' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Inactive')),
- ));
-
- return parent::_prepareColumns();
- }
-
- public function getRowUrl($row)
- {
- return $this->getUrl('*/*/edit', array('user_id' => $row->getId()));
- }
-
- public function getGridUrl()
- {
- //$uid = $this->getRequest()->getParam('user_id');
- return $this->getUrl('*/*/roleGrid', array());
- }
-
-}
diff --git a/app/code/Mage/Adminhtml/Block/Cache/Grid.php b/app/code/Mage/Adminhtml/Block/Cache/Grid.php
deleted file mode 100644
index ddf2cd2fb11c8..0000000000000
--- a/app/code/Mage/Adminhtml/Block/Cache/Grid.php
+++ /dev/null
@@ -1,172 +0,0 @@
-setId('cache_grid');
- $this->setFilterVisibility(false);
- $this->setPagerVisibility(false);
- $this->_invalidatedTypes = Mage::app()->getCacheInstance()->getInvalidatedTypes();
- }
-
- /**
- * Prepare grid collection
- */
- protected function _prepareCollection()
- {
- $collection = new Varien_Data_Collection();
- foreach (Mage::app()->getCacheInstance()->getTypes() as $type) {
- $collection->addItem($type);
- }
- $this->setCollection($collection);
- return parent::_prepareCollection();
- }
-
- /**
- * Prepare grid columns
- */
- protected function _prepareColumns()
- {
- $baseUrl = $this->getUrl();
- $this->addColumn('cache_type', array(
- 'header' => $this->__('Cache Type'),
- 'width' => '180',
- 'align' => 'left',
- 'index' => 'cache_type',
- 'sortable' => false,
- ));
-
- $this->addColumn('description', array(
- 'header' => $this->__('Description'),
- 'align' => 'left',
- 'index' => 'description',
- 'sortable' => false,
- ));
-
- $this->addColumn('tags', array(
- 'header' => $this->__('Associated Tags'),
- 'align' => 'left',
- 'index' => 'tags',
- 'width' => '180',
- 'sortable' => false,
- ));
-
- $this->addColumn('status', array(
- 'header' => $this->__('Status'),
- 'width' => '120',
- 'align' => 'left',
- 'index' => 'status',
- 'type' => 'options',
- 'options' => array(0 => $this->__('Disabled'), 1 => $this->__('Enabled')),
- 'frame_callback' => array($this, 'decorateStatus')
- ));
-
-// $this->addColumn('action',
-// array(
-// 'header' => $this->__('Action'),
-// 'width' => '100',
-// 'type' => 'action',
-// 'getter' => 'getId',
-// 'actions' => array(
-// array(
-// 'caption' => $this->__('Refresh'),
-// 'url' => array('base'=> '*/*/refresh'),
-// 'field' => 'type'
-// ),
-// ),
-// 'filter' => false,
-// 'sortable' => false,
-// 'is_system' => true,
-// ));
-
- return parent::_prepareColumns();
- }
-
- /**
- * Decorate status column values
- *
- * @return string
- */
- public function decorateStatus($value, $row, $column, $isExport)
- {
- $class = '';
- if (isset($this->_invalidatedTypes[$row->getId()])) {
- $cell = ''.$this->__('Invalidated').' ';
- } else {
- if ($row->getStatus()) {
- $cell = ''.$value.' ';
- } else {
- $cell = ''.$value.' ';
- }
- }
- return $cell;
- }
-
- /**
- * Get row edit url
- *
- * @return string
- */
- public function getRowUrl($row)
- {
- return false;
- //return $this->getUrl('*/*/edit', array('type'=>$row->getId()));
- }
-
- /**
- * Add mass-actions to grid
- */
- protected function _prepareMassaction()
- {
- $this->setMassactionIdField('id');
- $this->getMassactionBlock()->setFormFieldName('types');
-
- $modeOptions = Mage::getModel('Mage_Index_Model_Process')->getModesOptions();
-
- $this->getMassactionBlock()->addItem('enable', array(
- 'label' => Mage::helper('Mage_Index_Helper_Data')->__('Enable'),
- 'url' => $this->getUrl('*/*/massEnable'),
- ));
- $this->getMassactionBlock()->addItem('disable', array(
- 'label' => Mage::helper('Mage_Index_Helper_Data')->__('Disable'),
- 'url' => $this->getUrl('*/*/massDisable'),
- ));
- $this->getMassactionBlock()->addItem('refresh', array(
- 'label' => Mage::helper('Mage_Index_Helper_Data')->__('Refresh'),
- 'url' => $this->getUrl('*/*/massRefresh'),
- 'selected' => true,
- ));
-
- return $this;
- }
-}
diff --git a/app/code/Mage/Adminhtml/Block/Cache/Notifications.php b/app/code/Mage/Adminhtml/Block/Cache/Notifications.php
deleted file mode 100644
index 3dfee82bda62a..0000000000000
--- a/app/code/Mage/Adminhtml/Block/Cache/Notifications.php
+++ /dev/null
@@ -1,66 +0,0 @@
-getCacheInstance()->getInvalidatedTypes();
- $res = array();
- foreach ($invalidatedTypes as $type) {
- $res[] = $type->getCacheType();
- }
- return $res;
- }
-
- /**
- * Get index management url
- *
- * @return string
- */
- public function getManageUrl()
- {
- return $this->getUrl('adminhtml/cache');
- }
-
- /**
- * ACL validation before html generation
- *
- * @return string
- */
- protected function _toHtml()
- {
- if (Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Adminhtml::cache')) {
- return parent::_toHtml();
- }
- return '';
- }
-}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Category/Tree.php b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tree.php
index 2223168468494..f847da6ed0291 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Category/Tree.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Category/Tree.php
@@ -38,7 +38,6 @@ class Mage_Adminhtml_Block_Catalog_Category_Tree extends Mage_Adminhtml_Block_Ca
protected $_template = 'catalog/category/tree.phtml';
-
protected function _construct()
{
parent::_construct();
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product.php b/app/code/Mage/Adminhtml/Block/Catalog/Product.php
index 6f04a70c42414..e35ca526b8f44 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product.php
@@ -42,17 +42,15 @@ class Mage_Adminhtml_Block_Catalog_Product extends Mage_Adminhtml_Block_Widget_C
*/
protected function _prepareLayout()
{
- /** @var $limitation Mage_Catalog_Model_Product_Limitation */
- $limitation = Mage::getObjectManager()->get('Mage_Catalog_Model_Product_Limitation');
- if (!$limitation->isCreateRestricted()) {
- $this->_addButton('add_new', array(
- 'id' => 'add_new_product',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Add Product'),
- 'class' => 'btn-add',
- 'class_name' => 'Mage_Backend_Block_Widget_Button_Split',
- 'options' => $this->_getAddProductButtonOptions()
- ));
- }
+ $addButtonProps = array(
+ 'id' => 'add_new_product',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Add Product'),
+ 'class' => 'btn-add',
+ 'button_class' => 'btn-round',
+ 'class_name' => 'Mage_Backend_Block_Widget_Button_Split',
+ 'options' => $this->_getAddProductButtonOptions(),
+ );
+ $this->_addButton('add_new', $addButtonProps);
$this->setChild(
'grid',
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute.php
index 7e9c031a982b0..9c7569966fd57 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute.php
@@ -38,7 +38,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Attribute extends Mage_Adminhtml_Bloc
protected function _construct()
{
$this->_controller = 'catalog_product_attribute';
- $this->_headerText = Mage::helper('Mage_Catalog_Helper_Data')->__('Manage Attributes');
+ $this->_headerText = Mage::helper('Mage_Catalog_Helper_Data')->__('Product Attributes');
$this->_addButtonLabel = Mage::helper('Mage_Catalog_Helper_Data')->__('Add New Attribute');
parent::_construct();
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php
index faafc38e7a4cf..e0caf4595615d 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php
@@ -44,16 +44,18 @@ protected function _construct()
if($this->getRequest()->getParam('popup')) {
$this->_removeButton('back');
- $this->_addButton(
- 'save_in_new_set',
- array(
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save in New Attribute Set'),
- 'class' => 'save',
- 'onclick' => 'saveAttributeInNewSet(\''
- . Mage::helper('Mage_Catalog_Helper_Data')->__('Enter Name for New Attribute Set')
- . '\')',
- )
- );
+ if ($this->getRequest()->getParam('product_tab') != 'variations') {
+ $this->_addButton(
+ 'save_in_new_set',
+ array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save in New Attribute Set'),
+ 'class' => 'save',
+ 'onclick' => 'saveAttributeInNewSet(\''
+ . Mage::helper('Mage_Catalog_Helper_Data')->__('Enter Name for New Attribute Set')
+ . '\')',
+ )
+ );
+ }
} else {
$this->_addButton(
'save_and_edit_button',
@@ -71,6 +73,7 @@ protected function _construct()
}
$this->_updateButton('save', 'label', Mage::helper('Mage_Catalog_Helper_Data')->__('Save Attribute'));
+ $this->_updateButton('save', 'class', 'save primary');
$this->_updateButton('save', 'data_attribute', array(
'mage-init' => array(
'button' => array('event' => 'save', 'target' => '#edit_form'),
@@ -118,6 +121,13 @@ public function getValidationUrl()
*/
public function getSaveUrl()
{
- return $this->getUrl('*/'.$this->_controller.'/save', array('_current'=>true, 'back'=>null));
+ return $this->getUrl(
+ '*/'.$this->_controller.'/save',
+ array(
+ '_current' => true,
+ 'back' => null,
+ 'product_tab' => $this->getRequest()->getParam('product_tab')
+ )
+ );
}
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Advanced.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Advanced.php
new file mode 100644
index 0000000000000..c2f921f885c17
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Advanced.php
@@ -0,0 +1,211 @@
+
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Advanced extends Mage_Backend_Block_Widget_Form
+{
+ /**
+ * Adding product form elements for editing attribute
+ *
+ * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Advanced
+ */
+ protected function _prepareForm()
+ {
+ $attributeObject = $this->getAttributeObject();
+
+ $form = new Varien_Data_Form(array(
+ 'id' => 'edit_form',
+ 'action' => $this->getData('action'),
+ 'method' => 'post'
+ ));
+
+ $fieldset = $form->addFieldset(
+ 'advanced_fieldset',
+ array(
+ 'legend' => $this->__('Advanced Attribute Properties'),
+ 'collapsable' => true
+ )
+ );
+
+ $yesno = Mage::getModel('Mage_Backend_Model_Config_Source_Yesno')->toOptionArray();
+
+ $validateClass = sprintf(
+ 'validate-code validate-length maximum-length-%d',
+ Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH
+ );
+ $fieldset->addField(
+ 'attribute_code',
+ 'text',
+ array(
+ 'name' => 'attribute_code',
+ 'label' => $this->__('Attribute Code'),
+ 'title' => $this->__('Attribute Code'),
+ 'note' => $this->__(
+ 'For internal use. Must be unique with no spaces. Maximum length of attribute code must be less than %s symbols',
+ Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH
+ ),
+ 'class' => $validateClass,
+ )
+ );
+
+ $fieldset->addField(
+ 'default_value_text',
+ 'text',
+ array(
+ 'name' => 'default_value_text',
+ 'label' => $this->__('Default Value'),
+ 'title' => $this->__('Default Value'),
+ 'value' => $attributeObject->getDefaultValue(),
+ )
+ );
+
+ $fieldset->addField(
+ 'default_value_yesno',
+ 'select',
+ array(
+ 'name' => 'default_value_yesno',
+ 'label' => $this->__('Default Value'),
+ 'title' => $this->__('Default Value'),
+ 'values' => $yesno,
+ 'value' => $attributeObject->getDefaultValue(),
+ )
+ );
+
+ $dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_LocaleInterface::FORMAT_TYPE_SHORT);
+ $fieldset->addField(
+ 'default_value_date',
+ 'date',
+ array(
+ 'name' => 'default_value_date',
+ 'label' => $this->__('Default Value'),
+ 'title' => $this->__('Default Value'),
+ 'image' => $this->getViewFileUrl('images/grid-cal.gif'),
+ 'value' => $attributeObject->getDefaultValue(),
+ 'date_format' => $dateFormat
+ )
+ );
+
+ $fieldset->addField(
+ 'default_value_textarea',
+ 'textarea',
+ array(
+ 'name' => 'default_value_textarea',
+ 'label' => $this->__('Default Value'),
+ 'title' => $this->__('Default Value'),
+ 'value' => $attributeObject->getDefaultValue(),
+ )
+ );
+
+ $fieldset->addField(
+ 'is_unique',
+ 'select',
+ array(
+ 'name' => 'is_unique',
+ 'label' => $this->__('Unique Value'),
+ 'title' => $this->__('Unique Value (not shared with other products)'),
+ 'note' => $this->__('Not shared with other products'),
+ 'values' => $yesno,
+ )
+ );
+
+ $fieldset->addField(
+ 'frontend_class',
+ 'select',
+ array(
+ 'name' => 'frontend_class',
+ 'label' => $this->__('Input Validation for Store Owner'),
+ 'title' => $this->__('Input Validation for Store Owner'),
+ 'values' => Mage::helper('Mage_Eav_Helper_Data')->getFrontendClasses(
+ $attributeObject->getEntityType()->getEntityTypeCode()
+ )
+ )
+ );
+
+ if ($attributeObject->getId()) {
+ $form->getElement('attribute_code')->setDisabled(1);
+ if (!$attributeObject->getIsUserDefined()) {
+ $form->getElement('is_unique')->setDisabled(1);
+ }
+ }
+
+ $yesnoSource = Mage::getModel('Mage_Backend_Model_Config_Source_Yesno')->toOptionArray();
+
+ $scopes = array(
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('Mage_Catalog_Helper_Data')->__('Store View'),
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('Mage_Catalog_Helper_Data')->__('Website'),
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('Mage_Catalog_Helper_Data')->__('Global'),
+ );
+
+ if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id') {
+ unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]);
+ }
+
+ $fieldset->addField('is_global', 'select', array(
+ 'name' => 'is_global',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Scope'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Scope'),
+ 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Declare attribute value saving scope'),
+ 'values'=> $scopes
+ ), 'attribute_code');
+
+
+ $fieldset->addField('is_configurable', 'select', array(
+ 'name' => 'is_configurable',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use To Create Configurable Product'),
+ 'values' => $yesnoSource,
+ ));
+ $this->setForm($form);
+ return $this;
+ }
+
+ /**
+ * Initialize form fileds values
+ *
+ * @return Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Advanced
+ */
+ protected function _initFormValues()
+ {
+ $this->getForm()->addValues($this->getAttributeObject()->getData());
+ return parent::_initFormValues();
+ }
+
+ /**
+ * Retrieve attribute object from registry
+ *
+ * @return Mage_Eav_Model_Entity_Attribute_Abstract
+ */
+ private function getAttributeObject()
+ {
+ return Mage::registry('entity_attribute');
+ }
+}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php
index d67dbb5e10868..8a7e9b3cc29bb 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Front.php
@@ -32,54 +32,54 @@
* @author Magento Core Team
*/
-class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Front extends Mage_Adminhtml_Block_Widget_Form
+class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Front extends Mage_Backend_Block_Widget_Form
{
-
+ /**
+ * @inheritdoc
+ * @return $this
+ */
protected function _prepareForm()
{
- $model = Mage::registry('entity_attribute');
+ $attributeObject = Mage::registry('entity_attribute');
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
- $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('Mage_Catalog_Helper_Data')->__('Frontend Properties')));
+ $yesnoSource = Mage::getModel('Mage_Backend_Model_Config_Source_Yesno')->toOptionArray();;
- $yesno = array(
- array(
- 'value' => 0,
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('No')
- ),
+ $fieldset = $form->addFieldset(
+ 'front_fieldset',
array(
- 'value' => 1,
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Yes')
- ));
-
+ 'legend'=>Mage::helper('Mage_Catalog_Helper_Data')->__('Frontend Properties'),
+ 'collapsable' => $this->getRequest()->has('popup'),
+ )
+ );
$fieldset->addField('is_searchable', 'select', array(
- 'name' => 'is_searchable',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Quick Search'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Quick Search'),
- 'values' => $yesno,
+ 'name' => 'is_searchable',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Quick Search'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Quick Search'),
+ 'values' => $yesnoSource,
));
$fieldset->addField('is_visible_in_advanced_search', 'select', array(
'name' => 'is_visible_in_advanced_search',
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Advanced Search'),
'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Advanced Search'),
- 'values' => $yesno,
+ 'values' => $yesnoSource,
));
$fieldset->addField('is_comparable', 'select', array(
'name' => 'is_comparable',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Comparable on the Frontend'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Comparable on the Frontend'),
- 'values' => $yesno,
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Comparable on Frontend'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Comparable on Frontend'),
+ 'values' => $yesnoSource,
));
-
$fieldset->addField('is_filterable', 'select', array(
'name' => 'is_filterable',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__("Use in Layered Navigation (Can be used only with catalog input type 'Dropdown')"),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Can be used only with catalog input type Dropdown'),
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__("Use In Layered Navigation"),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
+ 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
'values' => array(
array('value' => '0', 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('No')),
array('value' => '1', 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Filterable (with results)')),
@@ -87,19 +87,82 @@ protected function _prepareForm()
),
));
-// if ($model->getIsUserDefined() || !$model->getId()) {
- $fieldset->addField('is_visible_on_front', 'select', array(
- 'name' => 'is_visible_on_front',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Visible on Catalog Pages on Front-end'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Visible on Catalog Pages on Front-end'),
- 'values' => $yesno,
- ));
-// }
+ $fieldset->addField('is_filterable_in_search', 'select', array(
+ 'name' => 'is_filterable_in_search',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__("Use In Search Results Layered Navigation"),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
+ 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
+ 'values' => $yesnoSource,
+ ));
- $form->setValues($model->getData());
+ $fieldset->addField('is_used_for_promo_rules', 'select', array(
+ 'name' => 'is_used_for_promo_rules',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use for Promo Rule Conditions'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use for Promo Rule Conditions'),
+ 'values' => $yesnoSource,
+ ));
- $this->setForm($form);
+ $fieldset->addField('position', 'text', array(
+ 'name' => 'position',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Position'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Position in Layered Navigation'),
+ 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Position of attribute in layered navigation block'),
+ 'class' => 'validate-digits'
+ ));
+ $fieldset->addField('is_wysiwyg_enabled', 'select', array(
+ 'name' => 'is_wysiwyg_enabled',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Enable WYSIWYG'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Enable WYSIWYG'),
+ 'values' => $yesnoSource,
+ ));
+
+ $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'select', array(
+ 'name' => 'is_html_allowed_on_front',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Allow HTML Tags on Frontend'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Allow HTML Tags on Frontend'),
+ 'values' => $yesnoSource,
+ ));
+ if (!$attributeObject->getId() || $attributeObject->getIsWysiwygEnabled()) {
+ $attributeObject->setIsHtmlAllowedOnFront(1);
+ }
+
+ $fieldset->addField('is_visible_on_front', 'select', array(
+ 'name' => 'is_visible_on_front',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Visible on Catalog Pages on Frontend'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Visible on Catalog Pages on Frontend'),
+ 'values' => $yesnoSource,
+ ));
+
+ $fieldset->addField('used_in_product_listing', 'select', array(
+ 'name' => 'used_in_product_listing',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Used in Product Listing'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Used in Product Listing'),
+ 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Depends on design theme'),
+ 'values' => $yesnoSource,
+ ));
+
+ $fieldset->addField('used_for_sort_by', 'select', array(
+ 'name' => 'used_for_sort_by',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Used for Sorting in Product Listing'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Used for Sorting in Product Listing'),
+ 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Depends on design theme'),
+ 'values' => $yesnoSource,
+ ));
+
+ // define field dependencies
+ $this->setChild(
+ 'form_after',
+ $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Form_Element_Dependence')
+ ->addFieldMap("is_wysiwyg_enabled", 'wysiwyg_enabled')
+ ->addFieldMap("is_html_allowed_on_front", 'html_allowed_on_front')
+ ->addFieldMap("frontend_input", 'frontend_input_type')
+ ->addFieldDependence('wysiwyg_enabled', 'frontend_input_type', 'textarea')
+ ->addFieldDependence('html_allowed_on_front', 'wysiwyg_enabled', '0')
+ );
+
+ $form->setValues($attributeObject->getData());
+ $this->setForm($form);
return parent::_prepareForm();
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php
index 4fce4c2cdf366..213befb50054d 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Main.php
@@ -47,6 +47,21 @@ protected function _prepareForm()
$form = $this->getForm();
/* @var $fieldset Varien_Data_Form_Element_Fieldset */
$fieldset = $form->getElement('base_fieldset');
+ $fiedsToRemove = array(
+ 'attribute_code',
+ 'is_unique',
+ 'frontend_class',
+ );
+
+ foreach ($fieldset->getElements() as $element) {
+ /** @var Varien_Data_Form_Abstract $element */
+ if (substr($element->getId(), 0, strlen('default_value')) == 'default_value') {
+ $fiedsToRemove[] = $element->getId();
+ }
+ }
+ foreach ($fiedsToRemove as $id) {
+ $fieldset->removeField($id);
+ }
$frontendInputElm = $form->getElement('frontend_input');
$additionalTypes = array(
@@ -54,15 +69,15 @@ protected function _prepareForm()
'value' => 'price',
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Price')
),
- array(
- 'value' => 'media_image',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Media Image')
- )
);
- if ($attributeObject->getFrontendInput() == 'gallery') {
+ $additionalReadOnlyTypes = array(
+ 'media_image' => Mage::helper('Mage_Catalog_Helper_Data')->__('Media Image'),
+ 'gallery' => Mage::helper('Mage_Catalog_Helper_Data')->__('Gallery')
+ );
+ if (isset($additionalReadOnlyTypes[$attributeObject->getFrontendInput()])) {
$additionalTypes[] = array(
- 'value' => 'gallery',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Gallery')
+ 'value' => $attributeObject->getFrontendInput(),
+ 'label' => $additionalReadOnlyTypes[$attributeObject->getFrontendInput()]
);
}
@@ -86,161 +101,6 @@ protected function _prepareForm()
$frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
$frontendInputElm->setValues($frontendInputValues);
- $yesnoSource = Mage::getModel('Mage_Backend_Model_Config_Source_Yesno')->toOptionArray();
-
- $scopes = array(
- Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('Mage_Catalog_Helper_Data')->__('Store View'),
- Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('Mage_Catalog_Helper_Data')->__('Website'),
- Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('Mage_Catalog_Helper_Data')->__('Global'),
- );
-
- if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id') {
- unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]);
- }
-
- $fieldset->addField('is_global', 'select', array(
- 'name' => 'is_global',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Scope'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Scope'),
- 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Declare attribute value saving scope'),
- 'values'=> $scopes
- ), 'attribute_code');
-
- $fieldset->addField('apply_to', 'apply', array(
- 'name' => 'apply_to[]',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Apply To'),
- 'values' => Mage_Catalog_Model_Product_Type::getOptions(),
- 'mode_labels' => array(
- 'all' => Mage::helper('Mage_Catalog_Helper_Data')->__('All Product Types'),
- 'custom' => Mage::helper('Mage_Catalog_Helper_Data')->__('Selected Product Types')
- ),
- 'required' => true,
- 'disabled' => !$attributeObject->getIsUserDefined() && $attributeObject->getId(),
- ), 'frontend_class');
-
- $fieldset->addField('is_configurable', 'select', array(
- 'name' => 'is_configurable',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use To Create Configurable Product'),
- 'values' => $yesnoSource,
- ), 'apply_to');
-
- // frontend properties fieldset
- $fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('Mage_Catalog_Helper_Data')->__('Frontend Properties')));
-
- $fieldset->addField('is_searchable', 'select', array(
- 'name' => 'is_searchable',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Quick Search'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Quick Search'),
- 'values' => $yesnoSource,
- ));
-
- $fieldset->addField('is_visible_in_advanced_search', 'select', array(
- 'name' => 'is_visible_in_advanced_search',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Advanced Search'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use in Advanced Search'),
- 'values' => $yesnoSource,
- ));
-
- $fieldset->addField('is_comparable', 'select', array(
- 'name' => 'is_comparable',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Comparable on Front-end'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Comparable on Front-end'),
- 'values' => $yesnoSource,
- ));
-
- $fieldset->addField('is_filterable', 'select', array(
- 'name' => 'is_filterable',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__("Use In Layered Navigation"),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
- 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
- 'values' => array(
- array('value' => '0', 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('No')),
- array('value' => '1', 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Filterable (with results)')),
- array('value' => '2', 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Filterable (no results)')),
- ),
- ));
-
- $fieldset->addField('is_filterable_in_search', 'select', array(
- 'name' => 'is_filterable_in_search',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__("Use In Search Results Layered Navigation"),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
- 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
- 'values' => $yesnoSource,
- ));
-
- $fieldset->addField('is_used_for_promo_rules', 'select', array(
- 'name' => 'is_used_for_promo_rules',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use for Promo Rule Conditions'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Use for Promo Rule Conditions'),
- 'values' => $yesnoSource,
- ));
-
- $fieldset->addField('position', 'text', array(
- 'name' => 'position',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Position'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Position in Layered Navigation'),
- 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Position of attribute in layered navigation block'),
- 'class' => 'validate-digits',
- ));
-
- $fieldset->addField('is_wysiwyg_enabled', 'select', array(
- 'name' => 'is_wysiwyg_enabled',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Enable WYSIWYG'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Enable WYSIWYG'),
- 'values' => $yesnoSource,
- ));
-
- $htmlAllowed = $fieldset->addField('is_html_allowed_on_front', 'select', array(
- 'name' => 'is_html_allowed_on_front',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Allow HTML Tags on Frontend'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Allow HTML Tags on Frontend'),
- 'values' => $yesnoSource,
- ));
- if (!$attributeObject->getId() || $attributeObject->getIsWysiwygEnabled()) {
- $attributeObject->setIsHtmlAllowedOnFront(1);
- }
-
- $fieldset->addField('is_visible_on_front', 'select', array(
- 'name' => 'is_visible_on_front',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Visible on Product View Page on Front-end'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Visible on Product View Page on Front-end'),
- 'values' => $yesnoSource,
- ));
-
- $fieldset->addField('used_in_product_listing', 'select', array(
- 'name' => 'used_in_product_listing',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Used in Product Listing'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Used in Product Listing'),
- 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Depends on design theme'),
- 'values' => $yesnoSource,
- ));
- $fieldset->addField('used_for_sort_by', 'select', array(
- 'name' => 'used_for_sort_by',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Used for Sorting in Product Listing'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Used for Sorting in Product Listing'),
- 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('Depends on design theme'),
- 'values' => $yesnoSource,
- ));
-
- $form->getElement('apply_to')->setSize(5);
-
- 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');
- }
-
- // define field dependencies
- $this->setChild(
- 'form_after',
- $this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Form_Element_Dependence')
- ->addFieldMap("is_wysiwyg_enabled", 'wysiwyg_enabled')
- ->addFieldMap("is_html_allowed_on_front", 'html_allowed_on_front')
- ->addFieldMap("frontend_input", 'frontend_input_type')
- ->addFieldDependence('wysiwyg_enabled', 'frontend_input_type', 'textarea')
- ->addFieldDependence('html_allowed_on_front', 'wysiwyg_enabled', '0')
- );
Mage::dispatchEvent('adminhtml_catalog_product_attribute_edit_prepare_form', array(
'form' => $form,
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php
index d3a7b63079af7..c837525fe7314 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tab/Options.php
@@ -37,22 +37,4 @@
class Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options
extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
{
- /**
- * Retrieve option values collection
- * It is represented by an array in case of system attribute
- *
- * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
- * @return array|Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection
- */
- protected function _getOptionValuesCollection(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
- {
- if ($this->canManageOptionDefaultOnly()) {
- $options = Mage::getModel($attribute->getSourceModel())
- ->setAttribute($attribute)
- ->getAllOptions(true);
- return array_reverse($options);
- } else {
- return parent::_getOptionValuesCollection($attribute);
- }
- }
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php
index 8397133a1d431..2c00d24941b86 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit/Tabs.php
@@ -44,20 +44,31 @@ protected function _construct()
protected function _beforeToHtml()
{
- $this->addTab('main', array(
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Properties'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Properties'),
- 'content' => $this->getLayout()
- ->createBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main')->toHtml(),
- 'active' => true
- ));
-
- $this->addTab('labels', array(
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Manage Label / Options'),
- 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Manage Label / Options'),
- 'content' => $this->getLayout()
- ->createBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options')->toHtml(),
- ));
+ $this->addTab(
+ 'main',
+ array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Properties'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Properties'),
+ 'content' => $this->getChildHtml('main'),
+ 'active' => true
+ )
+ );
+ $this->addTab(
+ 'labels',
+ array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Manage Labels'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Manage Labels'),
+ 'content' => $this->getChildHtml('labels'),
+ )
+ );
+ $this->addTab(
+ 'front',
+ array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Frontend Properties'),
+ 'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Frontend Properties'),
+ 'content' => $this->getChildHtml('front'),
+ )
+ );
return parent::_beforeToHtml();
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php
index 3f05f908d28b1..682ed700fe131 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Grid.php
@@ -75,7 +75,7 @@ protected function _prepareColumns()
'type' => 'options',
'options' => array(
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE =>Mage::helper('Mage_Catalog_Helper_Data')->__('Store View'),
- Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('Mage_Catalog_Helper_Data')->__('Website'),
+ Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE =>Mage::helper('Mage_Catalog_Helper_Data')->__('Web Site'),
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL =>Mage::helper('Mage_Catalog_Helper_Data')->__('Global'),
),
'align' => 'center',
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php
index 2053341a464dc..1b74861bb1229 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php
@@ -36,20 +36,6 @@ class Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Created extends
protected $_template = 'catalog/product/attribute/new/created.phtml';
- /**
- * Add additional blocks to layout
- *
- * @return void
- */
- protected function _prepareLayout()
- {
- $this->setChild(
- 'attributes',
- $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Attributes')
- ->setGroupAttributes($this->_getGroupAttributes())
- );
- }
-
/**
* Retrieve list of product attributes
*
@@ -86,12 +72,29 @@ public function getCloseButtonHtml()
*/
public function getAttributesBlockJson()
{
- $result = array(
- $this->getRequest()->getParam('product_tab') => $this->getChildHtml('attributes')
- );
+ $result = array();
+ if ($this->getRequest()->getParam('product_tab') == 'variations') {
+ /** @var $attribute Mage_Eav_Model_Entity_Attribute */
+ $attribute =
+ Mage::getModel('Mage_Eav_Model_Entity_Attribute')->load($this->getRequest()->getParam('attribute'));
+ $result = array(
+ 'tab' => $this->getRequest()->getParam('product_tab'),
+ 'attribute' => array(
+ 'id' => $attribute->getId(),
+ 'label' => $attribute->getFrontendLabel(),
+ 'code' => $attribute->getAttributeCode(),
+ 'options' => $attribute->getSourceModel() ? $attribute->getSource()->getAllOptions(false) : array()
+ )
+ );
+ }
$newAttributeSetId = $this->getRequest()->getParam('new_attribute_set_id');
if ($newAttributeSetId) {
- $result['newAttributeSetId'] = $newAttributeSetId;
+ /** @var $attributeSet Mage_Eav_Model_Entity_Attribute_Set */
+ $attributeSet = Mage::getModel('Mage_Eav_Model_Entity_Attribute_Set')->load($newAttributeSetId);
+ $result['set'] = array(
+ 'id' => $attributeSet->getId(),
+ 'label' => $attributeSet->getAttributeSetName(),
+ );
}
return Mage::helper('Mage_Core_Helper_Data')->jsonEncode($result);
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php
index 51012516f14ed..818055c564bee 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php
@@ -79,7 +79,7 @@ protected function _prepareLayout()
$this->addChild('delete_button', 'Mage_Adminhtml_Block_Widget_Button', array(
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Delete Attribute Set'),
- 'onclick' => 'deleteConfirm(\''. $this->jsQuoteEscape(Mage::helper('Mage_Catalog_Helper_Data')->__('All products of this set will be deleted! Are you sure you want to delete this attribute set?')) . '\', \'' . $this->getUrl('*/*/delete', array('id' => $setId)) . '\')',
+ 'onclick' => 'deleteConfirm(\''. $this->jsQuoteEscape(Mage::helper('Mage_Catalog_Helper_Data')->__('You are about to delete all products in this set. Are you sure you want to delete this attribute set?')) . '\', \'' . $this->getUrl('*/*/delete', array('id' => $setId)) . '\')',
'class' => 'delete'
));
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php
index 714c63893caeb..bbeb8920a7697 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formset.php
@@ -46,7 +46,7 @@ protected function _prepareForm()
$fieldset = $form->addFieldset('set_name', array('legend'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Edit Set Name')));
$fieldset->addField('attribute_set_name', 'text', array(
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Name'),
- 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('For internal use.'),
+ 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('For internal use'),
'name' => 'attribute_set_name',
'required' => true,
'class' => 'required-entry validate-no-html-tags',
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php
index be947e0ee6a86..c2ffd2e825d2c 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php
@@ -62,17 +62,17 @@ protected function _getHeader()
return Mage::helper('Mage_Catalog_Helper_Data')->__('Add New Attribute Set');
}
- protected function getSaveButtonHtml()
+ public function getSaveButtonHtml()
{
return $this->getChildHtml('save_button');
}
- protected function getBackButtonHtml()
+ public function getBackButtonHtml()
{
return $this->getChildHtml('back_button');
}
- protected function getFormHtml()
+ public function getFormHtml()
{
return $this->getChildHtml('setForm');
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php
index 0bb23f761025b..0e25cfa5701c6 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php
@@ -49,14 +49,14 @@ protected function _prepareLayout()
return parent::_prepareLayout();
}
- protected function getNewButtonHtml()
+ public function getNewButtonHtml()
{
return $this->getChildHtml('addButton');
}
protected function _getHeader()
{
- return Mage::helper('Mage_Catalog_Helper_Data')->__('Manage Attribute Sets');
+ return Mage::helper('Mage_Catalog_Helper_Data')->__('Product Templates');
}
protected function _toHtml()
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit.php
index 23a543176da1d..c37884ce9250f 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit.php
@@ -39,6 +39,7 @@ protected function _construct()
{
parent::_construct();
$this->setId('product_edit');
+ $this->setUseContainer(true);
}
/**
@@ -81,16 +82,6 @@ protected function _prepareLayout()
));
}
- if (!$this->getRequest()->getParam('popup')) {
- if ($this->getProduct()->isDeleteable()) {
- $this->addChild('delete_button', 'Mage_Adminhtml_Block_Widget_Button', array(
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Delete'),
- 'onclick' => 'confirmSetLocation(\''
- . Mage::helper('Mage_Catalog_Helper_Data')->__('Are you sure?') . '\', \'' . $this->getDeleteUrl() . '\')',
- 'class' => 'delete'
- ));
- }
- }
if (!$this->getProduct()->isReadonly()) {
$this->addChild('save-split-button', 'Mage_Backend_Block_Widget_Button_Split', array(
'id' => 'save-split-button',
@@ -183,11 +174,6 @@ public function getIsGrouped()
return $this->getProduct()->isGrouped();
}
- public function getDeleteUrl()
- {
- return $this->getUrl('*/*/delete', array('_current'=>true));
- }
-
public function getDuplicateUrl()
{
return $this->getUrl('*/*/duplicate', array('_current'=>true));
@@ -298,49 +284,39 @@ protected function _getSaveSplitButtonOptions()
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & Edit'),
'data_attribute' => array(
'mage-init' => array(
- 'button' => array('event' => 'saveAndContinueEdit', 'target' => '#product-edit-form'),
+ 'button' => array('event' => 'saveAndContinueEdit', 'target' => '[data-form=edit-product]'),
),
),
'default' => true,
);
}
- /** @var $limitation Mage_Catalog_Model_Product_Limitation */
- $limitation = Mage::getObjectManager()->get('Mage_Catalog_Model_Product_Limitation');
- if ($this->_isProductNew()) {
- $showAddNewButtons = !$limitation->isCreateRestricted(2);
- } else {
- $showAddNewButtons = !$limitation->isCreateRestricted();
- }
- if ($showAddNewButtons) {
+ $options[] = array(
+ 'id' => 'new-button',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & New'),
+ 'data_attribute' => array(
+ 'mage-init' => array(
+ 'button' => array('event' => 'saveAndNew', 'target' => '[data-form=edit-product]'),
+ ),
+ ),
+ );
+ if (!$this->getRequest()->getParam('popup') && $this->getProduct()->isDuplicable()) {
$options[] = array(
- 'id' => 'new-button',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & New'),
+ 'id' => 'duplicate-button',
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & Duplicate'),
'data_attribute' => array(
'mage-init' => array(
- 'button' => array('event' => 'saveAndNew', 'target' => '#product-edit-form'),
+ 'button' => array('event' => 'saveAndDuplicate', 'target' => '[data-form=edit-product]'),
),
),
);
- if (!$this->getRequest()->getParam('popup') && $this->getProduct()->isDuplicable()) {
- $options[] = array(
- 'id' => 'duplicate-button',
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & Duplicate'),
- 'data_attribute' => array(
- 'mage-init' => array(
- 'button' => array('event' => '', 'target' => '#product-edit-form'),
- ),
- ),
- 'onclick' => $this->_isProductNew() ? '' : 'setLocation(\'' . $this->getDuplicateUrl() . '\')',
- );
- }
}
$options[] = array(
'id' => 'close-button',
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Save & Close'),
'data_attribute' => array(
'mage-init' => array(
- 'button' => array('event' => 'save', 'target' => '#product-edit-form'),
+ 'button' => array('event' => 'save', 'target' => '[data-form=edit-product]'),
),
),
);
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php
index 8b27087349548..d1e244feac1fb 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/NewCategory.php
@@ -33,34 +33,75 @@
*/
class Mage_Adminhtml_Block_Catalog_Product_Edit_NewCategory extends Mage_Backend_Block_Widget_Form
{
+ /**
+ * @param Mage_Backend_Block_Template_Context $context
+ * @param Mage_Catalog_Model_CategoryFactory $categoryFactory
+ * @param array $data
+ */
+ public function __construct(
+ Mage_Backend_Block_Template_Context $context,
+ Mage_Catalog_Model_CategoryFactory $categoryFactory,
+ array $data = array()
+ ) {
+ parent::__construct($context, $data);
+ $this->setUseContainer(true);
+ $this->_categoryFactory = $categoryFactory;
+ }
+
/**
* Form preparation
*/
protected function _prepareForm()
{
- $form = new Varien_Data_Form();
+ $form = new Varien_Data_Form(array('id' => 'new_category_form'));
+ $form->setUseContainer($this->getUseContainer());
$form->addField('new_category_messages', 'note', array());
- $fieldset = $form->addFieldset('new_category_form', array());
+ $fieldset = $form->addFieldset('new_category_form_fieldset', array());
$fieldset->addField('new_category_name', 'text', array(
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Category Name'),
'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Category Name'),
'required' => true,
+ 'name' => 'new_category_name',
));
$fieldset->addField('new_category_parent', 'select', array(
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Parent Category'),
'title' => Mage::helper('Mage_Catalog_Helper_Data')->__('Parent Category'),
'required' => true,
- 'options' => array(),
+ 'options' => $this->_getParentCategoryOptions(),
'class' => 'validate-parent-category',
+ 'name' => 'new_category_parent',
+ // @codingStandardsIgnoreStart
+ 'note' => Mage::helper('Mage_Catalog_Helper_Data')->__('If there are no custom parent categories, please use the default parent category. You can reassign the category at any time in Products > Categories .', $this->getUrl('*/catalog_category')),
+ // @codingStandardsIgnoreEnd
));
$this->setForm($form);
}
+ /**
+ * Get parent category options
+ *
+ * @return array
+ */
+ protected function _getParentCategoryOptions()
+ {
+ $items = $this->_categoryFactory->create()
+ ->getCollection()
+ ->addAttributeToSelect('name')
+ ->addAttributeToSort('entity_id', 'ASC')
+ ->setPageSize(3)
+ ->load()
+ ->getItems();
+
+ return count($items) === 2
+ ? array($items[2]->getEntityId() => $items[2]->getName())
+ : array();
+ }
+
/**
* Category save action URL
*
@@ -80,7 +121,6 @@ public function getAfterElementHtml()
{
/** @var $coreHelper Mage_Core_Helper_Data */
$coreHelper = Mage::helper('Mage_Core_Helper_Data');
- $widgetUrl = $coreHelper->jsonEncode($this->getViewFileUrl('Mage_Catalog::js/new-category-dialog.js'));
$widgetOptions = $coreHelper->jsonEncode(array(
'suggestOptions' => array(
'source' => $this->getUrl('adminhtml/catalog_category/suggestCategories'),
@@ -93,10 +133,8 @@ public function getAfterElementHtml()
));
return <<
- head.js($widgetUrl, function () {
- jQuery(function($) { // waiting for page to load to have '#category_ids-template' available
- $('#new-category').mage('newCategoryDialog', $widgetOptions);
- });
+ jQuery(function($) { // waiting for page to load to have '#category_ids-template' available
+ $('#new-category').mage('newCategoryDialog', $widgetOptions);
});
HTML;
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php
index cf09e5ec02da7..8cdc513df9a28 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts.php
@@ -48,7 +48,7 @@ protected function _prepareLayout()
if ($alertPriceAllow) {
$accordion->addItem('price', array(
- 'title' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Price alert subscription was saved.'),
+ 'title' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('We saved the price alert subscription.'),
'content' => $this->getLayout()
->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts_Price')
->toHtml() . ' ',
@@ -57,7 +57,7 @@ protected function _prepareLayout()
}
if ($alertStockAllow) {
$accordion->addItem('stock', array(
- 'title' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Stock notification was saved.'),
+ 'title' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('We saved the stock notification.'),
'content' => $this->getLayout()
->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Alerts_Stock'),
'open' => true
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php
index 785018c47c479..2eda6175965db 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Price.php
@@ -43,7 +43,7 @@ protected function _construct()
$this->setDefaultSort('DESC');
$this->setUseAjax(true);
$this->setFilterVisibility(false);
- $this->setEmptyText(Mage::helper('Mage_Catalog_Helper_Data')->__('There are no customers for this alert'));
+ $this->setEmptyText(Mage::helper('Mage_Catalog_Helper_Data')->__('There are no customers for this alert.'));
}
protected function _prepareCollection()
@@ -88,13 +88,13 @@ protected function _prepareColumns()
));
$this->addColumn('add_date', array(
- 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Date Subscribed'),
+ 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Subscribe Date'),
'index' => 'add_date',
'type' => 'date'
));
$this->addColumn('last_send_date', array(
- 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Last Notification'),
+ 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Last Notified'),
'index' => 'last_send_date',
'type' => 'date'
));
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php
index 68296a02a3b44..b75ca3f0e64d3 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Alerts/Stock.php
@@ -80,13 +80,13 @@ protected function _prepareColumns()
));
$this->addColumn('add_date', array(
- 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Date Subscribed'),
+ 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Subscribe Date'),
'index' => 'add_date',
'type' => 'date'
));
$this->addColumn('send_date', array(
- 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Last Notification'),
+ 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Last Notified'),
'index' => 'send_date',
'type' => 'date'
));
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php
index acdee5bc910c6..97b96b233bed0 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php
@@ -108,15 +108,16 @@ protected function _prepareForm()
);
}
- // Add new attribute button if it is not an image tab
+ // Add new attribute controls if it is not an image tab
if (!$form->getElement('media_gallery')
- && Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Catalog::attributes_attributes')
+ && $this->_authorization->isAllowed('Mage_Catalog::attributes_attributes')
&& $isWrapped
) {
- $headerBar = $this->getLayout()
+ $attributeCreate = $this->getLayout()
->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create');
- $headerBar->getConfig()
+ $attributeCreate->getConfig()
+ ->setAttributeGroupCode($group->getAttributeGroupCode())
->setTabId('group_' . $group->getId())
->setGroupId($group->getId())
->setStoreId($form->getDataObject()->getStoreId())
@@ -124,7 +125,14 @@ protected function _prepareForm()
->setTypeId($form->getDataObject()->getTypeId())
->setProductId($form->getDataObject()->getId());
- $fieldset->setHeaderBar($headerBar->toHtml());
+ $attributeSearch = $this->getLayout()
+ ->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Search')
+ ->setGroupId($group->getId())
+ ->setGroupCode($group->getAttributeGroupCode());
+
+ $attributeSearch->setAttributeCreate($attributeCreate->toHtml());
+
+ $fieldset->setHeaderBar($attributeSearch->toHtml());
}
$values = $product->getData();
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php
index 389f898b584a1..987471c5f93db 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php
@@ -59,15 +59,14 @@ protected function _beforeToHtml()
$this->setId('create_attribute_' . $this->getConfig()->getGroupId())
->setType('button')
->setClass('action-add')
- ->setLabel(Mage::helper('Mage_Adminhtml_Helper_Data')->__('Add Attribute'))
+ ->setLabel(Mage::helper('Mage_Adminhtml_Helper_Data')->__('New Attribute'))
->setDataAttribute(array('mage-init' =>
array('productAttributes' =>
array(
'url' => $this->getUrl(
'*/catalog_product_attribute/new',
array(
- 'group' => $this->getConfig()->getGroupId(),
- 'product_tab' => $this->getConfig()->getTabId(),
+ 'group' => $this->getConfig()->getAttributeGroupCode(),
'store' => $this->getConfig()->getStoreId(),
'product' => $this->getConfig()->getProductId(),
'type' => $this->getConfig()->getTypeId(),
@@ -82,13 +81,11 @@ protected function _beforeToHtml()
->setUrl($this->getUrl(
'*/catalog_product_attribute/new',
array(
- 'group' => $this->getConfig()->getGroupId(),
- 'product_tab' => $this->getConfig()->getTabId(),
- 'store' => $this->getConfig()->getStoreId(),
- 'product' => $this->getConfig()->getProductId(),
- 'set' => $this->getConfig()->getAttributeSetId(),
- 'type' => $this->getConfig()->getTypeId(),
- 'popup' => 1
+ 'group' => $this->getConfig()->getAttributeGroupCode(),
+ 'store' => $this->getConfig()->getStoreId(),
+ 'product' => $this->getConfig()->getProductId(),
+ 'type' => $this->getConfig()->getTypeId(),
+ 'popup' => 1
)
));
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Search.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Search.php
new file mode 100644
index 0000000000000..14e0979183457
--- /dev/null
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Search.php
@@ -0,0 +1,95 @@
+
+ */
+class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Search extends Mage_Backend_Block_Widget
+{
+ /**
+ * Define block template
+ */
+ protected function _construct()
+ {
+ $this->setTemplate('Mage_Catalog::product/edit/attribute/search.phtml');
+ parent::_construct();
+ }
+
+ /**
+ * @return array
+ */
+ public function getSelectorOptions()
+ {
+ $templateId = Mage::registry('product')->getAttributeSetId();
+ return array(
+ 'source' => $this->getUrl('*/catalog_product/suggestAttributes'),
+ 'minLength' => 0,
+ 'ajaxOptions' => array('data' => array('template_id' => $templateId)),
+ 'template' => '[data-template-for="product-attribute-search"]',
+ 'data' => $this->getSuggestedAttributes('', $templateId),
+ );
+ }
+
+ /**
+ * Retrieve list of attributes with admin store label containing $labelPart
+ *
+ * @param string $labelPart
+ * @param int $templateId
+ * @return Mage_Catalog_Model_Resource_Product_Attribute_Collection
+ */
+ public function getSuggestedAttributes($labelPart, $templateId = null)
+ {
+ $escapedLabelPart = Mage::getResourceHelper('Mage_Core')->addLikeEscape($labelPart, array('position' => 'any'));
+ /** @var $collection Mage_Catalog_Model_Resource_Product_Attribute_Collection */
+ $collection = Mage::getResourceModel('Mage_Catalog_Model_Resource_Product_Attribute_Collection')
+ ->addFieldToFilter('frontend_label', array('like' => $escapedLabelPart));
+
+ $collection->setExcludeSetFilter($templateId ?: $this->getRequest()->getParam('template_id'))->setPageSize(20);
+
+ $result = array();
+ foreach ($collection->getItems() as $attribute) {
+ /** @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
+ $result[] = array(
+ 'id' => $attribute->getId(),
+ 'label' => $attribute->getFrontendLabel(),
+ 'code' => $attribute->getAttributeCode(),
+ );
+ }
+ return $result;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAddAttributeUrl()
+ {
+ return $this->getUrl('*/catalog_product/addAttributeToTemplate');
+ }
+}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php
index 236e759a9ed36..58f1d6b57c519 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Crosssell.php
@@ -43,7 +43,7 @@ protected function _construct()
$this->setId('cross_sell_product_grid');
$this->setDefaultSort('entity_id');
$this->setUseAjax(true);
- if ($this->_getProduct() && $this->_getProduct()->getId()) {
+ if ($this->getProduct() && $this->getProduct()->getId()) {
$this->setDefaultFilter(array('in_products'=>1));
}
if ($this->isReadonly()) {
@@ -56,7 +56,7 @@ protected function _construct()
*
* @return Mage_Catalog_Model_Product
*/
- protected function _getProduct()
+ public function getProduct()
{
return Mage::registry('current_product');
}
@@ -98,7 +98,7 @@ protected function _prepareCollection()
/* @var $collection Mage_Catalog_Model_Resource_Product_Link_Product_Collection */
$collection = Mage::getModel('Mage_Catalog_Model_Product_Link')->useCrossSellLinks()
->getProductCollection()
- ->setProduct($this->_getProduct())
+ ->setProduct($this->getProduct())
->addAttributeToSelect('*');
if ($this->isReadonly()) {
@@ -122,7 +122,7 @@ protected function _prepareCollection()
*/
public function isReadonly()
{
- return $this->_getProduct() && $this->_getProduct()->getCrosssellReadonly();
+ return $this->getProduct() && $this->getProduct()->getCrosssellReadonly();
}
/**
@@ -174,7 +174,7 @@ protected function _prepareColumns()
->toOptionHash();
$this->addColumn('set_name', array(
- 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attrib. Set Name'),
+ 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attribute Set'),
'index' => 'attribute_set_id',
'type' => 'options',
'options' => $sets,
@@ -224,7 +224,7 @@ protected function _prepareColumns()
'validate_class' => 'validate-number',
'index' => 'position',
'editable' => !$this->isReadonly(),
- 'edit_only' => !$this->_getProduct()->getId(),
+ 'edit_only' => !$this->getProduct()->getId(),
'header_css_class' => 'col-position',
'column_css_class' => 'col-position'
));
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php
index 655d55dc5000a..0065d11c83140 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Related.php
@@ -43,7 +43,7 @@ protected function _construct()
$this->setId('related_product_grid');
$this->setDefaultSort('entity_id');
$this->setUseAjax(true);
- if ($this->_getProduct()&& $this->_getProduct()->getId()) {
+ if ($this->getProduct()&& $this->getProduct()->getId()) {
$this->setDefaultFilter(array('in_products' => 1));
}
if ($this->isReadonly()) {
@@ -56,7 +56,7 @@ protected function _construct()
*
* @return Mage_Catalog_Model_Product
*/
- protected function _getProduct()
+ public function getProduct()
{
return Mage::registry('current_product');
}
@@ -97,7 +97,7 @@ protected function _prepareCollection()
{
$collection = Mage::getModel('Mage_Catalog_Model_Product_Link')->useRelatedLinks()
->getProductCollection()
- ->setProduct($this->_getProduct())
+ ->setProduct($this->getProduct())
->addAttributeToSelect('*');
if ($this->isReadonly()) {
@@ -119,7 +119,7 @@ protected function _prepareCollection()
*/
public function isReadonly()
{
- return $this->_getProduct() && $this->_getProduct()->getRelatedReadonly();
+ return $this->getProduct() && $this->getProduct()->getRelatedReadonly();
}
/**
@@ -171,7 +171,7 @@ protected function _prepareColumns()
->toOptionHash();
$this->addColumn('set_name', array(
- 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attrib. Set Name'),
+ 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attribute Set'),
'index' => 'attribute_set_id',
'type' => 'options',
'options' => $sets,
@@ -219,8 +219,8 @@ protected function _prepareColumns()
'type' => 'number',
'validate_class' => 'validate-number',
'index' => 'position',
- 'editable' => !$this->_getProduct()->getRelatedReadonly(),
- 'edit_only' => !$this->_getProduct()->getId(),
+ 'editable' => !$this->getProduct()->getRelatedReadonly(),
+ 'edit_only' => !$this->getProduct()->getId(),
'header_css_class' => 'col-position',
'column_css_class' => 'col-position'
));
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php
index 1940b4f5a47c7..116765ee92560 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php
@@ -32,10 +32,10 @@
* @package Mage_Adminhtml
* @author Magento Core Team
*/
-class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config extends Mage_Adminhtml_Block_Widget
- implements Mage_Adminhtml_Block_Widget_Tab_Interface
+class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config
+ extends Mage_Backend_Block_Widget
+ implements Mage_Backend_Block_Widget_Tab_Interface
{
-
protected $_template = 'catalog/product/edit/super/config.phtml';
/**
@@ -117,35 +117,80 @@ protected function _prepareLayout()
));
$this->addChild('super_settings', 'Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings');
- if ($this->getProduct()->getId()) {
- $this->setChild('simple',
- $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple',
- 'catalog.product.edit.tab.super.config.simple')
- );
-
- $this->addChild('create_from_configurable', 'Mage_Adminhtml_Block_Widget_Button', array(
- 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Copy From Configurable'),
- 'class' => 'add',
- 'onclick' => 'superProduct.createNewProduct()'
- ));
- }
+// @todo: Remove unused code and blocks
+// if ($this->getProduct()->getId()) {
+// $this->setChild('simple',
+// $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple',
+// 'catalog.product.edit.tab.super.config.simple')
+// );
+//
+// $this->addChild('create_from_configurable', 'Mage_Adminhtml_Block_Widget_Button', array(
+// 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Copy From Configurable'),
+// 'class' => 'add',
+// 'onclick' => 'superProduct.createNewProduct()'
+// ));
+// }
$this->addChild(
'generate',
'Mage_Backend_Block_Widget_Button',
array(
- 'id' => 'generate-variations-button',
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Generate Variations'),
+ 'class' => 'generate',
'data_attribute' => array(
'mage-init' => array(
'button' => array(
'event' => 'generate',
'target' => '#product-variations-matrix',
'eventData' => array(
- 'url' => $this->getUrl('*/*/variationsMatrix', array('_current' => true)),
+ 'url' => $this->getUrl('*/*/generateVariations', array('_current' => true)),
),
),
),
+ 'action' => 'generate',
+ ),
+ )
+ );
+ $this->addChild(
+ 'add_attribute',
+ 'Mage_Backend_Block_Widget_Button',
+ array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Create New Variation Set'),
+ 'class' => 'new-variation-set',
+ 'data_attribute' => array(
+ 'mage-init' => array(
+ 'configurableAttribute' => array(
+ 'url' => $this->getUrl(
+ '*/catalog_product_attribute/new',
+ array(
+ 'store' => $this->getProduct()->getStoreId(),
+ 'product_tab' => 'variations',
+ 'popup' => 1,
+ '_query' => array(
+ 'attribute' => array(
+ 'is_global' => 1,
+ 'frontend_input' => 'select',
+ 'is_configurable' => 1
+ ),
+ )
+ )
+ )
+ )
+ )
+ ),
+ )
+ );
+ $this->addChild(
+ 'add_option',
+ 'Mage_Backend_Block_Widget_Button',
+ array(
+ 'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Add Option'),
+ 'class' => 'action- scalable add',
+ 'data_attribute' => array(
+ 'mage-init' => array(
+ 'button' => array('event' => 'add-option'),
+ ),
+ 'action' => 'add-option',
),
)
);
@@ -380,4 +425,14 @@ public function getSelectedAttributes()
? array_filter($this->_getProductType()->getUsedProductAttributes($this->getProduct()))
: array();
}
+
+ /**
+ * Get parent tab code
+ *
+ * @return string
+ */
+ public function getParentTab()
+ {
+ return 'product-details';
+ }
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Attribute.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Attribute.php
index 68343b08c9d5b..651ecd92306db 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Attribute.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Attribute.php
@@ -32,7 +32,7 @@
* @author Magento Core Team
*/
class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Attribute
- extends Mage_Backend_Block_Template
+ extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config
{
/**
* Render block
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php
index bc7feea65f4be..618c10bb6e100 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Matrix.php
@@ -34,6 +34,40 @@
class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Matrix
extends Mage_Backend_Block_Template
{
+ /** @var Mage_Core_Model_App */
+ protected $_application;
+
+ /** @var Mage_Core_Model_LocaleInterface */
+ protected $_locale;
+
+ /**
+ * @param Mage_Backend_Block_Template_Context $context
+ * @param Mage_Core_Model_App $application
+ * @param Mage_Core_Model_LocaleInterface $locale
+ * @param array $data
+ */
+ public function __construct(
+ Mage_Backend_Block_Template_Context $context,
+ Mage_Core_Model_App $application,
+ Mage_Core_Model_LocaleInterface $locale,
+ array $data = array()
+ ) {
+ parent::__construct($context, $data);
+ $this->_application = $application;
+ $this->_locale = $locale;
+ }
+
+ /**
+ * Retrieve price rendered according to current locale and currency settings
+ *
+ * @param int|float $price
+ * @return string
+ */
+ public function renderPrice($price)
+ {
+ return $this->_locale->currency($this->_application->getBaseCurrencyCode())->toCurrency(sprintf('%f', $price));
+ }
+
/**
* Get configurable product type
*
@@ -63,7 +97,7 @@ public function getVariations()
{
$variationalAttributes = array();
$usedProductAttributes = $this->getAttributes();
- foreach ($usedProductAttributes as &$attribute) {
+ foreach ($usedProductAttributes as $attribute) {
$options = array();
foreach ($attribute['options'] as $valueInfo) {
foreach ($attribute['values'] as $priceData) {
@@ -80,8 +114,8 @@ public function getVariations()
'id' => $attribute['attribute_id'],
'values' => $options,
);
-
}
+
$attributesCount = count($variationalAttributes);
if ($attributesCount === 0) {
return array();
@@ -151,7 +185,6 @@ public function getAttributes()
}
}
}
-
$this->setData('attributes', $attributes);
}
return $this->getData('attributes');
@@ -232,7 +265,7 @@ public function getAttributeFrontendClass($code)
*
* @return string
*/
- protected function getImageUploadUrl()
+ public function getImageUploadUrl()
{
return $this->getUrl('*/catalog_product_gallery/upload');
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php
index 97c78fda75118..57e3ad0515aa1 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config/Simple.php
@@ -46,7 +46,7 @@ protected function _prepareForm()
$form = new Varien_Data_Form();
$form->setFieldNameSuffix('simple_product');
- $form->setDataObject($this->_getProduct());
+ $form->setDataObject($this->getProduct());
$fieldset = $form->addFieldset('simple_product', array(
'legend' => Mage::helper('Mage_Catalog_Helper_Data')->__('Quick simple product creation')
@@ -61,7 +61,7 @@ protected function _prepareForm()
$attributes = Mage::getModel('Mage_Catalog_Model_Product')
->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
- ->setAttributeSetId($this->_getProduct()->getAttributeSetId())
+ ->setAttributeSetId($this->getProduct()->getAttributeSetId())
->getAttributes();
/* Standart attributes */
@@ -72,7 +72,7 @@ protected function _prepareForm()
&& !in_array(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE, $attribute->getApplyTo())
// If not used in configurable
&& !in_array($attribute->getId(),
- $this->_getProduct()->getTypeInstance()->getUsedProductAttributeIds($this->_getProduct()))
+ $this->getProduct()->getTypeInstance()->getUsedProductAttributeIds($this->getProduct()))
)
// Or in additional
|| in_array($attribute->getAttributeCode(), $attributesConfig['additional'])
@@ -95,7 +95,7 @@ protected function _prepareForm()
if (in_array($attributeCode, $attributesConfig['autogenerate'])) {
$element->setDisabled('true');
- $element->setValue($this->_getProduct()->getData($attributeCode));
+ $element->setValue($this->getProduct()->getData($attributeCode));
$element->setAfterElementHtml(
' _getProduct()->getTypeInstance()->getUsedProductAttributes($this->_getProduct());
+ $usedAttributes = $this->getProduct()->getTypeInstance()->getUsedProductAttributes($this->getProduct());
foreach ($usedAttributes as $attribute) {
$attributeCode = $attribute->getAttributeCode();
$fieldset->addField( 'simple_product_' . $attributeCode, 'select', array(
@@ -179,7 +179,7 @@ protected function _prepareForm()
*
* @return Mage_Catalog_Model_Product
*/
- protected function _getProduct()
+ public function getProduct()
{
if (!$this->_product) {
$this->_product = Mage::registry('current_product');
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php
index 410c1f64eb0b1..48eca3fc2d959 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php
@@ -40,7 +40,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings extends Mage_
*/
protected function _prepareLayout()
{
- $onclick = "jQuery('#product-edit-form').attr('action', "
+ $onclick = "jQuery('[data-form=edit-product]').attr('action', "
. $this->helper('Mage_Core_Helper_Data')->jsonEncode($this->getContinueUrl())
. ").addClass('ignore-validate').submit();";
$this->addChild('continue_button', 'Mage_Backend_Block_Widget_Button', array(
@@ -56,7 +56,7 @@ protected function _prepareLayout()
*
* @return Mage_Catalog_Model_Product
*/
- protected function _getProduct()
+ public function getProduct()
{
return Mage::registry('current_product');
}
@@ -78,7 +78,7 @@ protected function _prepareForm()
'title' => 'Select Attribute',
));
- $product = $this->_getProduct();
+ $product = $this->getProduct();
/** @var $configurableType Mage_Catalog_Model_Product_Type_Configurable */
$configurableType = Mage::getSingleton('Mage_Catalog_Model_Product_Type_Configurable');
$usedAttributes = $product->isConfigurable()
@@ -113,7 +113,7 @@ protected function _prepareForm()
*/
public function getContinueUrl()
{
- return $this->getUrl($this->_getProduct()->getId() ? '*/*/edit' : '*/*/new', array(
+ return $this->getUrl($this->getProduct()->getId() ? '*/*/edit' : '*/*/new', array(
'_current' => true,
));
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php
index b8e6d55bbbd95..083a0d1021929 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php
@@ -44,7 +44,7 @@ protected function _construct()
$this->setId('up_sell_product_grid');
$this->setDefaultSort('entity_id');
$this->setUseAjax(true);
- if ($this->_getProduct() && $this->_getProduct()->getId()) {
+ if ($this->getProduct() && $this->getProduct()->getId()) {
$this->setDefaultFilter(array('in_products'=>1));
}
if ($this->isReadonly()) {
@@ -57,7 +57,7 @@ protected function _construct()
*
* @return Mage_Catalog_Model_Product
*/
- protected function _getProduct()
+ public function getProduct()
{
return Mage::registry('current_product');
}
@@ -96,7 +96,7 @@ protected function _addColumnFilterToCollection($column)
*/
public function isReadonly()
{
- return $this->_getProduct() && $this->_getProduct()->getUpsellReadonly();
+ return $this->getProduct() && $this->getProduct()->getUpsellReadonly();
}
/**
@@ -108,7 +108,7 @@ protected function _prepareCollection()
{
$collection = Mage::getModel('Mage_Catalog_Model_Product_Link')->useUpSellLinks()
->getProductCollection()
- ->setProduct($this->_getProduct())
+ ->setProduct($this->getProduct())
->addAttributeToSelect('*');
if ($this->isReadonly()) {
@@ -130,7 +130,7 @@ protected function _prepareCollection()
*/
protected function _prepareColumns()
{
- if (!$this->_getProduct()->getUpsellReadonly()) {
+ if (!$this->getProduct()->getUpsellReadonly()) {
$this->addColumn('in_products', array(
'type' => 'checkbox',
'name' => 'in_products',
@@ -171,7 +171,7 @@ protected function _prepareColumns()
->toOptionHash();
$this->addColumn('set_name', array(
- 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attrib. Set Name'),
+ 'header' => Mage::helper('Mage_Catalog_Helper_Data')->__('Attribute Set'),
'index' => 'attribute_set_id',
'type' => 'options',
'options' => $sets,
@@ -219,8 +219,8 @@ protected function _prepareColumns()
'type' => 'number',
'validate_class' => 'validate-number',
'index' => 'position',
- 'editable' => !$this->_getProduct()->getUpsellReadonly(),
- 'edit_only' => !$this->_getProduct()->getId(),
+ 'editable' => !$this->getProduct()->getUpsellReadonly(),
+ 'edit_only' => !$this->getProduct()->getId(),
'header_css_class' => 'col-position',
'column_css_class' => 'col-position'
));
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php
index 73279db842f76..922c199578756 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php
@@ -72,7 +72,10 @@ protected function _prepareLayout()
$attributes = $product->getAttributes($group->getId(), true);
foreach ($attributes as $key => $attribute) {
- if (!$attribute->getIsVisible()) {
+ $applyTo = $attribute->getApplyTo();
+ if (!$attribute->getIsVisible()
+ || (!empty($applyTo) && !in_array($product->getTypeId(), $applyTo))
+ ) {
unset($attributes[$key]);
}
}
@@ -180,7 +183,7 @@ protected function _prepareLayout()
if ($this->getRequest()->getParam('id')) {
if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_Review')) {
- if (Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Review::reviews_all')){
+ if ($this->_authorization->isAllowed('Mage_Review::reviews_all')){
$this->addTab('product-reviews', array(
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Product Reviews'),
'url' => $this->getUrl('*/*/reviews', array('_current' => true)),
@@ -254,7 +257,7 @@ public function setAttributeTabBlock($attributeTabBlock)
*/
protected function _translateHtml($html)
{
- Mage::getSingleton('Mage_Core_Model_Translate_Inline')->processResponseBody($html);
+ $this->_translator->processResponseBody($html);
return $html;
}
}
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Grid.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Grid.php
index a353a70322bde..fc258a17b4772 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Grid.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Grid.php
@@ -191,7 +191,7 @@ protected function _prepareColumns()
$this->addColumn('set_name',
array(
- 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Attrib. Set Name'),
+ 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Attribute Set'),
'width' => '100px',
'index' => 'attribute_set_id',
'type' => 'options',
@@ -223,7 +223,7 @@ protected function _prepareColumns()
if (Mage::helper('Mage_Catalog_Helper_Data')->isModuleEnabled('Mage_CatalogInventory')) {
$this->addColumn('qty',
array(
- 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Qty'),
+ 'header'=> Mage::helper('Mage_Catalog_Helper_Data')->__('Quantity'),
'width' => '100px',
'type' => 'number',
'index' => 'qty',
@@ -327,7 +327,7 @@ protected function _prepareMassaction()
)
));
- if (Mage::getSingleton('Mage_Core_Model_Authorization')->isAllowed('Mage_Catalog::update_attributes')){
+ if ($this->_authorization->isAllowed('Mage_Catalog::update_attributes')){
$this->getMassactionBlock()->addItem('attributes', array(
'label' => Mage::helper('Mage_Catalog_Helper_Data')->__('Update Attributes'),
'url' => $this->getUrl('*/catalog_product_action_attribute/edit', array('_current'=>true))
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php
index b963468465f7a..2f110c4934d6a 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/BaseImage.php
@@ -55,6 +55,11 @@ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_BaseImage extends Varien_
*/
protected $_fileConfig;
+ /**
+ * @var Mage_Core_Model_View_Url
+ */
+ protected $_viewUrl;
+
/**
* Constructor
*
@@ -64,6 +69,8 @@ public function __construct(array $attributes = array())
{
parent::__construct($attributes);
+ $this->_viewUrl = Mage::getModel('Mage_Core_Model_View_Url');
+
$this->_url = isset($attributes['url']) ? $attributes['url']
: Mage::getModel('Mage_Backend_Model_Url');
$this->_coreHelper = isset($attributes['coreHelper']) ? $attributes['coreHelper']
@@ -103,7 +110,7 @@ public function getElementHtml()
{
$htmlId = $this->_coreHelper->escapeHtml($this->getHtmlId());
$uploadUrl = $this->_coreHelper->escapeHtml($this->_getUploadUrl());
- $spacerImage = Mage::getDesign()->getViewFileUrl('images/spacer.gif');
+ $spacerImage = $this->_viewUrl->getViewFileUrl('images/spacer.gif');
/** @var $product Mage_Catalog_Model_Product */
$html = <<{$this->__('Click here or drag and drop to add images')}
@@ -138,7 +147,7 @@ public function getElementHtml()
(function($) {
'use strict';
- $('[data-activate-tab="image-management"]')
+ $('[data-activate-tab=image-management]')
.on('click.toggleImageManagementTab', function() {
$('#product_info_tabs_image-management').trigger('click');
});
diff --git a/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php
index a020e825e41d8..290a138fa8ce9 100644
--- a/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php
+++ b/app/code/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Category.php
@@ -33,6 +33,17 @@
*/
class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Category extends Varien_Data_Form_Element_Multiselect
{
+ /**
+ * @var Mage_Core_Model_Layout
+ */
+ protected $_layout;
+
+ public function __construct($attributes = array(), Mage_Core_Model_Layout $layout = null)
+ {
+ parent::__construct($attributes);
+ $this->_layout = $layout ?: Mage::getObjectManager()->get('Mage_Core_Model_Layout');
+ }
+
/**
* Get values for select
* @return array
@@ -81,15 +92,21 @@ public function getAfterElementHtml()
$selectorOptions = $coreHelper->jsonEncode($this->_getSelectorOptions());
$newCategoryCaption = Mage::helper('Mage_Catalog_Helper_Data')->__('New Category');
- return <<_layout
+ ->createBlock('Mage_Backend_Block_Widget_Button')
+ ->setData(array(
+ 'id' => 'add_category_button',
+ 'label' => $newCategoryCaption,
+ 'title' => $newCategoryCaption,
+ 'onclick' => 'jQuery("#new-category").dialog("open")'
+ ));
+ $return = <<