public function getOptionIds(Attribute $attribute, $labels)
    {
        $optionIds = [];

        if (!is_array($labels)) {
            $labels = [$labels];
        }

        $options = $attribute->getSource()->getAllOptions();

        foreach ($labels as $label) {
            foreach ($options as $option) {
                if ($option['label'] == $label) {
                    $optionIds[] = (int) $option['value'];
                }
            }
        }

        return $optionIds;
    }
public function getOptionIds(Attribute $attribute, $labels)
    {
        $optionIds = [];

        if (!is_array($labels)) {
            $labels = [$labels];
        }

        $options = $attribute->getSource()->getAllOptions();

        foreach ($labels as $label) {
            foreach ($options as $option) {
                if ($option['label'] == $label) {
                    $optionIds[] = (int) $option['value'];
                }
            }
        }

        return $optionIds;
    }
public function getOptionIds ( Attribute $ attribute , $ labels ) { $ optionIds = [ ] ; if ( ! is_array ( $ labels ) ) { $ labels = [ $ labels ] ; } $ options = $ attribute -> getSource ( ) -> getAllOptions ( ) ; foreach ( $ labels as $ label ) { foreach ( $ options as $ option ) { if ( $ option [ 'label' ] == $ label ) { $ optionIds [ ] = ( int ) $ option [ 'value' ] ; } } } return $ optionIds ; }
Retrive options ids from a labels array.

@param Attribute $attribute Attribute.
@param string[]  $labels    Labels

@return integer[]
Retrive options ids from a labels array .