I am trying to run a script that creates additional product attribute in magento admin. However the attribute doesn't come out to the admin backend.
This is my model: Setup.php
class Rts_Cattribute_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
{
protected function _prepareValues($attr)
{
$data = parent::_prepareValues($attr);
$data = array_merge($data, array(
'apply_to' => $this->_getValue($attr, 'apply_to'),
'frontend_input_renderer' => $this->_getValue($attr, 'input_renderer'),
'is_comparable' => $this->_getValue($attr, 'comparable', 0),
'is_configurable' => $this->_getValue($attr, 'is_configurable', 1),
'is_filterable' => $this->_getValue($attr, 'filterable', 0),
'is_filterable_in_search' => $this->_getValue($attr, 'filterable_in_search', 0),
'is_global' => $this->_getValue(
$attr,
'global',
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE
),
'is_html_allowed_on_front' => $this->_getValue($attr, 'is_html_allowed_on_front', 0),
'is_searchable' => $this->_getValue($attr, 'searchable', 0),
'is_used_for_promo_rules' => $this->_getValue($attr, 'used_for_promo_rules', 0),
'is_visible' => $this->_getValue($attr, 'visible', 1),
'is_visible_on_front' => $this->_getValue($attr, 'visible_on_front', 1),
'is_wysiwyg_enabled' => $this->_getValue($attr, 'wysiwyg_enabled', 0),
'is_visible_in_advanced_search' => $this->_getValue($attr, 'visible_in_advanced_search', 0),
'position' => $this->_getValue($attr, 'position', 0),
'used_for_sort_by' => $this->_getValue($attr, 'used_for_sort_by', 0),
'used_in_product_listing' => $this->_getValue($attr, 'used_in_product_listing', 0)
));
return $data;
}
}
This is my config: config.xml
<config>
<modules>
<Rts_Cattribute>
<version>0.1.0</version>
</Rts_Cattribute>
</modules>
<global>
<resources>
<cattribute_setup>
<setup>
<module>Rts_Cattribute</module>
<class>Rts_Cattribute_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
</cattribute_setup>
</resources>
</global>
</config>
Lastly this is my install script: mysql4-install-0.1.0.php
$installer = $this;
$installer->startSetup();
$installer->addAttribute('catalog_product', 'max_ftlbs', array(
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Max Ft.Lbs',
'input' => 'text',
'class' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => false,
'required' => false,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'apply_to' => '',
'is_configurable' => false
));
$installer->endSetup();
I followed this tutorials
http://magento4newbies.blogspot.com/2015/01/how-to-adding-custom-product-attributes.html
http://codegento.com/2011/02/install-scripts-and-upgrade-scripts/
In this link Adding custom product attributes in Magento using setup script
it says that The standard class for magento installers is Mage_Eav_Model_Entity_Setup
but when dealing with products, you'll need to use Mage_Catalog_Model_Resource_Setup
instead.
I've tried many solution however it didn't work.
Everytime I do some changes I always delete the resource version before I refresh the page.
Problem:
The custom attribute won't show up or it is not created in the admin backend.
Question:
What is the right standard class for magento installer?
Is my installer correct?
I hope you can help me with this.