Skip to main content
added 401 characters in body
Source Link
zhartaunik
  • 3.8k
  • 4
  • 24
  • 54

I think there is no problem and you do not need to load the $model again.

Sequence is following:

_beforeSave()

save() //model in not saved!!!

_afterSAve() //model is still not saved!!!

on afterSave dispatching some events such as 
    Mage::dispatchEvent('model_save_after', array('object'=>$this));
    Mage::dispatchEvent($this->_eventPrefix.'_save_after', $this->_getEventData());

commit() And only now magento save changes to database 

So you evend don't need to use method _afterSave() you can use one of events with following check:

if ($observer->getObject instanceof My_Module_Model_Price) {

upd.1 You have some non logical things. For example you named method getPrice(). In this method you need to receive smth. In your case better use name: applyPriceRanges(). And code for this method is following:

$this->setData('current_price', $this->getSpecialPrice())->setData( /* .... */ )->save()

and in _afterSave() method or in observer try to do your changes with your object.

I think there is no problem and you do not need to load the $model again.

Sequence is following:

_beforeSave()

save() //model in not saved!!!

_afterSAve() //model is still not saved!!!

on afterSave dispatching some events such as 
    Mage::dispatchEvent('model_save_after', array('object'=>$this));
    Mage::dispatchEvent($this->_eventPrefix.'_save_after', $this->_getEventData());

commit() And only now magento save changes to database 

So you evend don't need to use method _afterSave() you can use one of events with following check:

if ($observer->getObject instanceof My_Module_Model_Price) {

I think there is no problem and you do not need to load the $model again.

Sequence is following:

_beforeSave()

save() //model in not saved!!!

_afterSAve() //model is still not saved!!!

on afterSave dispatching some events such as 
    Mage::dispatchEvent('model_save_after', array('object'=>$this));
    Mage::dispatchEvent($this->_eventPrefix.'_save_after', $this->_getEventData());

commit() And only now magento save changes to database 

So you evend don't need to use method _afterSave() you can use one of events with following check:

if ($observer->getObject instanceof My_Module_Model_Price) {

upd.1 You have some non logical things. For example you named method getPrice(). In this method you need to receive smth. In your case better use name: applyPriceRanges(). And code for this method is following:

$this->setData('current_price', $this->getSpecialPrice())->setData( /* .... */ )->save()

and in _afterSave() method or in observer try to do your changes with your object.

added 2 characters in body
Source Link
zhartaunik
  • 3.8k
  • 4
  • 24
  • 54

I think there is no problem and you do not need to load the $model again.

Sequence is following:

_beforeSave()

save() //model in not saved!!!

_afterSAve() //model is still not saved!!!

on afterSave dispatching some events such as 
    Mage::dispatchEvent('model_save_after', array('object'=>$this));
    Mage::dispatchEvent($this->_eventPrefix.'_save_after', $this->_getEventData());

commit() And only now magento save changes into methoddatabase 

So you evend don't need to use method _afterSave() you can use one of events with following check:

if ($observer->getObject instanceof My_Module_Model_Price) {

I think there is no problem and you do not need to load the $model again.

Sequence is following:

_beforeSave()

save() //model in not saved!!!

_afterSAve() //model is still not saved!!!

on afterSave dispatching some events such as 
    Mage::dispatchEvent('model_save_after', array('object'=>$this));
    Mage::dispatchEvent($this->_eventPrefix.'_save_after', $this->_getEventData());

commit() And only now magento save changes in method 

So you evend don't need to use method _afterSave() you can use one of events with following check:

if ($observer->getObject instanceof My_Module_Model_Price) {

I think there is no problem and you do not need to load the $model again.

Sequence is following:

_beforeSave()

save() //model in not saved!!!

_afterSAve() //model is still not saved!!!

on afterSave dispatching some events such as 
    Mage::dispatchEvent('model_save_after', array('object'=>$this));
    Mage::dispatchEvent($this->_eventPrefix.'_save_after', $this->_getEventData());

commit() And only now magento save changes to database 

So you evend don't need to use method _afterSave() you can use one of events with following check:

if ($observer->getObject instanceof My_Module_Model_Price) {
Source Link
zhartaunik
  • 3.8k
  • 4
  • 24
  • 54

I think there is no problem and you do not need to load the $model again.

Sequence is following:

_beforeSave()

save() //model in not saved!!!

_afterSAve() //model is still not saved!!!

on afterSave dispatching some events such as 
    Mage::dispatchEvent('model_save_after', array('object'=>$this));
    Mage::dispatchEvent($this->_eventPrefix.'_save_after', $this->_getEventData());

commit() And only now magento save changes in method 

So you evend don't need to use method _afterSave() you can use one of events with following check:

if ($observer->getObject instanceof My_Module_Model_Price) {