|
7 | 7 |
|
8 | 8 | use Magento\Catalog\Api\Data\ProductAttributeInterface;
|
9 | 9 | use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
|
10 |
| -use Magento\Eav\Model\Entity\AttributeCache; |
11 | 10 | use Magento\Framework\Setup\UpgradeDataInterface;
|
12 | 11 | use Magento\Framework\Setup\ModuleContextInterface;
|
13 | 12 | use Magento\Framework\Setup\ModuleDataSetupInterface;
|
@@ -35,26 +34,16 @@ class UpgradeData implements UpgradeDataInterface
|
35 | 34 | */
|
36 | 35 | private $eavSetupFactory;
|
37 | 36 |
|
38 |
| - /** |
39 |
| - * @var AttributeCache |
40 |
| - */ |
41 |
| - private $attributeCache; |
42 |
| - |
43 | 37 | /**
|
44 | 38 | * Init
|
45 | 39 | *
|
46 | 40 | * @param CategorySetupFactory $categorySetupFactory
|
47 | 41 | * @param EavSetupFactory $eavSetupFactory
|
48 |
| - * @param AttributeCache $attributeCache |
49 | 42 | */
|
50 |
| - public function __construct( |
51 |
| - CategorySetupFactory $categorySetupFactory, |
52 |
| - EavSetupFactory $eavSetupFactory, |
53 |
| - AttributeCache $attributeCache |
54 |
| - ) { |
| 43 | + public function __construct(CategorySetupFactory $categorySetupFactory, EavSetupFactory $eavSetupFactory) |
| 44 | + { |
55 | 45 | $this->categorySetupFactory = $categorySetupFactory;
|
56 | 46 | $this->eavSetupFactory = $eavSetupFactory;
|
57 |
| - $this->attributeCache = $attributeCache; |
58 | 47 | }
|
59 | 48 |
|
60 | 49 | /**
|
@@ -146,24 +135,19 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
|
146 | 135 | }
|
147 | 136 |
|
148 | 137 | if (version_compare($context->getVersion(), '2.0.4') < 0) {
|
149 |
| - $mediaBackendType = 'static'; |
150 |
| - $mediaBackendModel = null; |
151 | 138 | /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
|
152 | 139 | $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
|
153 | 140 | $categorySetup->updateAttribute(
|
154 | 141 | 'catalog_product',
|
155 | 142 | 'media_gallery',
|
156 | 143 | 'backend_type',
|
157 |
| - $mediaBackendType |
| 144 | + 'static' |
158 | 145 | );
|
159 | 146 | $categorySetup->updateAttribute(
|
160 | 147 | 'catalog_product',
|
161 | 148 | 'media_gallery',
|
162 |
| - 'backend_model', |
163 |
| - $mediaBackendModel |
| 149 | + 'backend_model' |
164 | 150 | );
|
165 |
| - |
166 |
| - $this->changeMediaGalleryAttributeInCache($mediaBackendType, $mediaBackendModel); |
167 | 151 | }
|
168 | 152 |
|
169 | 153 | if (version_compare($context->getVersion(), '2.0.5', '<')) {
|
@@ -397,25 +381,4 @@ private function changePriceAttributeDefaultScope($categorySetup)
|
397 | 381 |
|
398 | 382 | }
|
399 | 383 | }
|
400 |
| - |
401 |
| - /** |
402 |
| - * @param string $mediaBackendType |
403 |
| - * @param string $mediaBackendModel |
404 |
| - * @return void |
405 |
| - */ |
406 |
| - private function changeMediaGalleryAttributeInCache($mediaBackendType, $mediaBackendModel) |
407 |
| - { |
408 |
| - // need to do, because media_gallery has backend model in cache. |
409 |
| - $catalogProductAttributes = $this->attributeCache->getAttributes('catalog_product', '0-0'); |
410 |
| - |
411 |
| - if (is_array($catalogProductAttributes)) { |
412 |
| - /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $catalogProductAttribute */ |
413 |
| - foreach ($catalogProductAttributes as $catalogProductAttribute) { |
414 |
| - if ($catalogProductAttribute->getAttributeCode() == 'media_gallery') { |
415 |
| - $catalogProductAttribute->setBackendModel($mediaBackendModel); |
416 |
| - $catalogProductAttribute->setBackendType($mediaBackendType); |
417 |
| - } |
418 |
| - } |
419 |
| - } |
420 |
| - } |
421 | 384 | }
|
0 commit comments