Mage_ProductAlert_Model_Mysql4_Price Class Reference

Inheritance diagram for Mage_ProductAlert_Model_Mysql4_Price:

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=null)

Protected Member Functions

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


Detailed Description

Definition at line 35 of file Price.php.


Member Function Documentation

_beforeSave ( Mage_Core_Model_Abstract object  )  [protected]

Before save process, check exists the same alert

Parameters:
Mage_Core_Model_Abstract $object
Returns:
Mage_ProductAlert_Model_Mysql4_Price

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 52 of file Price.php.

00053     {
00054         if (is_null($object->getId()) && $object->getCustomerId() && $object->getProductId() && $object->getWebsiteId()) {
00055             if ($row = $this->_getAlertRow($object)) {
00056                 $price = $object->getPrice();
00057                 $object->addData($row);
00058                 if ($price) {
00059                     $object->setPrice($price);
00060                 }
00061                 $object->setStatus(0);
00062             }
00063         }
00064         if (is_null($object->getAddDate())) {
00065             $object->setAddDate(Mage::getModel('core/date')->gmtDate());
00066         }
00067         return parent::_beforeSave($object);
00068     }

_construct (  )  [protected]

Initialize connection

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 41 of file Price.php.

00042     {
00043         $this->_init('productalert/price', 'alert_price_id');
00044     }

_getAlertRow ( Mage_Core_Model_Abstract object  )  [protected]

Retrieve alert row by object parameters

Parameters:
Mage_Core_Model_Abstract $object
Returns:
array|bool

Definition at line 76 of file Price.php.

00077     {
00078         if ($object->getCustomerId() && $object->getProductId() && $object->getWebsiteId()) {
00079             $sql = $this->_getWriteAdapter()->select()
00080                 ->from($this->getMainTable())
00081                 ->where('customer_id=?', $object->getCustomerId())
00082                 ->where('product_id=?', $object->getProductId())
00083                 ->where('website_id=?', $object->getWebsiteId());
00084             return $this->_getWriteAdapter()->fetchRow($sql);
00085         }
00086         return false;
00087     }

deleteCustomer ( Mage_Core_Model_Abstract object,
customerId,
websiteId = null 
)

Delete all customer alerts on website

Parameters:
Mage_Core_Model_Abstract $object
int $customerId
int $websiteId
Returns:
Mage_ProductAlert_Model_Mysql4_Price

Definition at line 112 of file Price.php.

00113     {
00114         $where   = array();
00115         $where[] = $this->_getWriteAdapter()->quoteInto('customer_id=?', $customerId);
00116         if ($websiteId) {
00117             $where[] = $this->_getWriteAdapter()->quoteInto('website_id=?', $websiteId);
00118         }
00119         $this->_getWriteAdapter()->delete($this->getMainTable(), $where);
00120         return $this;
00121     }

loadByParam ( Mage_Core_Model_Abstract object  ) 

Load object data by parameters

Parameters:
Mage_Core_Model_Abstract $object
Returns:
Mage_ProductAlert_Model_Mysql4_Price

Definition at line 95 of file Price.php.

00096     {
00097         $row = $this->_getAlertRow($object);
00098         if ($row) {
00099             $object->setData($row);
00100         }
00101         return $this;
00102     }


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