Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AttributeOptions.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 
16 {
20  private $optionManager;
21 
25  public function __construct(
27  ) {
28  $this->optionManager = $optionManager;
29  }
30 
36  public function getData(int $entityType, string $attributeCode): array
37  {
38  $options = $this->optionManager->getItems($entityType, $attributeCode);
39 
40  $optionsData = [];
41  foreach ($options as $option) {
42  // without empty option @see \Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions
43  if ($option->getValue() === '') {
44  continue;
45  }
46 
47  $optionsData[] = [
48  'label' => $option->getLabel(),
49  'value' => $option->getValue()
50  ];
51  }
52  return $optionsData;
53  }
54 }
__construct(AttributeOptionManagementInterface $optionManager)
$attributeCode
Definition: extend.phtml:12