I'm using Magento (1.7) and I've just extended my old store (store1) with store2 by multi-store. I've a lot of products (about 1500) and they all are visible in Store1 but not in the new store (store2). Is there a easy way to enable all products for alle stores?
In the products grid in the admin, select all products with the 'select all' button. From the 'actions' dropdown menu; select 'Update Attributes'. In the 'Websites' tab; select the desired websites and click 'save'. Next, reindex all data:
Go to: System > Index Management.
Select all items and start reindexing by submitting the form.
There are a couple of ways to do this. First, and easiest, is to use the mass edit feature in the admin. Go to your manage products page, click select all, change the action dropdown to say "Change Attributes" and click submit. Then, on the websites tab, make sure your new site is checked in the "Add Product to Websites" area, and click save.
If you need to do this programatically and you have your website IDs, you can put something like this in a PHP script in your Magento root:
<?php
require_once('app/Mage.php');
umask(0);
Mage::app('admin');
$website_ids = array(1, 2); // I'm assuming your website IDs are 1 and 2.
// $website_ids = getWebsitesArray();
$product_collection = Mage::getModel('catalog/product')->getCollection();
foreach($product_collection as $product) {
$product->setWebsiteIds($website_ids);
$product->save();
}
And just for good measure, here's how to get that website_ids array programatically:
/* @return array */
function getWebsitesArray() {
$ret = array();
$website_collection = Mage::app()->getWebsites(true);
foreach($website_collection as $website) {
$ret = array_push($website->getId());
}
return $ret;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With