Magento – How to get the website Id’s a product is associated with

magento-1.7product

I can set the website ids against a product by adding 'websites' => array(1,2) to an array and saving the product. The problem is this overwrites all websites so if I only want to add a product to a website (without touching the rest) then I need to know which websites the product is associated with.

I tried $product->getWebsites() but websites isn't in the _data var of the product object so returns null.

Best Answer

$product->getWebsiteIds() 

should get you what you need.