-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathInstallData.php
More file actions
97 lines (86 loc) · 2.93 KB
/
InstallData.php
File metadata and controls
97 lines (86 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Magiccart
* @category Magiccart
* @copyright Copyright (c) 2014 Magiccart (http://www.magiccart.net/)
* @license http://www.magiccart.net/license-agreement.html
* @Author: DOng NGuyen<nguyen@dvn.com>
* @@Create Date: 2016-01-05 10:40:51
* @@Modify Date: 2016-02-29 11:35:11
* @@Function:
*/
namespace Magiccart\Magicmenu\Setup;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
/**
* Category setup factory
*
* @var CategorySetupFactory
*/
private $categorySetupFactory;
/**
* Init
*
* @param CategorySetupFactory $categorySetupFactory
*/
public function __construct(CategorySetupFactory $categorySetupFactory)
{
$this->categorySetupFactory = $categorySetupFactory;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var CategorySetup $categorySetup */
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
$categorySetup->addAttribute(
\Magento\Catalog\Model\Category::ENTITY,
'magic_label',
[
'group' => 'Magiccart',
'label' => 'Label',
'input' => 'text',
'type' => 'varchar',
'required' => false,
'frontend_class' => 'validate-length maximum-length-255',
'note' => 'Example: New,Hot,... Maximum 255 chars',
'sort_order' => 1,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
]
);
$categorySetup->addAttribute(
\Magento\Catalog\Model\Category::ENTITY,
'magic_thumbnail',
[
'group' => 'Magiccart',
'label' => 'Thumbnail',
'input' => 'image',
'type' => 'varchar',
'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image',
'required' => false,
'sort_order' => 2,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
]
);
$categorySetup->addAttribute(
\Magento\Catalog\Model\Category::ENTITY,
'magic_image',
[
'group' => 'Magiccart',
'label' => 'Image',
'input' => 'image',
'type' => 'varchar',
'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image',
'required' => false,
'sort_order' => 3,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
]
);
}
}