I have implemented the code to update existing products so that they get added to the new store website I have created.

    $websiteIds = array(1, 2);
    $skus = 'sku1, sku2';

    $skuArray = explode(',', $skus);

    $productIds = Mage::getResourceModel('catalog/product_collection')
            ->addFieldToFilter('sku', array('find_in_set' => $skuArray))

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

The code works well and adds these products to the other website too, but when the product is viewed, it does not display the Buy Now option, now when I Reindexed the URLs then it started displaying the Buy Now. Is it something I can do programatically when updating the products, because I will be having huge products on my live website and Indexing will also take a lot of time.


Try this:

$websiteIds = array(1, 2);
$skus = 'sku1,sku2,sku3';
$skuArray = explode(',', $skus);
foreach($skuArray as $sku) {
    $product = Mage::helper('catalog/product')->getProduct($sku);
    if($product->getId()) {
| improve this answer | |
  • I know this one, but there are huge number of products to be updated, and I am not going to update all products, say 75% of the products, if I do this all using Admin, it will only keep loading – Deepanshu Goyal Dec 21 '15 at 9:54
  • If you see the code I have provided, it does the same as you have mentioned – Deepanshu Goyal Dec 21 '15 at 9:55
  • updated ans pls check now – Abdul Dec 21 '15 at 10:17
  • Thanks for your answer. I am trying to find some other way too. I am trying to skip the looping thing. – Deepanshu Goyal Dec 21 '15 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.