public function getAttributeOptions(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute)
    {
        $options = [];

        if ($attribute->usesSource()) {
            // should attribute has index (option value) instead of a label?
            $index = in_array($attribute->getAttributeCode(), $this->indexValueAttributes) ? 'value' : 'label';

            // only default (admin) store values used
            /** @var \Magento\Eav\Model\Entity\Attribute $attribute */
            $attribute->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID);

            try {
                foreach ($attribute->getSource()->getAllOptions(false) as $option) {
                    foreach (is_array($option['value']) ? $option['value'] : [$option] as $innerOption) {
                        if (strlen($innerOption['value'])) {
                            // skip ' -- Please Select -- ' option
                            $options[strtolower($innerOption['value'])] = (string)$innerOption[$index];
                        }
                    }
                }
            } catch (\Exception $e) {
                // ignore exceptions connected with source models
            }
        }

        return $options;
    }
public function getAttributeOptions(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute)
    {
        $options = [];

        if ($attribute->usesSource()) {
            // should attribute has index (option value) instead of a label?
            $index = in_array($attribute->getAttributeCode(), $this->indexValueAttributes) ? 'value' : 'label';

            // only default (admin) store values used
            /** @var \Magento\Eav\Model\Entity\Attribute $attribute */
            $attribute->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID);

            try {
                foreach ($attribute->getSource()->getAllOptions(false) as $option) {
                    foreach (is_array($option['value']) ? $option['value'] : [$option] as $innerOption) {
                        if (strlen($innerOption['value'])) {
                            // skip ' -- Please Select -- ' option
                            $options[strtolower($innerOption['value'])] = (string)$innerOption[$index];
                        }
                    }
                }
            } catch (\Exception $e) {
                // ignore exceptions connected with source models
            }
        }

        return $options;
    }
public function getAttributeOptions ( \ Magento \ Eav \ Model \ Entity \ Attribute \ AbstractAttribute $ attribute ) { $ options = [ ] ; if ( $ attribute -> usesSource ( ) ) { // should attribute has index (option value) instead of a label? $ index = in_array ( $ attribute -> getAttributeCode ( ) , $ this -> indexValueAttributes ) ? 'value' : 'label' ; // only default (admin) store values used /** @var \Magento\Eav\Model\Entity\Attribute $attribute */ $ attribute -> setStoreId ( \ Magento \ Store \ Model \ Store :: DEFAULT_STORE_ID ) ; try { foreach ( $ attribute -> getSource ( ) -> getAllOptions ( false ) as $ option ) { foreach ( is_array ( $ option [ 'value' ] ) ? $ option [ 'value' ] : [ $ option ] as $ innerOption ) { if ( strlen ( $ innerOption [ 'value' ] ) ) { // skip ' -- Please Select -- ' option $ options [ strtolower ( $ innerOption [ 'value' ] ) ] = ( string ) $ innerOption [ $ index ] ; } } } } catch ( \ Exception $ e ) { // ignore exceptions connected with source models } } return $ options ; }
Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.

@param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
@return array
Returns attributes all values in label - value or value - value pairs form . Labels are lower - cased .