Mygento_Payture_Model_Source_List::toOptionArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 *
5
 *
6
 * @category Mygento
7
 * @package Mygento_Payture
8
 * @copyright 2017 NKS LLC. (https://www.mygento.ru)
9
 */
10
class Mygento_Payture_Model_Source_List
11
{
12
13
    public function getAllOptions()
14
    {
15
        $attributes = Mage::getModel('eav/config')->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection();
16
17
        $attributes->addFieldToFilter('main_table.frontend_input', ['neq' => 'hidden']);
18
        $attributes->addFieldToFilter('main_table.frontend_input', ['neq' => 'multiselect']);
19
        $attributes->addFieldToFilter('main_table.frontend_input', ['neq' => 'boolean']);
20
        $attributes->addFieldToFilter('main_table.frontend_input', ['neq' => 'date']);
21
        $attributes->addFieldToFilter('main_table.frontend_input', ['neq' => 'image']);
22
        $attributes->addFieldToFilter('main_table.frontend_input', ['neq' => 'price']);
23
        $attributes->addFieldToFilter('used_in_product_listing', '1');
24
25
        $attributes->setOrder('frontend_label', 'ASC');
26
27
        $_options = [];
28
29
        $_options[] = [
30
            'label' => Mage::helper('payture')->__('No usage'),
31
            'value' => 0
32
        ];
33
34
        foreach ($attributes as $attr) {
35
            $label = $attr->getStoreLabel() ? $attr->getStoreLabel() : $attr->getFrontendLabel();
36
            if ('' != $label) {
37
                $_options[] = ['label' => $label, 'value' => $attr->getAttributeCode()];
38
            }
39
        }
40
        return $_options;
41
    }
42
43
    public function toOptionArray()
44
    {
45
        return $this->getAllOptions();
46
    }
47
}
48