|
6 | 6 | namespace Magento\Eav\Model\ResourceModel;
|
7 | 7 |
|
8 | 8 | use Magento\Eav\Api\AttributeRepositoryInterface as AttributeRepository;
|
| 9 | +use Magento\Framework\App\ObjectManager; |
9 | 10 | use Magento\Framework\EntityManager\MetadataPool;
|
10 | 11 | use Magento\Framework\Api\SearchCriteriaBuilder;
|
11 | 12 | use Magento\Framework\App\ResourceConnection as AppResource;
|
@@ -49,6 +50,11 @@ class ReadHandler implements AttributeInterface
|
49 | 50 | */
|
50 | 51 | protected $scopeResolver;
|
51 | 52 |
|
| 53 | + /** |
| 54 | + * @var \Psr\Log\LoggerInterface |
| 55 | + */ |
| 56 | + private $logger; |
| 57 | + |
52 | 58 | /**
|
53 | 59 | * ReadHandler constructor.
|
54 | 60 | *
|
@@ -163,9 +169,30 @@ public function execute($entityType, $entityData, $arguments = [])
|
163 | 169 | \Magento\Framework\DB\Select::SQL_UNION_ALL
|
164 | 170 | );
|
165 | 171 | 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 | + } |
167 | 180 | }
|
168 | 181 | }
|
169 | 182 | return $entityData;
|
170 | 183 | }
|
| 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 | + } |
171 | 198 | }
|
0 commit comments