Mage_Checkout_Model_Mysql4_Agreement Class Reference

Inheritance diagram for Mage_Checkout_Model_Mysql4_Agreement:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Protected Member Functions

 _construct ()
 _beforeSave (Mage_Core_Model_Abstract $object)
 _afterSave (Mage_Core_Model_Abstract $object)
 _afterLoad (Mage_Core_Model_Abstract $object)
 _getLoadSelect ($field, $value, $object)


Detailed Description

Definition at line 27 of file Agreement.php.


Member Function Documentation

_afterLoad ( Mage_Core_Model_Abstract object  )  [protected]

Perform actions after object load

Parameters:
Varien_Object $object

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 63 of file Agreement.php.

00064     {
00065         $select = $this->_getReadAdapter()->select()
00066             ->from($this->getTable('checkout/agreement_store'))
00067             ->where('agreement_id = ?', $object->getId());
00068 
00069         if ($data = $this->_getReadAdapter()->fetchAll($select)) {
00070             $storesArray = array();
00071             foreach ($data as $row) {
00072                 $storesArray[] = $row['store_id'];
00073             }
00074             $object->setData('store_id', $storesArray);
00075         }
00076 
00077         return parent::_afterLoad($object);
00078     }

_afterSave ( Mage_Core_Model_Abstract object  )  [protected]

Perform actions after object save

Parameters:
Varien_Object $object

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 48 of file Agreement.php.

00049     {
00050         $condition = $this->_getWriteAdapter()->quoteInto('agreement_id = ?', $object->getId());
00051         $this->_getWriteAdapter()->delete($this->getTable('checkout/agreement_store'), $condition);
00052 
00053         foreach ((array)$object->getData('stores') as $store) {
00054             $storeArray = array();
00055             $storeArray['agreement_id'] = $object->getId();
00056             $storeArray['store_id'] = $store;
00057             $this->_getWriteAdapter()->insert($this->getTable('checkout/agreement_store'), $storeArray);
00058         }
00059 
00060         return parent::_afterSave($object);
00061     }

_beforeSave ( Mage_Core_Model_Abstract object  )  [protected]

Perform actions before object save

Parameters:
Varien_Object $object

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 34 of file Agreement.php.

00035     {
00036         // format height
00037         $height = $object->getContentHeight();
00038         if (!$height) {
00039             $height = '';
00040         }
00041         if ($height && preg_match('/[0-9]$/', $height)) {
00042             $height .= 'px';
00043         }
00044         $object->setContentHeight($height);
00045         return parent::_beforeSave($object);
00046     }

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 29 of file Agreement.php.

00030     {
00031         $this->_init('checkout/agreement', 'agreement_id');
00032     }

_getLoadSelect ( field,
value,
object 
) [protected]

Retrieve select object for load object data

Parameters:
string $field
mixed $value
Returns:
Zend_Db_Select

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 80 of file Agreement.php.

00081     {
00082         $select = parent::_getLoadSelect($field, $value, $object);
00083 
00084         if ($object->getStoreId()) {
00085             $select->join(array('cps' => $this->getTable('checkout/agreement_store')), $this->getMainTable().'.agreement_id = `cps`.agreement_id')
00086                     ->where('is_active=1 AND `cps`.store_id in (0, ?) ', $object->getStoreId())
00087                     ->order('store_id DESC')
00088                     ->limit(1);
00089         }
00090         return $select;
00091     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:51 2009 for Magento by  doxygen 1.5.8