I am having trouble figuring this out.
I want to add an additional field, after the store labels on a product attribute's options. So when I go to Catalog -> Attributes - Manage Attributes, choose to create a new attribute and choose dropdown (or multiselect) as the attribute type, and go to Manage Labels / Options, I want an additional field to appear next to each option.
So it would be display like below...
Admin | Default Store View | Custom Field 1 | Custom Field 2
Can anyone help me with this? I have tried creating a custom module, and creating a new attribute programmatically, and adding a custom source model, but it is not adding the additional label field as I had hoped.
Here is the setup file...
<?php
$this->startSetup();
//if you want to add the attribute to the category instead of the product change on the line below 'catalog_product' to 'catalog_category'
$this->addAttribute('catalog_product', 'buckle_builder_figure_list', array(
'group' => 'General',
'type' => 'text',
'backend' => 'eav/entity_attribute_backend_array',
'frontend_input' => '',
'frontend' => '',
'label' => 'Buckle Builder Figures',
'input' => 'multiselect',
'class' => '',
'source' => 'bucklebuilder/attribute_source_bucklebuilder',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,//can be SCOPE_WEBSITE or SCOPE_STORE
'visible' => true,
'used_in_product_listing' =>true, //can also be false
'frontend_class' => '',
'required' => false,//can be true
'user_defined' => true,
'default' => '',
'searchable' => false,//can be true
'filterable' => false,//can be true
'comparable' => false,//can be true
'visible_on_front' => false,//can be true
'unique' => false,
'position' => 60,//put any number here
));
$this->endSetup();
and here is the source model...
<?php
class Unleaded_BuckleBuilder_Model_Attribute_Source_BuckleBuilder extends Mage_Eav_Model_Entity_Attribute_Source_Abstract{
protected $_options = null;
public function getAllOptions($withEmpty = false){
if (is_null($this->_options)){
$this->_options = array();
//$this->_options[] = array('label'=>'HERE GOES THE LABEL', 'value'=>'HERE GOES THE VALUE');
//as example
$this->_options[] = array('label'=> $this->__('Figure Name'), value=>1);
$this->_options[] = array('label'=> $this->__('Figure SKU'), value=>2);
$this->_options[] = array('label'=> $this->__('Figure Style'), value=>3);
}
$options = $this->_options;
if ($withEmpty) {
array_unshift($options, array('value'=>'', 'label'=>''));
}
return $options;
}
public function getOptionText($value)
{
$options = $this->getAllOptions(false);
foreach ($options as $item) {
if ($item['value'] == $value) {
return $item['label'];
}
}
return false;
}
public function getFlatColums()
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$column = array(
'unsigned' => false,
'default' => null,
'extra' => null
);
if (Mage::helper('core')->useDbCompatibleMode()) {
$column['type'] = 'int(10)';
$column['is_null'] = true;
} else {
$column['type'] = Varien_Db_Ddl_Table::TYPE_TEXT;
$column['length'] = 10;
$column['nullable'] = true;
$column['comment'] = $attributeCode . ' column';
}
return array($attributeCode => $column);
}
public function getFlatUpdateSelect($store)
{
return Mage::getResourceModel('eav/entity_attribute')
->getFlatUpdateSelect($this->getAttribute(), $store);
}
}