1 | <?php |
||
2 | |||
3 | namespace Pagantis\Pagantis\Setup; |
||
4 | |||
5 | use Magento\Framework\Setup\UpgradeDataInterface; |
||
6 | use Magento\Framework\Setup\ModuleContextInterface; |
||
7 | use Magento\Framework\Setup\ModuleDataSetupInterface; |
||
8 | use Pagantis\Pagantis\Helper\Config; |
||
9 | use Magento\Eav\Setup\EavSetupFactory; |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | class UpgradeData implements UpgradeDataInterface |
||
12 | { |
||
13 | /** Config tablename */ |
||
14 | const CONFIG_TABLE = 'Pagantis_config'; |
||
15 | |||
16 | /** Orders tablename */ |
||
17 | const ORDERS_TABLE = 'cart_process'; |
||
18 | |||
19 | /** @var Config */ |
||
20 | public $config; |
||
21 | |||
22 | /** @var string */ |
||
23 | public $code; |
||
24 | |||
25 | /** @var string */ |
||
26 | public $group; |
||
27 | |||
28 | /** @var string */ |
||
29 | public $label; |
||
30 | |||
31 | /** |
||
32 | * @var EavSetupFactory |
||
33 | */ |
||
34 | protected $eavSetupFactory; |
||
35 | |||
36 | /** |
||
37 | * UpgradeData constructor. |
||
38 | * |
||
39 | * @param Config $config |
||
40 | * @param EavSetupFactory $eavSetupFactory |
||
41 | */ |
||
42 | public function __construct(Config $config, EavSetupFactory $eavSetupFactory) |
||
43 | { |
||
44 | $this->config = $config; |
||
45 | $this->code = 'pagantis_promoted'; |
||
46 | $this->group = 'General'; |
||
47 | $this->label = 'Pagantis Promoted'; |
||
48 | $this->eavSetupFactory = $eavSetupFactory; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @param ModuleDataSetupInterface $setup |
||
53 | * @param ModuleContextInterface $context |
||
54 | */ |
||
55 | public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) |
||
56 | { |
||
57 | $setup->startSetup(); |
||
58 | $prefixedTableName = $setup->getConnection()->getTableName(self::CONFIG_TABLE); |
||
59 | $prefixedOrdersTableName = $setup->getConnection()->getTableName(self::ORDERS_TABLE); |
||
60 | if ($setup->tableExists($prefixedTableName)) { |
||
61 | if (version_compare($context->getVersion(), '8.3.1') < 0) { |
||
62 | $newConfigs = array( |
||
63 | /* INSERT NEW CONFIGS PARAMS HERE:'config'=>'<value>'*/ |
||
64 | 'PAGANTIS_DISPLAY_MAX_AMOUNT' => 0 |
||
65 | ); |
||
66 | foreach ($newConfigs as $config => $value) { |
||
67 | $setup->getConnection() |
||
68 | ->insert($prefixedTableName, array('config' => $config, 'value' => $value)); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | if (version_compare($context->getVersion(), '8.3.2') < 0) { |
||
73 | $newConfigs = array( |
||
74 | /* INSERT NEW CONFIGS PARAMS HERE:'config'=>'<value>'*/ |
||
75 | 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT' => 'sdk.simulator.types.CHECKOUT_PAGE' |
||
76 | ); |
||
77 | foreach ($newConfigs as $config => $value) { |
||
78 | $setup->getConnection() |
||
79 | ->insert($prefixedTableName, array('config' => $config, 'value' => $value)); |
||
80 | } |
||
81 | $setup->getConnection() |
||
82 | ->update( |
||
83 | $prefixedTableName, |
||
84 | array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), |
||
85 | "config='PAGANTIS_SIMULATOR_DISPLAY_TYPE'" |
||
86 | ); |
||
87 | |||
88 | } |
||
89 | |||
90 | if (version_compare($context->getVersion(), '8.6.0') < 0) { |
||
91 | $newConfigs = array( |
||
92 | /* INSERT NEW CONFIGS PARAMS HERE:'config'=>'<value>'*/ |
||
93 | 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x'=>0, |
||
94 | 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x'=>800, |
||
95 | 'PAGANTIS_TITLE_4x'=>'Until 4 installments, without fees', |
||
96 | 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION' => '' |
||
97 | ); |
||
98 | foreach ($newConfigs as $config => $value) { |
||
99 | $setup->getConnection() |
||
100 | ->insert($prefixedTableName, array('config' => $config, 'value' => $value)); |
||
101 | } |
||
102 | $setup->getConnection() |
||
103 | ->update( |
||
104 | $prefixedTableName, |
||
105 | array('value' => 'Instant financing'), |
||
106 | "config='PAGANTIS_TITLE'" |
||
107 | ); |
||
108 | } |
||
109 | |||
110 | if (version_compare($context->getVersion(), '8.6.1') < 0) { |
||
111 | if ($setup->tableExists($prefixedOrdersTableName)) { |
||
112 | $query = "ALTER TABLE $prefixedOrdersTableName ADD COLUMN token VARCHAR(32) NOT NULL AFTER order_id"; |
||
113 | $setup->getConnection()->query($query); |
||
114 | |||
115 | $query = "ALTER TABLE $prefixedOrdersTableName DROP PRIMARY KEY, ADD PRIMARY KEY(id, order_id)"; |
||
116 | $setup->getConnection()->query($query); |
||
117 | } |
||
118 | } |
||
119 | } |
||
120 | $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); |
||
121 | $eavSetup->addAttribute( |
||
122 | \Magento\Catalog\Model\Product::ENTITY, |
||
123 | $this->code, |
||
124 | [ |
||
125 | 'group' => $this->group, |
||
126 | 'type' => 'int', |
||
127 | 'backend' => '', |
||
128 | 'frontend' => '', |
||
129 | 'label' => $this->label, |
||
130 | 'input' => 'boolean', |
||
131 | 'class' => '', |
||
132 | 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', |
||
133 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, |
||
134 | 'visible' => true, |
||
135 | 'required' => false, |
||
136 | 'user_defined' => false, |
||
137 | 'default' => '0', |
||
138 | 'searchable' => false, |
||
139 | 'filterable' => false, |
||
140 | 'comparable' => false, |
||
141 | 'visible_on_front' => false, |
||
142 | 'used_in_product_listing' => false, |
||
143 | 'unique' => false, |
||
144 | 'apply_to' => '' |
||
145 | ] |
||
146 | ); |
||
147 | |||
148 | $setup->endSetup(); |
||
149 | } |
||
150 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths