1

How can I get the list of products which have a specific product among their Up-Sells?

To be more specific, I'm getting a list of products with a specific attribute; I need to remove those products from the Up-Sells list across all the products in the Database, so, I'd like to filter the collection in some way.

Magento CE 1.9

1

Product relations are stored in the catalog_product_link table, where upsells are distinguished with link_type_id=4. You can look up the link types in catalog_product_link_type:

mysql> select * from  catalog_product_link_type;
+--------------+------------+
| link_type_id | code       |
+--------------+------------+
|            1 | relation   |
|            3 | super      |
|            4 | up_sell    |
|            5 | cross_sell |
+--------------+------------+

The linked product, i.e. the product in the upsell list is determined by linked_product_id.

To list the products, join the tablt to product collection using this column.

To be more specific, I'm getting a list of products with a specific attribute; I need to remove those products from the Up-Sells list across all the products in the Database

But it's good that you were more specific because this is much simpler. I assume it is a one time thing, so you can do it right away in MySQL:

DELETE FROM catalog_product_link WHERE linked_product_id IN ( [LIST] );

[LIST] can either be a comma separated list of product ids or a subquery in the form SELECT entity_id FROM catalog_product_entity [JOIN] [WHERE].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.