Skip to content

Commit 9130077

Browse files
author
Joan He
committed
MAGETWO-64218: Remove all usages/references of \Magento\Eav\Model\Entity\AttributeCache
- resolve merge conflict from commit f86aa0b
1 parent 3d2a4cd commit 9130077

File tree

1 file changed

+4
-41
lines changed

1 file changed

+4
-41
lines changed

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

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use Magento\Catalog\Api\Data\ProductAttributeInterface;
99
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
10-
use Magento\Eav\Model\Entity\AttributeCache;
1110
use Magento\Framework\Setup\UpgradeDataInterface;
1211
use Magento\Framework\Setup\ModuleContextInterface;
1312
use Magento\Framework\Setup\ModuleDataSetupInterface;
@@ -35,26 +34,16 @@ class UpgradeData implements UpgradeDataInterface
3534
*/
3635
private $eavSetupFactory;
3736

38-
/**
39-
* @var AttributeCache
40-
*/
41-
private $attributeCache;
42-
4337
/**
4438
* Init
4539
*
4640
* @param CategorySetupFactory $categorySetupFactory
4741
* @param EavSetupFactory $eavSetupFactory
48-
* @param AttributeCache $attributeCache
4942
*/
50-
public function __construct(
51-
CategorySetupFactory $categorySetupFactory,
52-
EavSetupFactory $eavSetupFactory,
53-
AttributeCache $attributeCache
54-
) {
43+
public function __construct(CategorySetupFactory $categorySetupFactory, EavSetupFactory $eavSetupFactory)
44+
{
5545
$this->categorySetupFactory = $categorySetupFactory;
5646
$this->eavSetupFactory = $eavSetupFactory;
57-
$this->attributeCache = $attributeCache;
5847
}
5948

6049
/**
@@ -146,24 +135,19 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
146135
}
147136

148137
if (version_compare($context->getVersion(), '2.0.4') < 0) {
149-
$mediaBackendType = 'static';
150-
$mediaBackendModel = null;
151138
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
152139
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
153140
$categorySetup->updateAttribute(
154141
'catalog_product',
155142
'media_gallery',
156143
'backend_type',
157-
$mediaBackendType
144+
'static'
158145
);
159146
$categorySetup->updateAttribute(
160147
'catalog_product',
161148
'media_gallery',
162-
'backend_model',
163-
$mediaBackendModel
149+
'backend_model'
164150
);
165-
166-
$this->changeMediaGalleryAttributeInCache($mediaBackendType, $mediaBackendModel);
167151
}
168152

169153
if (version_compare($context->getVersion(), '2.0.5', '<')) {
@@ -397,25 +381,4 @@ private function changePriceAttributeDefaultScope($categorySetup)
397381

398382
}
399383
}
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-
}
421384
}

0 commit comments

Comments
 (0)