Creating New Magento Attribute Parameters

I'm having problems trying to create new settings on the Settings Management tab. When you create an attribute, I know how to save data in the database correctly. I am replacing it with Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Optionsmy module for creating custom fields.

My module:

config.xml

<config>
        <blocks>
            <adminhtml>
                <rewrite>
                     <catalog_product_attribute_edit_tabs>Ceicom_Swatches_Block_Adminhtml_Tabs</catalog_product_attribute_edit_tabs>
                     <catalog_product_attribute_edit_tab_options>Ceicom_Swatches_Block_Adminhtml_Options</catalog_product_attribute_edit_tab_options>
                 </rewrite>
             </adminhtml>
        </blocks>
</config>

Ceicom / Samples / block / Adminhtml / Options.php

class Ceicom_Swatches_Block_Adminhtml_Options extends Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options
{
    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('ceicom/attribute/options.phtml');
    }
}

in a Phtml file placed in user fields:

inserir a descrição da imagem aqui

Obviously, for this you need to add new columns to the table eav_attribute_option. For example]: field_1, field_2.

To save additional fields, I need to re-write: Mage_Eav_Model_Resource_Entity_Attribute::_saveOption().

Any tips on how to do this without changing CORE, as I already did, using rewrite, and how to load a data bank for input to edit an attribute?

+3
1

:

eav Mage_Eav_Model_Resource_Entity_Attribute, . , , _saveOption , Mage_Eav_Model_Resource_Entity_Attribute. , Mage_Eav_Model_Resource_Entity_Attribute , . , , Mage_Eav_Model_Resource_Entity_Attribute

:

  • Mage_Catalog_Model_Resource_Attribute
  • Mage_Eav_Model_Mysql4_Entity_Attribute
  • Mage_Eav_Model_Resource_Attribute ()

, :

1) , Mage_Eav_Model_Resource_Entity_Attribute

class My_Module_Model_Eav_Resource_Entity_Attribute extends Mage_Eav_Model_Resource_Entity_Attribute{ protected function _saveOption(Mage_Core_Model_Abstract $object){ //your custom logic here } }

Mage_Eav_Model_Resource_Entity_Attribute , Mage_Catalog_Model_Resource_Attribute, .

2) Mage_Catalog_Model_Resource_Attribute , My_Module_Model_Eav_Resource_Entity_Attribute

:

<global>
      <models>
            <!-- Overrides Mage_Catalog_Model_Resource_Attribute -->
            <catalog_resource>
                <rewrite>
                    <attribute>My_Module_Model_Catalog_Resource_Attribute</attribute>
                </rewrite>
            </catalog_resource>
        </models>
       <!-- The rest of global config section -->
</global>

, __saveOption .

+7

All Articles