Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI to Edit EAV Attributes & Sets - Category #2353

Closed
wants to merge 13 commits into from
3 changes: 3 additions & 0 deletions EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
| admin_user_authenticate_after | 1.9.4.5 |
| admin_user_authenticate_before | 1.9.4.5 |
| admin_user_validate | 1.9.4.5 |
| adminhtml_[entityCode]_attribute_types | 22.0.0 |
| adminhtml_[entityCode]_attribute_scopes | 22.0.0 |
| adminhtml_[entityCode]_attribute_edit_prepare_form | 22.0.0 |
| adminhtml_block_eav_attribute_edit_form_init | 1.9.4.5 |
| adminhtml_block_promo_widget_chooser_prepare_collection | 1.9.4.5 |
| adminhtml_block_salesrule_actions_prepareform | 1.9.4.5 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ protected function _getAdditionalElementTypes()
{
return array(
'image' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_category_helper_image'),
'textarea' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_helper_form_wysiwyg')
'textarea' => Mage::getConfig()->getBlockClassName('adminhtml/catalog_helper_form_wysiwyg'),
'boolean' => Mage::getConfig()->getBlockClassName('eav/adminhtml_helper_form_boolean'),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* OpenMage
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

require_once 'Mage/Eav/controllers/Adminhtml/Attribute/AbstractController.php';

/**
* Catalog category attribute controller
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
*/

class Mage_Adminhtml_Catalog_Category_AttributeController extends Mage_Eav_Adminhtml_Attribute_AbstractController
{
/**
* Additional initialization
*
*/
protected function _construct()
{
$this->_entityCode = Mage_Catalog_Model_Category::ENTITY;
}

protected function _initAction()
{
parent::_initAction();

$this->_title($this->__('Catalog'))
->_title($this->__('Attributes'))
->_title($this->__('Manage Category Attributes'));

$this->_setActiveMenu('catalog/attributes')
->_addBreadcrumb(
$this->__('Catalog'),
$this->__('Catalog')
)
->_addBreadcrumb(
$this->__('Manage Category Attributes'),
$this->__('Manage Category Attributes')
);

return $this;
}

protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/category_attributes');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* OpenMage
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

require_once 'Mage/Eav/controllers/Adminhtml/Set/AbstractController.php';

/**
* Catalog category attribute sets controller
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
*/

class Mage_Adminhtml_Catalog_Category_SetController extends Mage_Eav_Adminhtml_Set_AbstractController
{
/**
* Additional initialization
*
*/
protected function _construct()
{
$this->_entityCode = Mage_Catalog_Model_Category::ENTITY;
}

protected function _initAction()
{
parent::_initAction();

$this->_title($this->__('Catalog'))
->_title($this->__('Attributes'))
->_title($this->__('Manage Category Attribute Sets'));

$this->_setActiveMenu('catalog/attributes')
->_addBreadcrumb(
$this->__('Catalog'),
$this->__('Catalog')
)
->_addBreadcrumb(
$this->__('Manage Category Attribute Sets'),
$this->__('Manage Category Attribute Sets')
);

return $this;
}

protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/category_sets');
}

}
4 changes: 0 additions & 4 deletions app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@
*/
class Mage_Catalog_Model_Resource_Eav_Attribute extends Mage_Eav_Model_Entity_Attribute
{
const SCOPE_STORE = 0;
const SCOPE_GLOBAL = 1;
const SCOPE_WEBSITE = 2;

const MODULE_NAME = 'Mage_Catalog';
const ENTITY = 'catalog_eav_attribute';

Expand Down
22 changes: 18 additions & 4 deletions app/code/core/Mage/Catalog/etc/adminhtml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,21 @@
<title>Attributes</title>
<children>
<attributes translate="title" module="catalog">
<title>Manage Attributes</title>
<title>Manage Product Attributes</title>
<action>adminhtml/catalog_product_attribute/</action>
</attributes>
<sets translate="title" module="catalog">
<title>Manage Attribute Sets</title>
<title>Manage Product Attribute Sets</title>
<action>adminhtml/catalog_product_set/</action>
</sets>
<category_attributes translate="title" module="catalog">
<title>Manage Category Attributes</title>
<action>adminhtml/catalog_category_attribute/</action>
</category_attributes>
<category_sets translate="title" module="catalog">
<title>Manage Category Attribute Sets</title>
<action>adminhtml/catalog_category_set/</action>
</category_sets>
</children>
<sort_order>20</sort_order>
</attributes>
Expand Down Expand Up @@ -90,11 +98,17 @@
<title>Attributes</title>
<children>
<attributes translate="title">
<title>Manage Attributes</title>
<title>Manage Product Attributes</title>
</attributes>
<sets translate="title">
<title>Manage Attribute Sets</title>
<title>Manage Product Attribute Sets</title>
</sets>
<category_attributes translate="title">
<title>Manage Category Attributes</title>
</category_attributes>
<category_sets translate="title">
<title>Manage Category Attribute Sets</title>
</category_sets>
</children>
</attributes>
<categories translate="title">
Expand Down
49 changes: 49 additions & 0 deletions app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* OpenMage
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* @category Mage
* @package Mage_Eav
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Adminhtml attributes block
*
* @category Mage
* @package Mage_Eav
* @author Magento Core Team <core@magentocommerce.com>
*/

class Mage_Eav_Block_Adminhtml_Attribute extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_blockGroup = 'eav';
$this->_controller = 'adminhtml_attribute';
if ($entity_type = Mage::registry('entity_type')) {
$this->_headerText = Mage::helper('eav')->__('Manage %s Attributes', Mage::helper('eav')->formatTypeCode($entity_type));
} else {
$this->_headerText = Mage::helper('eav')->__('Manage Attributes');
}
$this->_addButtonLabel = Mage::helper('eav')->__('Add New Attribute');
parent::__construct();
}

public function getHeaderCssClass()
{
return 'icon-head head-eav-attribute';
}

}
81 changes: 81 additions & 0 deletions app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/**
* OpenMage
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* @category Mage
* @package Mage_Eav
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Mage_Eav_Block_Adminhtml_Attribute_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{

public function __construct()
{
$this->_objectId = 'attribute_id';
$this->_blockGroup = 'eav';
$this->_controller = 'adminhtml_attribute';

parent::__construct();

$this->_addButton(
'save_and_edit_button',
array(
'label' => Mage::helper('eav')->__('Save and Continue Edit'),
'onclick' => 'saveAndContinueEdit()',
'class' => 'save'
),
100
);

$this->_updateButton('save', 'label', Mage::helper('eav')->__('Save Attribute'));
$this->_updateButton('save', 'onclick', 'saveAttribute()');

if (!Mage::registry('entity_attribute')->getIsUserDefined()) {
$this->_removeButton('delete');
} else {
$this->_updateButton('delete', 'label', Mage::helper('eav')->__('Delete Attribute'));
}
}

public function getHeaderText()
{
if (Mage::registry('entity_attribute')->getId()) {
$frontendLabel = Mage::registry('entity_attribute')->getFrontendLabel();
if (is_array($frontendLabel)) {
$frontendLabel = $frontendLabel[0];
}
return Mage::helper('eav')->__('Edit %s Attribute "%s"', Mage::helper('eav')->formatTypeCode(Mage::registry('entity_type')), $this->escapeHtml($frontendLabel));
}
else {
return Mage::helper('eav')->__('New %s Attribute', Mage::helper('eav')->formatTypeCode(Mage::registry('entity_type')));
}
}

public function getValidationUrl()
{
return $this->getUrl('*/*/validate', array('_current'=>true));
}

public function getSaveUrl()
{
return $this->getUrl('*/*/save', array('_current'=>true, 'back'=>null));
}

public function getHeaderCssClass()
{
return 'icon-head head-eav-attribute';
}

}
30 changes: 30 additions & 0 deletions app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* OpenMage
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* @category Mage
* @package Mage_Eav
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Mage_Eav_Block_Adminhtml_Attribute_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
}
Loading