A client has 20000+ products with 7 websites. They used to have 4 websites and most products are associated to 4 websites. What is the best & quickest way to iterate through the products and update the products to include the new websites.
I have the following code however it is far too slow:
$productCollection = Mage::getModel('catalog/product')->getCollection() ->addFieldToFilter('sku', array('like' => '02%')); foreach ($productCollection as $product) { echo $product->getSku(); $product->setWebsiteIds(array(1,2,3,4,5,6,7)); try { $product->save(); echo " - saved."; } catch (Exception $e) { echo ' - '.$e->getMessage(); } echo "\n"; }
I were thinking of using the iterator walk method however I understand that the store/website isn't exactly an attribute so it can't be easily updated on its own.