tags:

views:

34

answers:

1

Hello,

I need to delete certain option value from an attribute, for example color. If color has red, blue and green as options, then I need to delete one of them, for example blue.

I have so far been able to get the attribute values but I am having problems deleting a particular option.

    $attribute_model        = Mage::getModel('eav/entity_attribute');
    $attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ;

    $attribute_code         = $attribute_model->getIdByCode('catalog_product', 'color_pattern');
    $attribute              = $attribute_model->load($attribute_code);

    $attribute_table        = $attribute_options_model->setAttribute($attribute);
    $options                = $attribute_options_model->getAllOptions(false);

How can I delete an option from the list of options? Any help will be appreciated.

Thanking you,

A: 

found a way to delete options through sql statement ;)

if(@unlink(Mage::getBaseDir('media') . DS ."sizecharts" . DS .$sizecharts->getFilename()))
                 {     

                 $select=$read->select()
               ->distinct(true)
               ->from($optionvalueTable,array('option_id'))
                ->where('value="'.$sizecharts->getFilename().'"'); 

                $opt1 = $read->fetchAll($select);
               $deleteCondition = $write->quoteInto('option_id=?', $opt1[0]['option_id']);
               $write->delete($optionTable, $deleteCondition);    
            //$model->setId($this->getRequest()->getParam('id'))
                $sizecharts->delete();

                 }
jarus