/**
* 添加关联商品到指定商品
*/
public function addRelatedProducts($product_id,$skus) {
$param = array();
foreach ($skus as $key=>$sku) {
$related_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
if ($related_product) {
$param[$related_product->getId()] = array('position'=>$key);
}
}
$product = Mage::getModel('catalog/product')->load($product_id);
if ($product) {
$product->setRelatedLinkData($param)->save();
return true;
}
return false;
}