I have a custom model and I want to add a validation in the _beforeSave()
method so that if it's a new object, and no customer_id
has been set, it shouldn't save the record at all. I did the validations on my pages but that doesn't keep other developers from doing something like:
$myModel = Mage::getModel("myModule/myModel");
$myModel->save();
This shouldn't happen because some values must be set before saving. I want something like:
public function _beforeSave()
{
parent::_beforeSave();
if($this->getCustomerId() <= 0)
{
#cancel save
}
return $this;
}
Can I cancel the save() method?