@@ -256,19 +256,36 @@ protected function _setItemAttributeValue($valueInfo)
256
256
$ valueInfo ['attribute_id ' ]
257
257
);
258
258
$ attributeCode = $ attribute ->getAttributeCode ();
259
- if ($ attribute ->getIsGlobal () === ScopedAttributeInterface::SCOPE_GLOBAL ) {
259
+ if ((int )$ attribute ->getIsGlobal () === ScopedAttributeInterface::SCOPE_GLOBAL ) {
260
+ $ entityLinkField = $ this ->getEntity ()->getLinkField ();
260
261
$ attributeTable = $ attribute ->getBackend ()->getTable ();
261
262
$ linkField = $ attribute ->getEntity ()->getLinkField ();
262
263
263
- $ select = $ this ->getConnection ()
264
- ->select ()
265
- ->from (['attr_table ' => $ attributeTable ], "attr_table.value " )
266
- ->where ("attr_table.attribute_id = ? " , $ valueInfo ['attribute_id ' ])
267
- ->where ("attr_table. {$ linkField } = ? " , $ entityId )
268
- ->where ('attr_table.store_id = ? ' , $ this ->getDefaultStoreId (), \Zend_Db::INT_TYPE );
269
- $ data = $ this ->getConnection ()->fetchOne ($ select );
270
- if ($ data ) {
271
- $ valueInfo ['value ' ] = $ data ;
264
+ $ select = $ this ->getConnection ()->select ()
265
+ ->from (
266
+ ['e ' => $ this ->getEntity ()->getEntityTable ()],
267
+ ['entity_id ' ]
268
+ )
269
+ ->join (
270
+ ['t_d ' => $ attributeTable ],
271
+ "e. {$ entityLinkField } = t_d. {$ linkField }" ,
272
+ ['t_d.value ' ]
273
+ )->where (
274
+ " e.entity_id = ? " ,
275
+ $ entityId ,
276
+ \Zend_Db::INT_TYPE
277
+ )->where (
278
+ 't_d.attribute_id = ? ' ,
279
+ $ attribute ->getAttributeId (),
280
+ \Zend_Db::INT_TYPE
281
+ )->where (
282
+ 't_d.store_id = ? ' ,
283
+ $ this ->getDefaultStoreId (),
284
+ \Zend_Db::INT_TYPE
285
+ );
286
+ $ data = $ this ->getConnection ()->fetchRow ($ select );
287
+ if ($ data && is_array ($ data )) {
288
+ $ valueInfo ['value ' ] = $ data ['value ' ];
272
289
}
273
290
}
274
291
0 commit comments