13
13
use Magento \Framework \Model \Entity \ScopeInterface ;
14
14
use Magento \Framework \EntityManager \Operation \AttributeInterface ;
15
15
use Magento \Eav \Model \Entity \AttributeCache ;
16
+ use Psr \Log \LoggerInterface ;
16
17
17
18
/**
18
19
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -49,6 +50,11 @@ class ReadHandler implements AttributeInterface
49
50
*/
50
51
protected $ scopeResolver ;
51
52
53
+ /**
54
+ * @var LoggerInterface
55
+ */
56
+ private $ logger ;
57
+
52
58
/**
53
59
* ReadHandler constructor.
54
60
*
@@ -58,21 +64,24 @@ class ReadHandler implements AttributeInterface
58
64
* @param AppResource $appResource
59
65
* @param ScopeResolver $scopeResolver
60
66
* @param AttributeCache $attributeCache
67
+ * @param LoggerInterface $logger
61
68
*/
62
69
public function __construct (
63
70
AttributeRepository $ attributeRepository ,
64
71
MetadataPool $ metadataPool ,
65
72
SearchCriteriaBuilder $ searchCriteriaBuilder ,
66
73
AppResource $ appResource ,
67
74
ScopeResolver $ scopeResolver ,
68
- AttributeCache $ attributeCache
75
+ AttributeCache $ attributeCache ,
76
+ LoggerInterface $ logger
69
77
) {
70
78
$ this ->attributeRepository = $ attributeRepository ;
71
79
$ this ->metadataPool = $ metadataPool ;
72
80
$ this ->searchCriteriaBuilder = $ searchCriteriaBuilder ;
73
81
$ this ->appResource = $ appResource ;
74
82
$ this ->scopeResolver = $ scopeResolver ;
75
83
$ this ->attributeCache = $ attributeCache ;
84
+ $ this ->logger = $ logger ;
76
85
}
77
86
78
87
/**
@@ -163,7 +172,14 @@ public function execute($entityType, $entityData, $arguments = [])
163
172
\Magento \Framework \DB \Select::SQL_UNION_ALL
164
173
);
165
174
foreach ($ connection ->fetchAll ($ unionSelect ) as $ attributeValue ) {
166
- $ entityData [$ attributesMap [$ attributeValue ['attribute_id ' ]]] = $ attributeValue ['value ' ];
175
+ if (isset ($ attributesMap [$ attributeValue ['attribute_id ' ]])) {
176
+ $ entityData [$ attributesMap [$ attributeValue ['attribute_id ' ]]] = $ attributeValue ['value ' ];
177
+ } else {
178
+ $ this ->logger ->warning (
179
+ "Attempt to load value of nonexistent EAV attribute ' {$ attributeValue ['attribute_id ' ]}'
180
+ for entity type ' $ entityType'. "
181
+ );
182
+ }
167
183
}
168
184
}
169
185
return $ entityData ;
0 commit comments