Skip to content

Commit 20ddc55

Browse files
authored
[MDEE-429] Enable product links (#286)
* [MDEE-429] Enable product links
1 parent 4364e4c commit 20ddc55

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

CatalogDataExporter/Model/Provider/Product/Links.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ public function get(array $values) : array
110110
private function formatLinkRow(array $row, array $linkTypes) : array
111111
{
112112
return [
113-
'productId' => $row['productId'],
114-
'position' => $row['position'],
115-
'qty' => $row['qty'],
116-
'type' => $linkTypes[$row['link_type_id']] ?? null,
113+
'sku' => $row['sku'],
114+
'type' => $linkTypes[$row['link_type_id']] ?? null
117115
];
118116
}
119117
}

CatalogDataExporter/Model/Query/ProductLinksQuery.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\App\ResourceConnection;
1212
use Magento\Framework\DB\Select;
1313
use Magento\Framework\DB\Sql\Expression;
14+
use Magento\GroupedProduct\Model\ResourceModel\Product\Link as GroupedProductLink;
1415

1516
/**
1617
* Product links query for catalog data exporter
@@ -130,24 +131,26 @@ public function getQuery(array $productIds, string $storeViewCode, int $linkType
130131
->where('cpe_parent.entity_id IN (?)', $productIds)
131132
->where('links.link_type_id IN (?)', $linkTypeId != null ? $linkTypeId : $this->linkTypes);
132133

133-
foreach ($this->getProductLinkAttributesData($linkTypeId) as $attributeData) {
134-
$tableAlias = \sprintf('attribute_%s', $attributeData['code']);
134+
if ($linkTypeId === GroupedProductLink::LINK_TYPE_GROUPED) {
135+
foreach ($this->getProductLinkAttributesData($linkTypeId) as $attributeData) {
136+
$tableAlias = \sprintf('attribute_%s', $attributeData['code']);
135137

136-
$select->joinLeft(
137-
[
138-
$tableAlias => $this->resourceConnection->getTableName(
139-
['catalog_product_link_attribute', $attributeData['data_type']]
138+
$select->joinLeft(
139+
[
140+
$tableAlias => $this->resourceConnection->getTableName(
141+
['catalog_product_link_attribute', $attributeData['data_type']]
142+
),
143+
],
144+
\sprintf(
145+
'%1$s.link_id = links.link_id AND %1$s.product_link_attribute_id IN (%2$s)',
146+
$tableAlias,
147+
$attributeData['attribute_ids']
140148
),
141-
],
142-
\sprintf(
143-
'%1$s.link_id = links.link_id AND %1$s.product_link_attribute_id IN (%2$s)',
144-
$tableAlias,
145-
$attributeData['attribute_ids']
146-
),
147-
[
148-
$attributeData['code'] => \sprintf('%s.value', $tableAlias),
149-
]
150-
);
149+
[
150+
$attributeData['code'] => \sprintf('%s.value', $tableAlias),
151+
]
152+
);
153+
}
151154
}
152155

153156
return $select;

CatalogDataExporter/etc/et_schema.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,14 @@
142142
<using field="productId" />
143143
<using field="storeViewCode" />
144144
</field>
145-
<!-- Disabling links as no service is using it right now, and some information might be missing -->
146-
<!--
145+
147146
<field name="links" type="Link" repeated="true"
148147
provider="Magento\CatalogDataExporter\Model\Provider\Product\Links"
149148
>
150149
<using field="productId" />
151150
<using field="storeViewCode" />
152151
</field>
153-
-->
152+
154153
</record>
155154

156155
<record name="Attribute">
@@ -319,10 +318,8 @@
319318
<field name="videoMetadata" type="String"/>
320319
</record>
321320
<record name="Link">
322-
<field name="productId" type="ID" />
323-
<field name="position" type="Int" />
321+
<field name="sku" type="String" />
324322
<field name="type" type="String" />
325-
<field name="qty" type="Float" />
326323
</record>
327324

328325

0 commit comments

Comments
 (0)