Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

In your model you would need to override Mage_Core_Model_Abstract::load() function.

If the soft delete is on all models you need to override: Mage_Core_Model_Resource_Db_Abstract::load() method to something like:

public function load(Mage_Core_Model_Abstract $object, $value, $field = null)
{
    if (is_null($field)) {
        $field = $this->getIdFieldName();
    }

    $read = $this->_getReadAdapter();
    if ($read && !is_null($value)) {
        $select = $this->_getLoadSelect($field, $value, $object);
        $data = $read->fetchRow($select);

        if ($data && $data[is_delete] != 1) {
            $object->setData($data);
        }
    }

    $this->unserializeFields($object);
    $this->_afterLoad($object);

    return $this;
}

Here is how you could override an abstract class in Magento: http://stackoverflow.com/questions/15739628/override-extend-magento-abstract-classhttps://stackoverflow.com/questions/15739628/override-extend-magento-abstract-class

In your model you would need to override Mage_Core_Model_Abstract::load() function.

If the soft delete is on all models you need to override: Mage_Core_Model_Resource_Db_Abstract::load() method to something like:

public function load(Mage_Core_Model_Abstract $object, $value, $field = null)
{
    if (is_null($field)) {
        $field = $this->getIdFieldName();
    }

    $read = $this->_getReadAdapter();
    if ($read && !is_null($value)) {
        $select = $this->_getLoadSelect($field, $value, $object);
        $data = $read->fetchRow($select);

        if ($data && $data[is_delete] != 1) {
            $object->setData($data);
        }
    }

    $this->unserializeFields($object);
    $this->_afterLoad($object);

    return $this;
}

Here is how you could override an abstract class in Magento: http://stackoverflow.com/questions/15739628/override-extend-magento-abstract-class

In your model you would need to override Mage_Core_Model_Abstract::load() function.

If the soft delete is on all models you need to override: Mage_Core_Model_Resource_Db_Abstract::load() method to something like:

public function load(Mage_Core_Model_Abstract $object, $value, $field = null)
{
    if (is_null($field)) {
        $field = $this->getIdFieldName();
    }

    $read = $this->_getReadAdapter();
    if ($read && !is_null($value)) {
        $select = $this->_getLoadSelect($field, $value, $object);
        $data = $read->fetchRow($select);

        if ($data && $data[is_delete] != 1) {
            $object->setData($data);
        }
    }

    $this->unserializeFields($object);
    $this->_afterLoad($object);

    return $this;
}

Here is how you could override an abstract class in Magento: https://stackoverflow.com/questions/15739628/override-extend-magento-abstract-class

added 21 characters in body
Source Link
Paras Sood
  • 2.6k
  • 1
  • 15
  • 23

In your model you would need to override Mage_Core_Model_Abstract::load() function.

If the soft delete is on all models you need to override: Mage_Core_Model_Resource_Db_Abstract::load() method to something like:

public function load(Mage_Core_Model_Abstract $object, $value, $field = null)
{
    if (is_null($field)) {
        $field = $this->getIdFieldName();
    }

    $read = $this->_getReadAdapter();
    if ($read && !is_null($value)) {
        $select = $this->_getLoadSelect($field, $value, $object);
        $data = $read->fetchRow($select);

        if ($data && $data[is_delete] != 1) {
            $object->setData($data);
        }
    }

    $this->unserializeFields($object);
    $this->_afterLoad($object);

    return $this;
}

/** Here is how you could override an abstract class in Magento: http://stackoverflow.com/questions/15739628/override-extend-magento-abstract-class

  • Load an object

  • @param Mage_Core_Model_Abstract $object

  • @param mixed $value

  • @param string $field field to load by (defaults to model id)

  • @return Mage_Core_Model_Resource_Db_Abstract */ public function load(Mage_Core_Model_Abstract $object, $value, $field = null) { if (is_null($field)) { $field = $this->getIdFieldName(); }

    $read = $this->_getReadAdapter(); if ($read && !is_null($value)) { $select = $this->_getLoadSelect($field, $value, $object); $data = $read->fetchRow($select);

     if ($data && $data[is_delete] != 1) {
         $object->setData($data);
     }
    

    }

    $this->unserializeFields($object); $this->_afterLoad($object);

    return $this; }

In your model you would need to override Mage_Core_Model_Abstract::load() function.

If the soft delete is on all models you need to override: Mage_Core_Model_Resource_Db_Abstract::load() method to something like:

/**

  • Load an object

  • @param Mage_Core_Model_Abstract $object

  • @param mixed $value

  • @param string $field field to load by (defaults to model id)

  • @return Mage_Core_Model_Resource_Db_Abstract */ public function load(Mage_Core_Model_Abstract $object, $value, $field = null) { if (is_null($field)) { $field = $this->getIdFieldName(); }

    $read = $this->_getReadAdapter(); if ($read && !is_null($value)) { $select = $this->_getLoadSelect($field, $value, $object); $data = $read->fetchRow($select);

     if ($data && $data[is_delete] != 1) {
         $object->setData($data);
     }
    

    }

    $this->unserializeFields($object); $this->_afterLoad($object);

    return $this; }

In your model you would need to override Mage_Core_Model_Abstract::load() function.

If the soft delete is on all models you need to override: Mage_Core_Model_Resource_Db_Abstract::load() method to something like:

public function load(Mage_Core_Model_Abstract $object, $value, $field = null)
{
    if (is_null($field)) {
        $field = $this->getIdFieldName();
    }

    $read = $this->_getReadAdapter();
    if ($read && !is_null($value)) {
        $select = $this->_getLoadSelect($field, $value, $object);
        $data = $read->fetchRow($select);

        if ($data && $data[is_delete] != 1) {
            $object->setData($data);
        }
    }

    $this->unserializeFields($object);
    $this->_afterLoad($object);

    return $this;
}

Here is how you could override an abstract class in Magento: http://stackoverflow.com/questions/15739628/override-extend-magento-abstract-class

Source Link
Paras Sood
  • 2.6k
  • 1
  • 15
  • 23

In your model you would need to override Mage_Core_Model_Abstract::load() function.

If the soft delete is on all models you need to override: Mage_Core_Model_Resource_Db_Abstract::load() method to something like:

/**

  • Load an object

  • @param Mage_Core_Model_Abstract $object

  • @param mixed $value

  • @param string $field field to load by (defaults to model id)

  • @return Mage_Core_Model_Resource_Db_Abstract */ public function load(Mage_Core_Model_Abstract $object, $value, $field = null) { if (is_null($field)) { $field = $this->getIdFieldName(); }

    $read = $this->_getReadAdapter(); if ($read && !is_null($value)) { $select = $this->_getLoadSelect($field, $value, $object); $data = $read->fetchRow($select);

     if ($data && $data[is_delete] != 1) {
         $object->setData($data);
     }
    

    }

    $this->unserializeFields($object); $this->_afterLoad($object);

    return $this; }