diff --git a/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php b/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php index 6b32cc77188e8542ef31f8527c0f93a65dd14c64..723d05b92c5129f8d912acc133134bd38d789219 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php +++ b/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php @@ -13,6 +13,7 @@ use Magento\Framework\Model\Entity\ScopeResolver; use Magento\Framework\Model\Entity\ScopeInterface; use Magento\Framework\EntityManager\Operation\AttributeInterface; use Magento\Eav\Model\Entity\AttributeCache; +use Psr\Log\LoggerInterface; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -49,6 +50,11 @@ class ReadHandler implements AttributeInterface */ protected $scopeResolver; + /** + * @var LoggerInterface + */ + private $logger; + /** * ReadHandler constructor. * @@ -58,6 +64,7 @@ class ReadHandler implements AttributeInterface * @param AppResource $appResource * @param ScopeResolver $scopeResolver * @param AttributeCache $attributeCache + * @param LoggerInterface $logger */ public function __construct( AttributeRepository $attributeRepository, @@ -65,7 +72,8 @@ class ReadHandler implements AttributeInterface SearchCriteriaBuilder $searchCriteriaBuilder, AppResource $appResource, ScopeResolver $scopeResolver, - AttributeCache $attributeCache + AttributeCache $attributeCache, + LoggerInterface $logger ) { $this->attributeRepository = $attributeRepository; $this->metadataPool = $metadataPool; @@ -73,6 +81,7 @@ class ReadHandler implements AttributeInterface $this->appResource = $appResource; $this->scopeResolver = $scopeResolver; $this->attributeCache = $attributeCache; + $this->logger = $logger; } /** @@ -163,7 +172,14 @@ class ReadHandler implements AttributeInterface \Magento\Framework\DB\Select::SQL_UNION_ALL ); foreach ($connection->fetchAll($unionSelect) as $attributeValue) { - $entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value']; + if (isset($attributesMap[$attributeValue['attribute_id']])) { + $entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value']; + } else { + $this->logger->warning( + "Attempt to load value of nonexistent EAV attribute '{$attributeValue['attribute_id']}' + for entity type '$entityType'." + ); + } } } return $entityData;