Reputation: 611
for allow custom price there is just Yes/No but i wanna add "use config" option too like Apply Map select how can i do that ?
this is the attribute :
$setup->addAttribute('catalog_product', 'allow_customprice', array(
'group' => 'Prices',
'input' => 'select',
'label' => 'Allow Custom Price',
'source' => 'eav/entity_attribute_source_boolean',
'backend' => '',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'searchable' => 1,
'filterable' => 0,
'default' => 1,
'comparable' => 1,
'visible_on_front' => 1,
'visible_in_advanced_search' => 0,
'is_html_allowed_on_front' => 0,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
thats the system.xml :
<fields>
<enablecp translate="label">
<label>Enable Custom Price</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<comment>Option for all products.</comment>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</enablecp>
<!-- END FIELD -->
<minprice translate="label">
<label>Min Price</label>
<frontend_type>text</frontend_type>
<validate>validate-number</validate>
<comment>Min price for all products.</comment>
<sort_order>60</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</minprice>
<!-- END FIELD -->
</fields>
thats it thanks for advance
Upvotes: 0
Views: 1202
Reputation: 1259
In your attribute configuration you set the source model to eav/entity_attribute_source_boolean
. This class contains the following method which fills the option data:
public function getAllOptions()
{
if (is_null($this->_options)) {
$this->_options = array(
array(
'label' => Mage::helper('eav')->__('Yes'),
'value' => self::VALUE_YES
),
array(
'label' => Mage::helper('eav')->__('No'),
'value' => self::VALUE_NO
),
);
}
return $this->_options;
}
When you want to modify it create your own source class and extend it from Mage_Eav_Model_Entity_Attribute_Source_Abstract
.
EDIT:
You can take Mage_Catalog_Model_Product_Attribute_Source_Boolean
as your source. It contains the options:
So the source should be set to: catalog/product_attribute_source_boolean
Upvotes: 1