0
votes

I am fairly new, only about a week into magento. I guess there is a API and then a newwer API called mage?

So if you go to the admin page and click on Catalog -> Manage Products* and then clikc on a product. On the left hand side of the mangment page there are three things:

Related Products

Up-Sells

Cross-sells

I want to pull that info (by the SKU of the item.) and put it into a child site (That is going to be identical just need to push this over so they are the same on all the sites.).

Does this make sense? I want those three things from the Product information and then populate it on the same SKU on another site (as they will have the same info and SKU is the primary key for everything and will be the same)

1

1 Answers

0
votes

To get a product by SKU you can use the loadByAttribute() method as follows:

$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', 'PRODUCTSKU');

Once you have the product you can get the related items from the product. You can get the ID's of the related products:

$_relatedProducts = $_product->getRelatedItemIds();

This should return you an array of product ID's which you can then loop and get each product individually.

Retrieve upsell products by using:

$_product->getUpSellProductCollection()

As for cross sells - I am not entirely sure, but I think you can use

$_crossSells = $_product->getTypeInstance(true)->getAssociatedProducts($_product);