2014-05-15 75 views

回答

1

爲了一套相關的,你需要做以下 我們假設目前的產品是$ _產品(你做Mage::getModel('catalog/product')->load(SOME ID))

$_product->setRelatedLinkData($param); 

$param得到的是具有以下結構的陣列

$param = array(
$associatedProductId=>array(
'position'=>$associatedProductPosition 
) 
) 

下面是一個例子,假設您想在產品3和5的位置添加帶有101和102的產品作爲相關產品到$ _product。 您應該這樣做: S:

$param = array(
101=>array(
'position'=>3 
), 
102=>array(
'position'=>5 
) 
); 
$_product->setRelatedLinkData($param); 
//here ... some other product operations and in the end 
$_product->save(); 

使用foreach和添加/上面的代碼之間修改英寸

我希望這會幫助你實現你想要的。

出處:http://marius-strajeru.blogspot.in/2010/06/adding-related-products-up-sells-and.html

對於下面的鏈接瞭解更多信息的檢查。

http://magentotutorial.in/how-to-add-related-products-in-magento-by-code-script/

相關問題