@@ -63,7 +63,7 @@ public function __construct(
63
63
*/
64
64
public function getSelect (AbstractAttribute $ superAttribute , int $ productId )
65
65
{
66
- $ productLinkField = $ this ->metadataPool ->getMetadata (ProductInterface::class)-> getLinkField ( );
66
+ $ productMetadata = $ this ->metadataPool ->getMetadata (ProductInterface::class);
67
67
$ store = $ this ->storeManager ->getStore ();
68
68
69
69
$ select = $ this ->attributeResource ->getConnection ()->select ()->from (
@@ -75,18 +75,28 @@ public function getSelect(AbstractAttribute $superAttribute, int $productId)
75
75
'value_index ' => 'entity_value.value ' ,
76
76
'super_attribute_label ' => 'attribute_label.value ' ,
77
77
]
78
- )->joinInner (
79
- ['product_entity ' => $ this ->attributeResource ->getTable ('catalog_product_entity ' )],
80
- "product_entity. $ productLinkField = super_attribute.product_id " ,
81
- []
82
78
)->joinInner (
83
79
['product_link ' => $ this ->attributeResource ->getTable ('catalog_product_super_link ' )],
84
80
'product_link.parent_id = super_attribute.product_id ' ,
85
81
[]
82
+ )->joinInner (
83
+ ['product_entity ' => $ this ->attributeResource ->getTable ('catalog_product_entity ' )],
84
+ "product_entity. {$ productMetadata ->getLinkField ()} = super_attribute.product_id " ,
85
+ []
86
86
)->joinInner (
87
87
['attribute ' => $ this ->attributeResource ->getTable ('eav_attribute ' )],
88
88
'attribute.attribute_id = super_attribute.attribute_id ' ,
89
89
[]
90
+ )->joinLeft (
91
+ ['attribute_label ' => $ this ->attributeResource ->getTable ('catalog_product_super_attribute_label ' )],
92
+ implode (
93
+ ' AND ' ,
94
+ [
95
+ 'super_attribute.product_super_attribute_id = attribute_label.product_super_attribute_id ' ,
96
+ 'attribute_label.store_id = 0 ' ,
97
+ ]
98
+ ),
99
+ []
90
100
)->joinInner (
91
101
['entity ' => $ this ->attributeResource ->getTable ('catalog_product_entity ' )],
92
102
'entity.entity_id = product_link.product_id ' ,
@@ -96,7 +106,7 @@ public function getSelect(AbstractAttribute $superAttribute, int $productId)
96
106
implode (
97
107
' AND ' ,
98
108
[
99
- "entity_website.product_id = entity. $ productLinkField " ,
109
+ "entity_website.product_id = entity. { $ productMetadata -> getIdentifierField ()} " ,
100
110
"entity_website.website_id = {$ store ->getWebsiteId ()}" ,
101
111
]
102
112
),
@@ -108,17 +118,7 @@ public function getSelect(AbstractAttribute $superAttribute, int $productId)
108
118
[
109
119
'entity_value.attribute_id = super_attribute.attribute_id ' ,
110
120
'entity_value.store_id = 0 ' ,
111
- "entity_value. $ productLinkField = entity. $ productLinkField " ,
112
- ]
113
- ),
114
- []
115
- )->joinLeft (
116
- ['attribute_label ' => $ this ->attributeResource ->getTable ('catalog_product_super_attribute_label ' )],
117
- implode (
118
- ' AND ' ,
119
- [
120
- 'super_attribute.product_super_attribute_id = attribute_label.product_super_attribute_id ' ,
121
- 'attribute_label.store_id = 0 ' ,
121
+ "entity_value. {$ productMetadata ->getLinkField ()} = entity. {$ productMetadata ->getLinkField ()}" ,
122
122
]
123
123
),
124
124
[]
0 commit comments