So I'm working on a CRUD module that creates entities based on an XML feed.
Right now, I'm using Magento system, so I have an array of data that I use to populate my object then call the save()
method for my entities. Code example:
foreach ($datas as $data) {
$entity = Mage::getModel('module/entity');
$entity->setData($data);
$entity->save();
}
Now, I want to know if there is a most efficient way of doing it (in terms of performance). Things that come to my mind are:
- Direct SQL queries ? Assuming I deal with one single table here.
- Collection walk method ? Just an idea I'm not sure if it's even possible but it would be something like populate a collection of data and use the walk iterator to generate the entities.
Feel free to provide a code example based on my snippet above.
Of course, this list is not exclusive, if you have more ideas I'd be willing to try them.