Since this is a one time change you may wish to consider taking a SQL approach. This will be quicker, and, if you backup your database before hand, you can do this safely.
Your images for the categories are held in catalog_category_entity_varchar table however you did not say whether these are the main images or the thumbnails. Therefore have a quick search of the table to find out:
SELECT * FROM `catalog_category_entity_varchar` WHERE `value` LIKE '%.png%';
This should return images that you know. Look at the value for attribute_id. This could be something like '45'.
Now you want to run an update, replacing xx with your attribute_id:
UPDATE `catalog_category_entity_varchar` SET `value` = REPLACE(`value`, '.png', '.jpg') WHERE `attribute_id`=xx;
If you are not happy with updating the database directly in a few minutes you could write a Magento module, iterate on the categories and update the image accordingly. However, for a one off the sql approach should work out nicely.
Ok I think I got it.
Replacing..
$store = Mage::app()->getStore();
..with..
$store = Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
..seems to have done the trick.
Best Answer
I was digging through this today and it's not easy to untangle. The way smart categories have been designed did not take into account any easy way for their creation programmatically via a migration script.
The merchandiser data is completely compartmentalized from the category model and there are observers which listen for category saves in the admin and kick off merchandiser handlers which ingest the POST data from the visual merchandiser tab.
The added complexity lies in the data being store as serialized arrays in the database with the keys having been generated by the Magento backend.
For instance:
... where
smart_attributes
unserializes to...One (admitadly terrible) option might be to generate the smart category, and then use the data in a migration script that instantiates the
merchandiser/merchandiser
resource model and inserts it via theinsertCategoryValues
method. That's how the core handle it, at any rate (you can see it in action in:Which kicks off the
categorySaveAfter
method where the configured VM settings are stored.app/code/community/OnTap/Merchandiser/Model/Adminhtml/Observer::categorySaveAfter()
I have an email out to the OnTap team to see if they have any best-practice suggestions for handling the creation of VM rules for use in migration scripts. If they reply with anything useful, I'll post it here.