Tag Archives: Source Model

Magento Create Attribute Source Model

1) Create the file app/code/local/Mage/Eav/Model/Entity/Attribute/Source/Cms.php and paste the code

<?php
class Mage_Eav_Model_Entity_Attribute_Source_Cms extends Mage_Eav_Model_Entity_Attribute_Source_Table{
public function getAllOptions($withEmpty = true){
if (!$this->_options) {
$options = array();
$options[] = array(
‘value’ => ‘0’,
‘label’ => ‘No’,
);
$options[] = array(
‘value’ => ‘1’,
‘label’ => ‘Yes’,
);
$this->_options = $options;
}
$options = $this->_options;

if ($withEmpty) {
array_unshift($options, array(
‘value’ => ”,
‘label’ => ‘Please Select’,
));
}

return $options;
}