Public Member Functions | |
loadByTagCustomer ($model) | |
getProductIds ($model) | |
deactivate ($tagId, $customerId) | |
Protected Member Functions | |
_construct () |
Definition at line 35 of file Relation.php.
_construct | ( | ) | [protected] |
Resource initialization
Reimplemented from Mage_Core_Model_Resource_Abstract.
Definition at line 37 of file Relation.php.
00038 { 00039 $this->_init('tag/relation', 'tag_relation_id'); 00040 }
deactivate | ( | $ | tagId, | |
$ | customerId | |||
) |
Definition at line 82 of file Relation.php.
00083 { 00084 $condition = $this->_getWriteAdapter()->quoteInto('tag_id = ?', $tagId) . ' AND '; 00085 $condition.= $this->_getWriteAdapter()->quoteInto('customer_id = ?', $customerId); 00086 $data = array('active'=>0); 00087 $this->_getWriteAdapter()->update($this->getMainTable(), $data, $condition); 00088 return $this; 00089 }
getProductIds | ( | $ | model | ) |
Definition at line 69 of file Relation.php.
00070 { 00071 $select = $this->_getReadAdapter()->select() 00072 ->from($this->getMainTable(), 'product_id') 00073 ->where("tag_id = ?", $model->getTagId()) 00074 ->where('customer_id=?', $model->getCustomerId()) 00075 ->where('active=1'); 00076 if( $model->hasStoreId() ) { 00077 $select->where('store_id = ?', $model->getStoreId()); 00078 } 00079 return $this->_getReadAdapter()->fetchCol($select); 00080 }
loadByTagCustomer | ( | $ | model | ) |
Definition at line 42 of file Relation.php.
00043 { 00044 if( $model->getTagId() && $model->getCustomerId() ) { 00045 $read = $this->_getReadAdapter(); 00046 $select = $read->select(); 00047 00048 $select->from($this->getMainTable()) 00049 ->join($this->getTable('tag/tag'), "{$this->getTable('tag/tag')}.tag_id = {$this->getMainTable()}.tag_id") 00050 ->where("{$this->getMainTable()}.tag_id = ?", $model->getTagId()) 00051 ->where('customer_id = ?', $model->getCustomerId()); 00052 00053 if( $model->getProductId() ) { 00054 $select->where("{$this->getMainTable()}.product_id = ?", $model->getProductId()); 00055 } 00056 00057 if( $model->hasStoreId() ) { 00058 $select->where("{$this->getMainTable()}.store_id = ?", $model->getStoreId()); 00059 } 00060 00061 $data = $read->fetchRow($select); 00062 $model->setData( ( is_array($data) ) ? $data : array() ); 00063 return $this; 00064 } else { 00065 return $this; 00066 } 00067 }