title: Copy products to all websites - Magento multi-store
body: <p>I am trying to copy my products from the first website I created to another 23 websites I added later in a multistore setup.
  I have this code which I thought should do the job:</p>
  
  <pre><code>$arr_stores = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24);
  $store_from = 1;  // first store id
  
  // get observer data and process each imported simple product - my products that need to be copied to     other websites
      $_event = $observer-&gt;getEvent();
      $_adapter = $_event-&gt;getAdapter();
  
      foreach($_adapter-&gt;getNewSku() as $sku =&gt; $value) {
  
          if($value['type_id'] == 'simple'){
              // load the next product - this loads product correctly
              $_product = Mage::getModel('catalog/product')-&gt;setStoreId($store_from)-&gt;load($value['entity_id']);
  
                     // set the websites
              $_product-&gt;setWebsiteIds($arr_stores);
              $_product-&gt;save();
  
                      // clear the var
              unset($_product);
  
          }
      }
  </code></pre>
  
  <p>however I am getting this error message:</p>
  
  <pre><code>SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`workoutlife`.`catalog_product_website`, CONSTRAINT `FK_CATALOG_PRODUCT_WEBSITE_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON DELET)
  </code></pre>
  
  <p>Can anyone tell me why this constraint may be failing?
  And why is ON DELET there? I am not trying to delete anything.
  TIA </p>