To add a new parameter for product attributes, you can create an extension that (1) adds a new column to the / eav _attribute directory table, and (2) places a field for the new parameter on the attribute edit page using an observer.
(1) Create a new DB field (is_visible_in_category_list)
Create an SQL script for your extension and add a new column. I would recommend using the catalog / eav_attribute table, but you could probably use eav_attribute:
$installer = $this; $installer->startSetup(); $table = $installer->getTable('catalog/eav_attribute'); $installer->getConnection()->addColumn( $table, 'is_visible_in_category_list', "TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'" ); $installer->getConnection()->addKey( $table, 'IDX_VISIBLE_IN_CATEGORY_LIST', 'is_visible_in_category_list' ); $installer->endSetup();
Here I also added an index for a faster query.
(2) Add a field to the product edit attribute page
The event is fired when preparing the attribute editing form, so let's watch it:
<events> <adminhtml_catalog_product_attribute_edit_prepare_form> <observers> <is_visible_in_category_list_observer> <class>mymodule/observer</class> <method>addVisibleInCategoryListAttributeField</method> </is_visible_in_category_list_observer> </observers> </adminhtml_catalog_product_attribute_edit_prepare_form> </events>
Then add a new field to the observer:
public function addVisibleInCategoryListAttributeField($observer) { $fieldset = $observer->getForm()->getElement('base_fieldset'); $attribute = $observer->getAttribute(); $fieldset->addField('is_visible_in_category_list', 'select', array( 'name' => 'is_visible_in_category_list', 'label' => Mage::helper('mymodule')->__('Visible in Category List'), 'title' => Mage::helper('mymodule')->__('Visible in Category List'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(), )); }
It's all. Saving settings from the edit page is automatically processed, since the field name in the form corresponds to the database field name.
Anders rasmussen
source share