Skip to content

Commit 558ef07

Browse files
author
Sergey Shvets
committed
Merge branch '2.1.8-develop' of github.com:magento/magento2ce into MAGETWO-66276
2 parents 3795814 + 0ad9891 commit 558ef07

File tree

22 files changed

+728
-155
lines changed

22 files changed

+728
-155
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ If you are a new GitHub user, we recommend that you create your own [free github
2929
3. Create and test your work.
3030
4. Fork the Magento 2 repository according to [Fork a repository instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow [Create a pull request instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#pull_request).
3131
5. Once your contribution is received, Magento 2 development team will review the contribution and collaborate with you as needed to improve the quality of the contribution.
32+
33+
## Code of Conduct
34+
35+
Please note that this project is released with a Contributor Code of Conduct. We expect you to agree to its terms when participating in this project.
36+
The full text is available in the repository [Wiki](https://github.com/magento/magento2/wiki/Magento-Code-of-Conduct).

app/code/Magento/Catalog/Setup/UpgradeData.php

Lines changed: 61 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
*/
66
namespace Magento\Catalog\Setup;
77

8+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
9+
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
810
use Magento\Framework\Setup\UpgradeDataInterface;
911
use Magento\Framework\Setup\ModuleContextInterface;
1012
use Magento\Framework\Setup\ModuleDataSetupInterface;
1113
use Magento\Eav\Setup\EavSetup;
14+
use Magento\Eav\Setup\EavSetupFactory;
1215

1316
/**
1417
* Upgrade Data script
@@ -26,32 +29,20 @@ class UpgradeData implements UpgradeDataInterface
2629
/**
2730
* EAV setup factory
2831
*
29-
* @var \Magento\Eav\Setup\EavSetupFactory
32+
* @var EavSetupFactory
3033
*/
3134
private $eavSetupFactory;
3235

33-
/**
34-
* Attributes cache management.
35-
*
36-
* @var \Magento\Eav\Model\Entity\AttributeCache
37-
*/
38-
private $attributeCache;
39-
4036
/**
4137
* Init
4238
*
4339
* @param CategorySetupFactory $categorySetupFactory
44-
* @param \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
45-
* @param \Magento\Eav\Model\Entity\AttributeCache $attributeCache
40+
* @param EavSetupFactory $eavSetupFactory
4641
*/
47-
public function __construct(
48-
CategorySetupFactory $categorySetupFactory,
49-
\Magento\Eav\Setup\EavSetupFactory $eavSetupFactory,
50-
\Magento\Eav\Model\Entity\AttributeCache $attributeCache
51-
) {
42+
public function __construct(CategorySetupFactory $categorySetupFactory, EavSetupFactory $eavSetupFactory)
43+
{
5244
$this->categorySetupFactory = $categorySetupFactory;
5345
$this->eavSetupFactory = $eavSetupFactory;
54-
$this->attributeCache = $attributeCache;
5546
}
5647

5748
/**
@@ -96,7 +87,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
9687

9788
if (version_compare($context->getVersion(), '2.0.2') < 0) {
9889
// set new resource model paths
99-
/** @var CategorySetup $categorySetup */
90+
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
10091
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
10192
$categorySetup->updateEntityType(
10293
\Magento\Catalog\Model\Category::ENTITY,
@@ -137,157 +128,151 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
137128
}
138129

139130
if (version_compare($context->getVersion(), '2.0.3') < 0) {
140-
/** @var CategorySetup $categorySetup */
131+
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
141132
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
142133
$categorySetup->updateAttribute(3, 54, 'default_value', 1);
143134
}
144135

145136
if (version_compare($context->getVersion(), '2.0.4') < 0) {
146-
$mediaBackendType = 'static';
147-
$mediaBackendModel = null;
148-
/** @var CategorySetup $categorySetup */
137+
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
149138
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
150139
$categorySetup->updateAttribute(
151140
'catalog_product',
152141
'media_gallery',
153142
'backend_type',
154-
$mediaBackendType
143+
'static'
155144
);
156145
$categorySetup->updateAttribute(
157146
'catalog_product',
158147
'media_gallery',
159-
'backend_model',
160-
$mediaBackendModel
148+
'backend_model'
161149
);
162-
163-
$this->changeMediaGalleryAttributeInCache($mediaBackendType, $mediaBackendModel);
164150
}
165151

166152
if (version_compare($context->getVersion(), '2.0.5', '<')) {
167-
/** @var CategorySetup $categorySetup */
153+
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
168154
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
169155

170156
//Product Details tab
171157
$categorySetup->updateAttribute(
172-
\Magento\Catalog\Model\Product::ENTITY,
158+
ProductAttributeInterface::ENTITY_TYPE_CODE,
173159
'status',
174160
'frontend_label',
175161
'Enable Product',
176162
5
177163
);
178164
$categorySetup->updateAttribute(
179-
\Magento\Catalog\Model\Product::ENTITY,
165+
ProductAttributeInterface::ENTITY_TYPE_CODE,
180166
'name',
181167
'frontend_label',
182168
'Product Name'
183169
);
184-
$attributeSetId = $categorySetup->getDefaultAttributeSetId(\Magento\Catalog\Model\Product::ENTITY);
185170
$categorySetup->addAttributeToGroup(
186-
\Magento\Catalog\Model\Product::ENTITY,
187-
$attributeSetId,
171+
ProductAttributeInterface::ENTITY_TYPE_CODE,
172+
'Default',
188173
'Product Details',
189174
'visibility',
190175
80
191176
);
192177
$categorySetup->addAttributeToGroup(
193-
\Magento\Catalog\Model\Product::ENTITY,
194-
$attributeSetId,
178+
ProductAttributeInterface::ENTITY_TYPE_CODE,
179+
'Default',
195180
'Product Details',
196181
'news_from_date',
197182
90
198183
);
199184
$categorySetup->addAttributeToGroup(
200-
\Magento\Catalog\Model\Product::ENTITY,
201-
$attributeSetId,
185+
ProductAttributeInterface::ENTITY_TYPE_CODE,
186+
'Default',
202187
'Product Details',
203188
'news_to_date',
204189
100
205190
);
206191
$categorySetup->addAttributeToGroup(
207-
\Magento\Catalog\Model\Product::ENTITY,
208-
$attributeSetId,
192+
ProductAttributeInterface::ENTITY_TYPE_CODE,
193+
'Default',
209194
'Product Details',
210195
'country_of_manufacture',
211196
110
212197
);
213198

214199
//Content tab
215200
$categorySetup->addAttributeGroup(
216-
\Magento\Catalog\Model\Product::ENTITY,
217-
$attributeSetId,
201+
ProductAttributeInterface::ENTITY_TYPE_CODE,
202+
'Default',
218203
'Content',
219204
15
220205
);
221206
$categorySetup->updateAttributeGroup(
222-
\Magento\Catalog\Model\Product::ENTITY,
223-
$attributeSetId,
207+
ProductAttributeInterface::ENTITY_TYPE_CODE,
208+
'Default',
224209
'Content',
225210
'tab_group_code',
226211
'basic'
227212
);
228213
$categorySetup->addAttributeToGroup(
229-
\Magento\Catalog\Model\Product::ENTITY,
230-
$attributeSetId,
214+
ProductAttributeInterface::ENTITY_TYPE_CODE,
215+
'Default',
231216
'Content',
232217
'description'
233218
);
234219
$categorySetup->addAttributeToGroup(
235-
\Magento\Catalog\Model\Product::ENTITY,
236-
$attributeSetId,
220+
ProductAttributeInterface::ENTITY_TYPE_CODE,
221+
'Default',
237222
'Content',
238223
'short_description',
239224
100
240225
);
241226

242227
//Images tab
243228
$groupId = (int)$categorySetup->getAttributeGroupByCode(
244-
\Magento\Catalog\Model\Product::ENTITY,
245-
$attributeSetId,
229+
ProductAttributeInterface::ENTITY_TYPE_CODE,
230+
'Default',
246231
'image-management',
247232
'attribute_group_id'
248233
);
249234
$categorySetup->addAttributeToGroup(
250-
\Magento\Catalog\Model\Product::ENTITY,
251-
$attributeSetId,
235+
ProductAttributeInterface::ENTITY_TYPE_CODE,
236+
'Default',
252237
$groupId,
253238
'image',
254239
1
255240
);
256241
$categorySetup->updateAttributeGroup(
257-
\Magento\Catalog\Model\Product::ENTITY,
258-
$attributeSetId,
242+
ProductAttributeInterface::ENTITY_TYPE_CODE,
243+
'Default',
259244
$groupId,
260245
'attribute_group_name',
261246
'Images'
262247
);
263248
$categorySetup->updateAttribute(
264-
\Magento\Catalog\Model\Product::ENTITY,
249+
ProductAttributeInterface::ENTITY_TYPE_CODE,
265250
'image',
266251
'frontend_label',
267252
'Base'
268253
);
269254
$categorySetup->updateAttribute(
270-
\Magento\Catalog\Model\Product::ENTITY,
255+
ProductAttributeInterface::ENTITY_TYPE_CODE,
271256
'small_image',
272257
'frontend_label',
273258
'Small'
274259
);
275260
$categorySetup->updateAttribute(
276-
\Magento\Catalog\Model\Product::ENTITY,
261+
ProductAttributeInterface::ENTITY_TYPE_CODE,
277262
'image',
278263
'frontend_input_renderer',
279264
null
280265
);
281266

282267
//Design tab
283268
$categorySetup->updateAttribute(
284-
\Magento\Catalog\Model\Product::ENTITY,
269+
ProductAttributeInterface::ENTITY_TYPE_CODE,
285270
'page_layout',
286271
'frontend_label',
287272
'Layout'
288273
);
289274
$categorySetup->updateAttribute(
290-
\Magento\Catalog\Model\Product::ENTITY,
275+
ProductAttributeInterface::ENTITY_TYPE_CODE,
291276
'custom_layout_update',
292277
'frontend_label',
293278
'Layout Update XML',
@@ -296,70 +281,70 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
296281

297282
//Schedule Design Update tab
298283
$categorySetup->addAttributeGroup(
299-
\Magento\Catalog\Model\Product::ENTITY,
300-
$attributeSetId,
284+
ProductAttributeInterface::ENTITY_TYPE_CODE,
285+
'Default',
301286
'Schedule Design Update',
302287
55
303288
);
304289
$categorySetup->updateAttributeGroup(
305-
\Magento\Catalog\Model\Product::ENTITY,
306-
$attributeSetId,
290+
ProductAttributeInterface::ENTITY_TYPE_CODE,
291+
'Default',
307292
'Schedule Design Update',
308293
'tab_group_code',
309294
'advanced'
310295
);
311296
$categorySetup->addAttributeToGroup(
312-
\Magento\Catalog\Model\Product::ENTITY,
313-
$attributeSetId,
297+
ProductAttributeInterface::ENTITY_TYPE_CODE,
298+
'Default',
314299
'Schedule Design Update',
315300
'custom_design_from',
316301
20
317302
);
318303
$categorySetup->addAttributeToGroup(
319-
\Magento\Catalog\Model\Product::ENTITY,
320-
$attributeSetId,
304+
ProductAttributeInterface::ENTITY_TYPE_CODE,
305+
'Default',
321306
'Schedule Design Update',
322307
'custom_design_to',
323308
30
324309
);
325310
$categorySetup->updateAttribute(
326-
\Magento\Catalog\Model\Product::ENTITY,
311+
ProductAttributeInterface::ENTITY_TYPE_CODE,
327312
'custom_design',
328313
'frontend_label',
329314
'New Theme',
330315
40
331316
);
332317
$categorySetup->addAttributeToGroup(
333-
\Magento\Catalog\Model\Product::ENTITY,
334-
$attributeSetId,
318+
ProductAttributeInterface::ENTITY_TYPE_CODE,
319+
'Default',
335320
'Schedule Design Update',
336321
'custom_design'
337322
);
338323
$categorySetup->addAttribute(
339-
\Magento\Catalog\Model\Product::ENTITY,
324+
ProductAttributeInterface::ENTITY_TYPE_CODE,
340325
'custom_layout',
341326
[
342327
'type' => 'varchar',
343328
'label' => 'New Layout',
344329
'input' => 'select',
345-
'source' => \Magento\Catalog\Model\Product\Attribute\Source\Layout::class,
330+
'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Layout',
346331
'required' => false,
347332
'sort_order' => 50,
348-
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
333+
'global' => ScopedAttributeInterface::SCOPE_STORE,
349334
'group' => 'Schedule Design Update',
350335
'is_used_in_grid' => true,
351336
'is_visible_in_grid' => false,
352337
'is_filterable_in_grid' => false
353338
]
354339
);
355340
}
356-
341+
357342
if (version_compare($context->getVersion(), '2.0.7') < 0) {
358343
/** @var EavSetup $eavSetup */
359-
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
344+
$eavSetup= $this->eavSetupFactory->create(['setup' => $setup]);
360345

361346
$eavSetup->updateAttribute(
362-
\Magento\Catalog\Model\Product::ENTITY,
347+
ProductAttributeInterface::ENTITY_TYPE_CODE,
363348
'meta_description',
364349
[
365350
'note' => 'Maximum 255 chars. Meta Description should optimally be between 150-160 characters'
@@ -368,7 +353,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
368353
}
369354

370355
if (version_compare($context->getVersion(), '2.1.3') < 0) {
371-
/** @var CategorySetup $categorySetup */
356+
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
372357
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
373358
$this->changePriceAttributeDefaultScope($categorySetup);
374359
}
@@ -377,7 +362,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
377362
}
378363

379364
/**
380-
* @param CategorySetup $categorySetup
365+
* @param \Magento\Catalog\Setup\CategorySetup $categorySetup
381366
* @return void
382367
*/
383368
private function changePriceAttributeDefaultScope($categorySetup)
@@ -394,30 +379,4 @@ private function changePriceAttributeDefaultScope($categorySetup)
394379

395380
}
396381
}
397-
398-
/**
399-
* Change media_gallery attribute metadata in cache.
400-
*
401-
* @param string $mediaBackendType
402-
* @param string $mediaBackendModel
403-
* @return void
404-
*/
405-
private function changeMediaGalleryAttributeInCache($mediaBackendType, $mediaBackendModel)
406-
{
407-
// need to do, because media_gallery has backend model in cache.
408-
$catalogProductAttributes = $this->attributeCache->getAttributes(
409-
\Magento\Catalog\Model\Product::ENTITY,
410-
'0-0'
411-
);
412-
413-
if (is_array($catalogProductAttributes)) {
414-
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $catalogProductAttribute */
415-
foreach ($catalogProductAttributes as $catalogProductAttribute) {
416-
if ($catalogProductAttribute->getAttributeCode() == 'media_gallery') {
417-
$catalogProductAttribute->setBackendModel($mediaBackendModel);
418-
$catalogProductAttribute->setBackendType($mediaBackendType);
419-
}
420-
}
421-
}
422-
}
423382
}

0 commit comments

Comments
 (0)