Magento: Which is optimized way to get single record? [duplicate]
-
02-10-2020 - |
Вопрос
load by Id
$data = Mage::getModel('module_name/model)->load($id);
or
//collection by filter
$data = Mage::getModel('module_name/model)->getCollection()->addFieldToFilter('id',$id);
Решение
The proper method to get single record : Mage::getModel('module_name/model)->load($id);
If you use getCollection() then it will load all the record of that particular table and then it will filter the record from all collection.
While load() will fetch only single record from that table.
Не связан с magento.stackexchange