Skip to content

Commit 06b9e44

Browse files
committed
MC-42666: GraphQL request returns configurable variants from ALL storeviews
1 parent f1f69be commit 06b9e44

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

app/code/Magento/ConfigurableProduct/Model/ResourceModel/Attribute/ScopedOptionSelectBuilder.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct(
6363
*/
6464
public function getSelect(AbstractAttribute $superAttribute, int $productId)
6565
{
66-
$productLinkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
66+
$productMetadata = $this->metadataPool->getMetadata(ProductInterface::class);
6767
$store = $this->storeManager->getStore();
6868

6969
$select = $this->attributeResource->getConnection()->select()->from(
@@ -75,18 +75,28 @@ public function getSelect(AbstractAttribute $superAttribute, int $productId)
7575
'value_index' => 'entity_value.value',
7676
'super_attribute_label' => 'attribute_label.value',
7777
]
78-
)->joinInner(
79-
['product_entity' => $this->attributeResource->getTable('catalog_product_entity')],
80-
"product_entity.$productLinkField = super_attribute.product_id",
81-
[]
8278
)->joinInner(
8379
['product_link' => $this->attributeResource->getTable('catalog_product_super_link')],
8480
'product_link.parent_id = super_attribute.product_id',
8581
[]
82+
)->joinInner(
83+
['product_entity' => $this->attributeResource->getTable('catalog_product_entity')],
84+
"product_entity.{$productMetadata->getLinkField()} = super_attribute.product_id",
85+
[]
8686
)->joinInner(
8787
['attribute' => $this->attributeResource->getTable('eav_attribute')],
8888
'attribute.attribute_id = super_attribute.attribute_id',
8989
[]
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+
[]
90100
)->joinInner(
91101
['entity' => $this->attributeResource->getTable('catalog_product_entity')],
92102
'entity.entity_id = product_link.product_id',
@@ -96,7 +106,7 @@ public function getSelect(AbstractAttribute $superAttribute, int $productId)
96106
implode(
97107
' AND ',
98108
[
99-
"entity_website.product_id = entity.$productLinkField",
109+
"entity_website.product_id = entity.{$productMetadata->getIdentifierField()}",
100110
"entity_website.website_id = {$store->getWebsiteId()}",
101111
]
102112
),
@@ -108,17 +118,7 @@ public function getSelect(AbstractAttribute $superAttribute, int $productId)
108118
[
109119
'entity_value.attribute_id = super_attribute.attribute_id',
110120
'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()}",
122122
]
123123
),
124124
[]

0 commit comments

Comments
 (0)