5
5
*/
6
6
namespace Magento \Catalog \Setup ;
7
7
8
- use Magento \Catalog \Api \Data \ProductAttributeInterface ;
9
- use Magento \Eav \Model \Entity \Attribute \ScopedAttributeInterface ;
10
8
use Magento \Eav \Setup \EavSetup ;
11
- use Magento \Eav \Setup \EavSetupFactory ;
12
9
use Magento \Framework \Setup \ModuleContextInterface ;
13
10
use Magento \Framework \Setup \ModuleDataSetupInterface ;
14
11
use Magento \Framework \Setup \UpgradeDataInterface ;
@@ -30,7 +27,7 @@ class UpgradeData implements UpgradeDataInterface
30
27
/**
31
28
* EAV setup factory
32
29
*
33
- * @var EavSetupFactory
30
+ * @var \Magento\Eav\Setup\ EavSetupFactory
34
31
*/
35
32
private $ eavSetupFactory ;
36
33
@@ -43,12 +40,12 @@ class UpgradeData implements UpgradeDataInterface
43
40
* Constructor
44
41
*
45
42
* @param CategorySetupFactory $categorySetupFactory
46
- * @param EavSetupFactory $eavSetupFactory
43
+ * @param \Magento\Eav\Setup\ EavSetupFactory $eavSetupFactory
47
44
* @param UpgradeWidgetData $upgradeWidgetData
48
45
*/
49
46
public function __construct (
50
47
CategorySetupFactory $ categorySetupFactory ,
51
- EavSetupFactory $ eavSetupFactory ,
48
+ \ Magento \ Eav \ Setup \ EavSetupFactory $ eavSetupFactory ,
52
49
UpgradeWidgetData $ upgradeWidgetData
53
50
) {
54
51
$ this ->categorySetupFactory = $ categorySetupFactory ;
@@ -100,7 +97,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
100
97
101
98
if (version_compare ($ context ->getVersion (), '2.0.2 ' ) < 0 ) {
102
99
// set new resource model paths
103
- /** @var \Magento\Catalog\Setup\ CategorySetup $categorySetup */
100
+ /** @var CategorySetup $categorySetup */
104
101
$ categorySetup = $ this ->categorySetupFactory ->create (['setup ' => $ setup ]);
105
102
$ categorySetup ->updateEntityType (
106
103
\Magento \Catalog \Model \Category::ENTITY ,
@@ -141,69 +138,72 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
141
138
}
142
139
143
140
if (version_compare ($ context ->getVersion (), '2.0.3 ' ) < 0 ) {
144
- /** @var \Magento\Catalog\Setup\ CategorySetup $categorySetup */
141
+ /** @var CategorySetup $categorySetup */
145
142
$ categorySetup = $ this ->categorySetupFactory ->create (['setup ' => $ setup ]);
146
143
$ categorySetup ->updateAttribute (3 , 54 , 'default_value ' , 1 );
147
144
}
148
145
149
146
if (version_compare ($ context ->getVersion (), '2.0.4 ' ) < 0 ) {
150
- /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
147
+ $ mediaBackendType = 'static ' ;
148
+ $ mediaBackendModel = null ;
149
+ /** @var CategorySetup $categorySetup */
151
150
$ categorySetup = $ this ->categorySetupFactory ->create (['setup ' => $ setup ]);
152
151
$ categorySetup ->updateAttribute (
153
152
'catalog_product ' ,
154
153
'media_gallery ' ,
155
154
'backend_type ' ,
156
- ' static '
155
+ $ mediaBackendType
157
156
);
158
157
$ categorySetup ->updateAttribute (
159
158
'catalog_product ' ,
160
159
'media_gallery ' ,
161
- 'backend_model '
160
+ 'backend_model ' ,
161
+ $ mediaBackendModel
162
162
);
163
163
}
164
164
165
165
if (version_compare ($ context ->getVersion (), '2.0.5 ' , '< ' )) {
166
- /** @var \Magento\Catalog\Setup\ CategorySetup $categorySetup */
166
+ /** @var CategorySetup $categorySetup */
167
167
$ categorySetup = $ this ->categorySetupFactory ->create (['setup ' => $ setup ]);
168
168
169
169
//Product Details tab
170
170
$ categorySetup ->updateAttribute (
171
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
171
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
172
172
'status ' ,
173
173
'frontend_label ' ,
174
174
'Enable Product ' ,
175
175
5
176
176
);
177
177
$ categorySetup ->updateAttribute (
178
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
178
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
179
179
'name ' ,
180
180
'frontend_label ' ,
181
181
'Product Name '
182
182
);
183
- $ attributeSetId = $ categorySetup ->getDefaultAttributeSetId (ProductAttributeInterface:: ENTITY_TYPE_CODE );
183
+ $ attributeSetId = $ categorySetup ->getDefaultAttributeSetId (\ Magento \ Catalog \ Model \Product:: ENTITY );
184
184
$ categorySetup ->addAttributeToGroup (
185
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
185
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
186
186
$ attributeSetId ,
187
187
'Product Details ' ,
188
188
'visibility ' ,
189
189
80
190
190
);
191
191
$ categorySetup ->addAttributeToGroup (
192
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
192
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
193
193
$ attributeSetId ,
194
194
'Product Details ' ,
195
195
'news_from_date ' ,
196
196
90
197
197
);
198
198
$ categorySetup ->addAttributeToGroup (
199
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
199
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
200
200
$ attributeSetId ,
201
201
'Product Details ' ,
202
202
'news_to_date ' ,
203
203
100
204
204
);
205
205
$ categorySetup ->addAttributeToGroup (
206
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
206
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
207
207
$ attributeSetId ,
208
208
'Product Details ' ,
209
209
'country_of_manufacture ' ,
@@ -212,26 +212,26 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
212
212
213
213
//Content tab
214
214
$ categorySetup ->addAttributeGroup (
215
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
215
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
216
216
$ attributeSetId ,
217
217
'Content ' ,
218
218
15
219
219
);
220
220
$ categorySetup ->updateAttributeGroup (
221
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
221
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
222
222
$ attributeSetId ,
223
223
'Content ' ,
224
224
'tab_group_code ' ,
225
225
'basic '
226
226
);
227
227
$ categorySetup ->addAttributeToGroup (
228
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
228
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
229
229
$ attributeSetId ,
230
230
'Content ' ,
231
231
'description '
232
232
);
233
233
$ categorySetup ->addAttributeToGroup (
234
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
234
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
235
235
$ attributeSetId ,
236
236
'Content ' ,
237
237
'short_description ' ,
@@ -240,53 +240,53 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
240
240
241
241
//Images tab
242
242
$ groupId = (int )$ categorySetup ->getAttributeGroupByCode (
243
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
243
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
244
244
$ attributeSetId ,
245
245
'image-management ' ,
246
246
'attribute_group_id '
247
247
);
248
248
$ categorySetup ->addAttributeToGroup (
249
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
249
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
250
250
$ attributeSetId ,
251
251
$ groupId ,
252
252
'image ' ,
253
253
1
254
254
);
255
255
$ categorySetup ->updateAttributeGroup (
256
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
256
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
257
257
$ attributeSetId ,
258
258
$ groupId ,
259
259
'attribute_group_name ' ,
260
260
'Images '
261
261
);
262
262
$ categorySetup ->updateAttribute (
263
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
263
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
264
264
'image ' ,
265
265
'frontend_label ' ,
266
266
'Base '
267
267
);
268
268
$ categorySetup ->updateAttribute (
269
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
269
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
270
270
'small_image ' ,
271
271
'frontend_label ' ,
272
272
'Small '
273
273
);
274
274
$ categorySetup ->updateAttribute (
275
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
275
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
276
276
'image ' ,
277
277
'frontend_input_renderer ' ,
278
278
null
279
279
);
280
280
281
281
//Design tab
282
282
$ categorySetup ->updateAttribute (
283
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
283
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
284
284
'page_layout ' ,
285
285
'frontend_label ' ,
286
286
'Layout '
287
287
);
288
288
$ categorySetup ->updateAttribute (
289
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
289
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
290
290
'custom_layout_update ' ,
291
291
'frontend_label ' ,
292
292
'Layout Update XML ' ,
@@ -295,47 +295,47 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
295
295
296
296
//Schedule Design Update tab
297
297
$ categorySetup ->addAttributeGroup (
298
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
298
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
299
299
$ attributeSetId ,
300
300
'Schedule Design Update ' ,
301
301
55
302
302
);
303
303
$ categorySetup ->updateAttributeGroup (
304
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
304
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
305
305
$ attributeSetId ,
306
306
'Schedule Design Update ' ,
307
307
'tab_group_code ' ,
308
308
'advanced '
309
309
);
310
310
$ categorySetup ->addAttributeToGroup (
311
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
311
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
312
312
$ attributeSetId ,
313
313
'Schedule Design Update ' ,
314
314
'custom_design_from ' ,
315
315
20
316
316
);
317
317
$ categorySetup ->addAttributeToGroup (
318
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
318
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
319
319
$ attributeSetId ,
320
320
'Schedule Design Update ' ,
321
321
'custom_design_to ' ,
322
322
30
323
323
);
324
324
$ categorySetup ->updateAttribute (
325
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
325
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
326
326
'custom_design ' ,
327
327
'frontend_label ' ,
328
328
'New Theme ' ,
329
329
40
330
330
);
331
331
$ categorySetup ->addAttributeToGroup (
332
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
332
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
333
333
$ attributeSetId ,
334
334
'Schedule Design Update ' ,
335
335
'custom_design '
336
336
);
337
337
$ categorySetup ->addAttribute (
338
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
338
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
339
339
'custom_layout ' ,
340
340
[
341
341
'type ' => 'varchar ' ,
@@ -344,7 +344,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
344
344
'source ' => \Magento \Catalog \Model \Product \Attribute \Source \Layout::class,
345
345
'required ' => false ,
346
346
'sort_order ' => 50 ,
347
- 'global ' => ScopedAttributeInterface::SCOPE_STORE ,
347
+ 'global ' => \ Magento \ Eav \ Model \ Entity \ Attribute \ ScopedAttributeInterface::SCOPE_STORE ,
348
348
'group ' => 'Schedule Design Update ' ,
349
349
'is_used_in_grid ' => true ,
350
350
'is_visible_in_grid ' => false ,
@@ -358,7 +358,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
358
358
$ eavSetup = $ this ->eavSetupFactory ->create (['setup ' => $ setup ]);
359
359
360
360
$ eavSetup ->updateAttribute (
361
- ProductAttributeInterface:: ENTITY_TYPE_CODE ,
361
+ \ Magento \ Catalog \ Model \Product:: ENTITY ,
362
362
'meta_description ' ,
363
363
[
364
364
'note ' => 'Maximum 255 chars. Meta Description should optimally be between 150-160 characters '
@@ -367,7 +367,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
367
367
}
368
368
369
369
if (version_compare ($ context ->getVersion (), '2.1.3 ' ) < 0 ) {
370
- /** @var \Magento\Catalog\Setup\ CategorySetup $categorySetup */
370
+ /** @var CategorySetup $categorySetup */
371
371
$ categorySetup = $ this ->categorySetupFactory ->create (['setup ' => $ setup ]);
372
372
$ this ->changePriceAttributeDefaultScope ($ categorySetup );
373
373
}
@@ -386,7 +386,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
386
386
* Set to 'No' 'Is Allowed Html on Store Front' option on product name attribute, because product name
387
387
* is multi entity field (used in order, quote) and cannot be conditionally escaped in all places
388
388
*
389
- * @param ModuleDataSetupInterface $categorySetup
389
+ * @param ModuleDataSetupInterface $setup
390
390
* @return void
391
391
*/
392
392
private function dissallowUsingHtmlForProductName (ModuleDataSetupInterface $ setup )
@@ -405,7 +405,7 @@ private function dissallowUsingHtmlForProductName(ModuleDataSetupInterface $setu
405
405
}
406
406
407
407
/**
408
- * @param \Magento\Catalog\Setup\ CategorySetup $categorySetup
408
+ * @param CategorySetup $categorySetup
409
409
* @return void
410
410
*/
411
411
private function changePriceAttributeDefaultScope ($ categorySetup )
0 commit comments