Is it possible to get a record of my model by another field of my model?
The normal way
$model = Mage::getModel('foo_bar/baz');
$model->load($id);
// do something with the loaded record
But i need something like this
$model = Mage::getModel('foo_bar/baz');
$model->loadByAnotherFieldOfModel($value)
// do something with the loaded record
is that possible?
$model = Mage::getModel('foo_bar/baz');
$model->load('field_value', 'field_name');
use this
$_category = Mage::getModel('catalog/category')->loadByAttribute('name', 'computer');
$_product = Mage::getModel('catalog/product')->loadByAttribute('name', 'hp2312');
// Load by SKU
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', 'computer123');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With