Skip to content

Add Select Attributes Values #2

@lewismcarey

Description

@lewismcarey

We've been implementing your controller methods - thank you.
I've been trying to add select attribute values programmatically:

public function installSelect($pkg) {

        // add a new set to page attr
        $selectSet  = $this->addAttributeSet('collection', 'my_selects', 'Selects', $pkg);        
        // set a new page attr key object
        $collectionKey = new CollectionKey;
        // create a select page attribute and add to the set
        $selectAttr = $this->addAttribute('my_new_select', 'My New Select', 'select', $collectionKey, $selectSet, $pkg, true);

        $optionValues = array('value1', 'value2', 'value3', 'value4');
        $options = array();
        $displayOrder = 0;
        $list = new SelectValueOptionList();
        foreach($optionValues as $value) {
            $opt = new SelectValueOption();
            $opt->setSelectAttributeOptionValue($value);
            $opt->setDisplayOrder($displayOrder);
            //$opt->setOptionList($list);
            $options[] = $opt;
            $displayOrder++;
        }      
        $type = $selectAttr->getController()->getAttributeKey()->getAttributeKeySettings();
        $list->setOptions($options);
        $type->setOptionList($list);        
    }

But can't seem to apply the Option List in atSelectOptions.avSelectOptionListID

I wonder if you have had any luck in this area?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions