I have thousands of products which have some common default values:
page layout : No layout updates; Visibility:Not Visible Individually;
categoies: empty,
Now I want to change these three attributes once like below:
page layout : 1 column; Visibility:Catalog, Search (4); categoies: 1,
I tried to finish it with below code, but it is not working.
$collection = Mage::getResourceModel('catalog/product_collection')->load();
foreach($collection as $items)
{
$product = Mage::getModel('catalog/product')->load($items->getId());
$product->setVisibility(4);
$product->save();
echo $product->getId().'<br>';
}
Who can tell me what the problem is with my code?
I also tried to finish in database. But I do not know which table can control visibilibty, which table can control layout or category. (Using Magento 1.7)
You can do this directly from the admin area:
Catalog -> Manage Product
Check the article you want to edit and then select “Change attributes” from “Actions” drop down menu.
You can now massively change attribute to your product
Cheers