| Conditions | 2 |
| Paths | 2 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 1 | public function toOptionArray() |
|
| 31 | { |
||
| 32 | // Load the ResourceModel with all the Attribute Collections (attribute sets in magento) |
||
| 33 | 1 | $collection = $this->objectManager->get(Collection::class); |
|
| 34 | |||
| 35 | // Filter on the Catalog_Product KEY_ENTITY_TYPE_ID which is 4 for products |
||
| 36 | 1 | $collection->addFieldToFilter(Set::KEY_ENTITY_TYPE_ID, 4); |
|
| 37 | |||
| 38 | // Load the items with the given filter (so all product attributes will be filtered) |
||
| 39 | 1 | $attributes = $collection->load()->getItems(); |
|
| 40 | |||
| 41 | // Empty array for the option array to return for the configuration source model in stockbase settings |
||
| 42 | 1 | $optionArray = []; |
|
| 43 | 1 | $optionArray[] = ['label' => '', 'value' => '']; |
|
| 44 | 1 | foreach ($attributes as $attribute) { |
|
| 45 | 1 | $optionArray[] = [ |
|
| 46 | 1 | 'label' => $attribute->getFrontendLabel(), |
|
| 47 | 1 | 'value' => $attribute->getAttributeCode(), |
|
| 48 | ]; |
||
| 49 | } |
||
| 50 | |||
| 51 | 1 | return $optionArray; |
|
| 52 | } |
||
| 53 | } |
||
| 54 |