I'm encountering the problem of the url key being unset and the visibility not retaining its original value when I'm retrieving a product collection, iterating through it to set a value per product, and then saving it as in the following:
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('type_id', 'configurable');
foreach ($products as $product) {
$product->setDescription('custom description');
$product->save();
}
However, if I add those attributes to be selected
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('url_key')
->addAttributeToSelect('visibility')
->addAttributeToFilter('type_id', 'configurable');
Then I'm able to save the product fine, and the url key and visibility retain their values.
A. Is this the correct way to handle this, or is there something else that I am supposed to set before I retrieve the collection?
B. Are there any other product attributes that have this same issue? (I didn't notice any other ones)
Thanks.