5
5
*/
6
6
namespace Magento \Catalog \Model \ResourceModel ;
7
7
8
+ use Magento \Catalog \Api \Data \ProductInterface ;
8
9
use Magento \Catalog \Api \ProductRepositoryInterface ;
10
+ use Magento \Framework \EntityManager \MetadataPool ;
9
11
10
12
/**
11
13
* Test class for Catalog attribute resource model.
@@ -24,6 +26,11 @@ class AttributeTest extends \PHPUnit\Framework\TestCase
24
26
*/
25
27
protected $ productResource ;
26
28
29
+ /**
30
+ * @var MetadataPool
31
+ */
32
+ private $ metadataPool ;
33
+
27
34
/**
28
35
* @var \Magento\Framework\ObjectManagerInterface
29
36
*/
@@ -38,6 +45,7 @@ protected function setUp()
38
45
$ this ->productResource = $ this ->objectManager ->get (
39
46
\Magento \Catalog \Model \ResourceModel \Product::class
40
47
);
48
+ $ this ->metadataPool = $ this ->objectManager ->get (MetadataPool::class);
41
49
}
42
50
43
51
/**
@@ -125,11 +133,12 @@ private function getEavEntityAttributeRow($entityTypeId, $attributeSetId, $attri
125
133
*/
126
134
private function getProductAttributeValues ($ attributeId , $ productId , $ table )
127
135
{
136
+ $ linkField = $ this ->metadataPool ->getMetadata (ProductInterface::class)->getLinkField ();
128
137
$ connection = $ this ->productResource ->getConnection ();
129
138
$ select = $ connection ->select ()
130
139
->from ($ this ->productResource ->getTable ($ table ))
131
140
->where ('attribute_id=? ' , $ attributeId )
132
- ->where (' entity_id =? ' , $ productId );
141
+ ->where ($ linkField . ' =? ' , $ productId );
133
142
134
143
return $ connection ->fetchAll ($ select );
135
144
}
0 commit comments