Skip to main content
added 8 characters in body
Source Link

Yes, definitely, if you check the save function of Mage_Core_Model_Abstract you can see this:

public function save()
{
    /**
     * Direct deleted items to delete method
     */
    if ($this->isDeleted()) {
        return $this->delete();
    }
    if (!$this->_hasModelChanged()) {
        return $this;
    }
    $this->_getResource()->beginTransaction();
    $dataCommited = false;
    try {
        $this->_beforeSave();
        if ($this->_dataSaveAllowed) {
            $this->_getResource()->save($this);
            $this->_afterSave();
        }
        $this->_getResource()->addCommitCallback(array($this, 'afterCommitCallback'))
            ->commit();
        $this->_hasDataChanges = false;
        $dataCommited = true;
    } catch (Exception $e) {
        $this->_getResource()->rollBack();
        $this->_hasDataChanges = true;
        throw $e;
    }
    if ($dataCommited) {
        $this->_afterSaveCommit();
    }
    return $this;
}

This line: $this->_beforeSave(); triggers the following events:

  • model_save_beforemodel_save_before
  • $this->_eventPrefix.'_save_before'$this->_eventPrefix.'_save_before' where the event prefix depends on your model. In your case, it is 'catalog_product'catalog_product

On the other hand, this line: $this->_afterSave() triggers the following events:

  • model_save_aftermodel_save_after
  • $this->_eventPrefix.'_save_after'$this->_eventPrefix.'_save_after' (same remark as before)

Yes, definitely, if you check the save function of Mage_Core_Model_Abstract you can see this:

public function save()
{
    /**
     * Direct deleted items to delete method
     */
    if ($this->isDeleted()) {
        return $this->delete();
    }
    if (!$this->_hasModelChanged()) {
        return $this;
    }
    $this->_getResource()->beginTransaction();
    $dataCommited = false;
    try {
        $this->_beforeSave();
        if ($this->_dataSaveAllowed) {
            $this->_getResource()->save($this);
            $this->_afterSave();
        }
        $this->_getResource()->addCommitCallback(array($this, 'afterCommitCallback'))
            ->commit();
        $this->_hasDataChanges = false;
        $dataCommited = true;
    } catch (Exception $e) {
        $this->_getResource()->rollBack();
        $this->_hasDataChanges = true;
        throw $e;
    }
    if ($dataCommited) {
        $this->_afterSaveCommit();
    }
    return $this;
}

This line: $this->_beforeSave(); triggers the following events:

  • model_save_before
  • $this->_eventPrefix.'_save_before' where the event prefix depends on your model. In your case, it is 'catalog_product'

On the other hand, this line: $this->_afterSave() triggers the following events:

  • model_save_after
  • $this->_eventPrefix.'_save_after' (same remark as before)

Yes, definitely, if you check the save function of Mage_Core_Model_Abstract you can see this:

public function save()
{
    /**
     * Direct deleted items to delete method
     */
    if ($this->isDeleted()) {
        return $this->delete();
    }
    if (!$this->_hasModelChanged()) {
        return $this;
    }
    $this->_getResource()->beginTransaction();
    $dataCommited = false;
    try {
        $this->_beforeSave();
        if ($this->_dataSaveAllowed) {
            $this->_getResource()->save($this);
            $this->_afterSave();
        }
        $this->_getResource()->addCommitCallback(array($this, 'afterCommitCallback'))
            ->commit();
        $this->_hasDataChanges = false;
        $dataCommited = true;
    } catch (Exception $e) {
        $this->_getResource()->rollBack();
        $this->_hasDataChanges = true;
        throw $e;
    }
    if ($dataCommited) {
        $this->_afterSaveCommit();
    }
    return $this;
}

This line: $this->_beforeSave(); triggers the following events:

  • model_save_before
  • $this->_eventPrefix.'_save_before' where the event prefix depends on your model. In your case, it is catalog_product

On the other hand, this line: $this->_afterSave() triggers the following events:

  • model_save_after
  • $this->_eventPrefix.'_save_after' (same remark as before)
Source Link

Yes, definitely, if you check the save function of Mage_Core_Model_Abstract you can see this:

public function save()
{
    /**
     * Direct deleted items to delete method
     */
    if ($this->isDeleted()) {
        return $this->delete();
    }
    if (!$this->_hasModelChanged()) {
        return $this;
    }
    $this->_getResource()->beginTransaction();
    $dataCommited = false;
    try {
        $this->_beforeSave();
        if ($this->_dataSaveAllowed) {
            $this->_getResource()->save($this);
            $this->_afterSave();
        }
        $this->_getResource()->addCommitCallback(array($this, 'afterCommitCallback'))
            ->commit();
        $this->_hasDataChanges = false;
        $dataCommited = true;
    } catch (Exception $e) {
        $this->_getResource()->rollBack();
        $this->_hasDataChanges = true;
        throw $e;
    }
    if ($dataCommited) {
        $this->_afterSaveCommit();
    }
    return $this;
}

This line: $this->_beforeSave(); triggers the following events:

  • model_save_before
  • $this->_eventPrefix.'_save_before' where the event prefix depends on your model. In your case, it is 'catalog_product'

On the other hand, this line: $this->_afterSave() triggers the following events:

  • model_save_after
  • $this->_eventPrefix.'_save_after' (same remark as before)