Always update on duplicate when using save() in custom model
-
31-10-2019 - |
質問
I have a custom model linked to a custom table. In that table, the column sku is unique. I'd like the following code to always update on duplicate:
Mage::getModel('company/product_log')
->setData('sku', 'abc123')
->setData('error', 'Invalid price.')
->save();
I'd like to do this from within the model itself instead of having to repeat update-vs-insert logic everywhere I want to use this table.
What is the best way to do this, or an existing example already in Magento?
正しい解決策はありません
所属していません magento.stackexchange