InstallData   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 79
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B install() 0 56 1
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * File: InstallData.php
7
 *
8
 * @author Bartosz Kubicki [email protected]>
9
 * @copyright Copyright (C) 2018 Lizard Media (http://lizardmedia.pl)
10
 */
11
12
namespace LizardMedia\ProductAttachment\Setup;
13
14
use \Magento\Catalog\Api\Data\ProductAttributeInterface;
15
use \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
16
use \Magento\Eav\Setup\EavSetupFactory;
17
use \Magento\Framework\Setup\InstallDataInterface;
18
use \Magento\Framework\Setup\ModuleContextInterface;
19
use \Magento\Framework\Setup\ModuleDataSetupInterface;
20
21
/**
22
 * Class InstallData
23
 * @package LizardMedia\ProductAttachment\Setup
24
 */
25
class InstallData implements InstallDataInterface
26
{
27
    /**
28
     * @var \Magento\Eav\Setup\EavSetupFactory
29
     */
30
    private $eavSetupFactory;
31
32
33
    /**
34
     * @param \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
35
     */
36
    public function __construct(EavSetupFactory $eavSetupFactory)
37
    {
38
        $this->eavSetupFactory = $eavSetupFactory;
39
    }
40
41
    /**
42
     * @param \Magento\Framework\Setup\ModuleDataSetupInterface $setup
43
     * @param \Magento\Framework\Setup\ModuleContextInterface $context
44
     *
45
     * @return void
46
     */
47
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
48
    {
49
        /** @var \Magento\Eav\Setup\EavSetup $eavSetup */
50
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
51
52
        $eavSetup->addAttribute(
53
            ProductAttributeInterface::ENTITY_TYPE_CODE,
54
            'attachments_title',
55
            [
56
                'type' => 'varchar',
57
                'input' => 'text',
58
                'frontend_class' => 'validate-no-html-tags validate-length maximum-length-255',
59
                'label' => 'Attachments title',
60
61
                'group' => 'product-details',
62
                'sort_order' => 115,
63
64
65
                'backend' => '',
66
                'frontend' => '',
67
                'source' => '',
68
69
                'default' => null,
70
71
                'wysiwyg_enabled' => false,
72
                'is_html_allowed_on_front' => false,
73
74
                'used_for_sort_by' => false,
75
76
                'global' => ScopedAttributeInterface::SCOPE_STORE,
77
                'visible' => false,
78
                'required' => false,
79
                'user_defined' => false,
80
81
                'searchable' => false,
82
                'visible_in_advanced_search' => false,
83
                'search_weight' => '',
84
                'filterable' => false,
85
                'filterable_in_search' => false,
86
                'comparable' => false,
87
                'visible_on_front' => false,
88
                'used_in_product_listing' => false,
89
                'unique' => false,
90
                'apply_to' => '',
91
                'used_for_promo_rules' => false,
92
93
                'is_used_in_grid' => false,
94
                'is_visible_in_grid' => false,
95
                'is_filterable_in_grid' => false,
96
97
                'is_required_in_admin_store' => '',
98
99
                'system' => 0
100
            ]
101
        );
102
    }
103
}
104