Mygento_Payture_Model_Source_List   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getAllOptions() 0 29 4
A toOptionArray() 0 4 1
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