Skip to content

Commit 2f84b68

Browse files
committed
MAGETWO-56063: After upgrading from 2.0.7 to 2.1, editing a category gives a 500 error
- skip loading of values for nonexistent attributes
1 parent 903dcbb commit 2f84b68

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Eav\Model\ResourceModel;
77

88
use Magento\Eav\Api\AttributeRepositoryInterface as AttributeRepository;
9+
use Magento\Framework\App\ObjectManager;
910
use Magento\Framework\EntityManager\MetadataPool;
1011
use Magento\Framework\Api\SearchCriteriaBuilder;
1112
use Magento\Framework\App\ResourceConnection as AppResource;
@@ -49,6 +50,11 @@ class ReadHandler implements AttributeInterface
4950
*/
5051
protected $scopeResolver;
5152

53+
/**
54+
* @var \Psr\Log\LoggerInterface
55+
*/
56+
private $logger;
57+
5258
/**
5359
* ReadHandler constructor.
5460
*
@@ -163,9 +169,30 @@ public function execute($entityType, $entityData, $arguments = [])
163169
\Magento\Framework\DB\Select::SQL_UNION_ALL
164170
);
165171
foreach ($connection->fetchAll($unionSelect) as $attributeValue) {
166-
$entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
172+
if (isset($attributesMap[$attributeValue['attribute_id']])) {
173+
$entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
174+
} else {
175+
$this->getLogger()->warning(
176+
"Attempt to load value of nonexistent EAV attribute '{$attributeValue['attribute_id']}'
177+
for entity type '$entityType'."
178+
);
179+
}
167180
}
168181
}
169182
return $entityData;
170183
}
184+
185+
/**
186+
* Get logger
187+
*
188+
* @return \Psr\Log\LoggerInterface
189+
* @deprecated
190+
*/
191+
private function getLogger()
192+
{
193+
if ($this->logger == null) {
194+
$this->logger = ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class);
195+
}
196+
return $this->logger;
197+
}
171198
}

0 commit comments

Comments
 (0)