The following is how t0 get cross-sell and upsell products using SQL in Magento
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SELECT e.sku AS sku, Group_concat(ee.sku) AS crossel_product, Group_concat(eee.sku) AS upsell_product FROM catalog_product_link l INNER JOIN catalog_product_entity e ON e.entity_id = l.product_id LEFT JOIN catalog_product_entity ee ON ee.entity_id = l.linked_product_id AND l.link_type_id = 5 LEFT JOIN `catalog_product_entity` AS eee ON eee.entity_id = l.linked_product_id AND l.link_type_id = 4 GROUP BY e.sku; |
This can then be modified to filter by specific SKUs to check their association to one another by adding a simple where clause before grouping.