Question

We have a multi-store with a bunch of products.

For certain categories in specific store views, I'd like to set all products to be in a particular store. Advice on how to achieve this would be greatly appreciated.

One of my biggest missing pieces is how to programmatically set the "Product in Stores" for each product -- I could probably figure out the rest from there. But yes, any thoughts would be appreciated.

Was it helpful?

Solution

You can easily assign products to different stores from adminpanel. Go to products grid catalog->products select all products or select selected products. Then click on actions dropdown from top left corner. Select Update Attribute then select websites. After that select specific store view's then save.

OTHER TIPS

For the sake of: If everyone every tries to google 'How to assign products to website or storeview programatically' Magento 1.9

Here's how, source from app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php

Use


//...
$actionModel = Mage::getSingleton('catalog/product_action');
$productIds  = $this->_getHelper()->getProductIds();

if ($websiteRemoveData) {
    $actionModel->updateWebsites($productIds, $websiteRemoveData, 'remove');
}
if ($websiteAddData) {
    $actionModel->updateWebsites($productIds, $websiteAddData, 'add');
}

Mage::dispatchEvent('catalog_product_to_website_change', array(
    'products' => $productIds
));
//...

Where the $websiteAddData and $websiteRemoveData is defined as followed

$websiteRemoveData  = $this->getRequest()->getParam('remove_website_ids', array());
$websiteAddData     = $this->getRequest()->getParam('add_website_ids', array());

Meaning, you will need to specify an array of website ids.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top