I'm looking for creating a custom attribute for products, already have a CRUD module, with name and descriptions fields, so the names from my DB should be options of that attribute. How do I need to correct this code, so it will get values from my DB? Thanks everyone!
class Material extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
{
/**
* Get all options
* @return array
*/
public function getAllOptions()
{
if (!$this->_options) {
$this->_options = [
['label' => __('Cotton'), 'value' => 'cotton'],
['label' => __('Leather'), 'value' => 'leather'],
['label' => __('Silk'), 'value' => 'silk'],
['label' => __('Denim'), 'value' => 'denim'],
['label' => __('Fur'), 'value' => 'fur'],
['label' => __('Wool'), 'value' => 'wool'],
];
}
return $this->_options;
}
}