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

how to add related products to a product? 
 
abosalam
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2008-04-25
 

I am trying to add products, reading from xml file and save the products to Magento database, but I could not figure out how to add related products to the product I am adding.  Any Idea about how to add related products?
this this the code

$current_Product Mage::getModel('catalog/product')
        ->
setSku($sku)
        ->
setDeliverystatus($deliverystatus)
        ->
setDeliveryStatusMessage($deliverystatusmessage)
        ->
setStatus($enabled)
        ->
setWeight($weight)
        ->
setTaxClassId('Taxable Goods')
        ->
setSoldQuantity($soldquantity)
        ->
setReleaseDate($releasedate)
        ->
setName($title)
        ->
setSubtitle($subtitle)
        ->
setPublisherId($publisherid)
        ->
setProductUrl($url)
        ->
setProductType($producttype)
        ->
setNewSku($newsku)
        ->
setPrice(15.49)
        ->
setCategoryIds($categories_array)
        ->
setAttributeSetId(4)
        ->
setStoreId(2)
        ->
setDescription($longdescription)
        ->
setShortDescription($shortdescription)
        ->
setDeliverystatusmessage($deliverystatusmessage)
        ->
setProductType($producttype)
        ->
save();

->setRelatedProductIds($related_product_array_Ids) does not work? Any idea?
Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
tSpid3r
Jr. Member
 
Total Posts:  17
Joined:  2008-11-07
 

Although the post is quite old, I’m looking for a solution to this.

Any ideas?

Thanks!

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