Bulk update products to include new websites

Step 1
Build an array with your new website ids.

$websiteIds = array(5,6,7);

Step 2
Now get all the product ids.

$productIds= Mage::getResourceModel('catalog/product_collection')->getAllIds();

Step 3
Assign all the products to the new websites:

Mage::getModel('catalog/product_website')->addProducts($websiteIds, $productIds);

Step 4
Feel good about yourself.


If you only want to add the products that are assigned to all 4 previously existing websites, use this:

$oldWebsiteIds = [2, 3, 4, 5];
$newWebsiteIds = [6, 7, 8]

/** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
$productCollection = Mage::getResourceModel('catalog/product_collection');
$productCollection->addWebsiteFilter($oldWebsiteIds );
// only filter products present in ALL of the websites
$productCollection->getSelect()
    ->having('COUNT(website_id) = ?', count($oldWebsiteIds))
    ->distinct(false)
    ->group('e.entity_id');
$productIds = $productCollection->getAllIds();

Mage::getModel('catalog/product_website')->addProducts($newWebsiteIds, $productIds);

See also: Filter products by website using AND

This can be a Magento setup script or a throwaway PHP script (in this case add include 'app/Mage.php'; at the top and remove it from the server after usage)


Another solution if your laziness goes to the point of not wanting to create any PHP files:

INSERT IGNORE INTO catalog_product_website
SELECT entity_id, {website_id} FROM catalog_product_entity

Worked for me.