Mage_ProductAlert_Model_Mysql4_Stock Class Reference

Inheritance diagram for Mage_ProductAlert_Model_Mysql4_Stock:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 loadByParam (Mage_Core_Model_Abstract $object)
 deleteCustomer (Mage_Core_Model_Abstract $object, $customerId, $websiteId)

Protected Member Functions

 _construct ()
 _beforeSave (Mage_Core_Model_Abstract $object)
 _getAlertRow (Mage_Core_Model_Abstract $object)


Detailed Description

Definition at line 35 of file Stock.php.


Member Function Documentation

_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 42 of file Stock.php.

00043     {
00044         if (is_null($object->getId()) && $object->getCustomerId() && $object->getProductId() && $object->getWebsiteId()) {
00045             if ($row = $this->_getAlertRow($object)) {
00046                 $object->addData($row);
00047                 $object->setStatus(0);
00048             }
00049         }
00050         if (is_null($object->getAddDate())) {
00051             $object->setAddDate(Mage::getModel('core/date')->gmtDate());
00052             $object->setStatus(0);
00053         }
00054         return parent::_beforeSave($object);
00055     }

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 37 of file Stock.php.

00038     {
00039         $this->_init('productalert/stock', 'alert_stock_id');
00040     }

_getAlertRow ( Mage_Core_Model_Abstract object  )  [protected]

Definition at line 57 of file Stock.php.

00058     {
00059         if ($object->getCustomerId() && $object->getProductId() && $object->getWebsiteId()) {
00060             $sql = $this->_getWriteAdapter()->select()
00061                 ->from($this->getMainTable())
00062                 ->where('customer_id=?', $object->getCustomerId())
00063                 ->where('product_id=?', $object->getProductId())
00064                 ->where('website_id=?', $object->getWebsiteId());
00065             return $this->_getWriteAdapter()->fetchRow($sql);
00066         }
00067         return false;
00068     }

deleteCustomer ( Mage_Core_Model_Abstract object,
customerId,
websiteId 
)

Definition at line 79 of file Stock.php.

00080     {
00081         $where   = array();
00082         $where[] = $this->_getWriteAdapter()->quoteInto('customer_id=?', $customerId);
00083         if ($websiteId) {
00084             $where[] = $this->_getWriteAdapter()->quoteInto('website_id=?', $websiteId);
00085         }
00086         $this->_getWriteAdapter()->delete($this->getMainTable(), $where);
00087         return $this;
00088     }

loadByParam ( Mage_Core_Model_Abstract object  ) 

Definition at line 70 of file Stock.php.

00071     {
00072         $row = $this->_getAlertRow($object);
00073         if ($row) {
00074             $object->setData($row);
00075         }
00076         return $this;
00077     }


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

Generated on Sat Jul 4 17:24:35 2009 for Magento by  doxygen 1.5.8