Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Adding Multiple Items as Cross-sells via the DB? What’s the SQL Statement? Moshe! 
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

Moshe, or anyone else that might know how to do this..

I’d like to add the same 3-4 products as CROSS-SELLS to all other products in the DB. But rather doing it one by one through the Admin UI, isn’t this possible to do via the DB? Could I make a custom statement that will insert the ID of the products into the cross-sell column?  I’ll try to figure out the SQL syntax, but ANY help would be greatly appreciated.

Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

It would be a pretty tedious work to do it using direct sql statements…

You could take a look at catalog_product_link* tables to get an idea.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Hm.. actually it looks like i’m being stuck in previous incarnation of the structure.
It is not that hard as long as you have product entity_ids.

In catalog_product_link add records with these values:

insert into (product_idlinked_product_idlink_type_idvalues (@main_product_id, @cross_sell_product_id5);
where 5 is id for cross_sell type which is in catalog_product_link_type.

You could add optional position sort order in catalog_product_link_attribute_int, get IDs from catalog_product_link and catalog_product_link_attribute.

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

Moshe!  Thanks a bunch man, I’m heading home now to check this out. I’ll report back with updates in a few.

This might be useful, no?

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

Works Great. Still a little tedious.. but it’s better than doing it through the front end. Thanks Moshe! 

If you have time, Can you give me a bit of help of adding product data to the catalog listing screen? 

See this post:

http://www.magentocommerce.com/boards/viewthread/589/

As always.. you guys rock. Lemme know your thoughts.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

This should produce a little list of products where you added x-sell/related/up-sell item x on an ad-hoc basis:

SELECT *
FROM catalog_product_link where linked_product_id=x and link_type_id=y
GROUP BY product_id, linked_product_id, link_type_id
HAVING ( COUNT(product_id) > 1 )

You can delete these to keep the db tidy grin

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top