I need to write to mysql database related products and upsells. This should be done by php. I can now set this for 1 product, but need to loop through all the products. My script:
<?php set_time_limit(0); require_once "blablabla/app/Mage.php";//my path here umask(0); Mage::app(); $sku="876297-6"; //some Sku $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku); $param = array( 101=>array( 'position'=>3 ), 102=>array( 'position'=>5 ) ); $_product->setRelatedLinkData($param); $_product->save(); echo "Great!!"; ?>
What I cannot do is the following:
1.Get all product IDs 2.For each product ID set a related product as a random product from collection
Position does not matter at all. + do this until there are 20 related products would be cool, but I can also run script 20 times, no pressure. Better to work with product IDs and not skus.
My script is just example. main purpose is to set 20 random related products to each product Thanks in advance!