/** * Load by Tag and Customer * * @param Mage_Tag_Model_Tag_Relation $model * @return Mage_Tag_Model_Mysql4_Tag_Relation */ public function loadByTagCustomer($model) { if ($model->getTagId() && $model->getCustomerId()) { $read = $this->_getReadAdapter(); $select = $read->select()->from($this->getMainTable())->join($this->getTable('tag/tag'), "{$this->getTable('tag/tag')}.tag_id = {$this->getMainTable()}.tag_id")->where("{$this->getMainTable()}.tag_id = ?", $model->getTagId())->where('customer_id = ?', $model->getCustomerId()); if ($model->getProductId()) { $select->where("{$this->getMainTable()}.product_id = ?", $model->getProductId()); } if ($model->hasStoreId()) { $select->where("{$this->getMainTable()}.store_id = ?", $model->getStoreId()); } $data = $read->fetchRow($select); $model->setData(is_array($data) ? $data : array()); } return $this; }
/** * Load by Tag and Customer * * @param Mage_Tag_Model_Tag_Relation $model * @return Mage_Tag_Model_Resource_Tag_Relation */ public function loadByTagCustomer($model) { if ($model->getTagId() && $model->getCustomerId()) { $read = $this->_getReadAdapter(); $bind = array('tag_id' => $model->getTagId(), 'customer_id' => $model->getCustomerId()); $select = $read->select()->from($this->getMainTable())->join($this->getTable('tag/tag'), $this->getTable('tag/tag') . '.tag_id = ' . $this->getMainTable() . '.tag_id')->where($this->getMainTable() . '.tag_id = :tag_id')->where('customer_id = :customer_id'); if ($model->getProductId()) { $select->where($this->getMainTable() . '.product_id = :product_id'); $bind['product_id'] = $model->getProductId(); } if ($model->hasStoreId()) { $select->where($this->getMainTable() . '.store_id = :sore_id'); $bind['sore_id'] = $model->getStoreId(); } $data = $read->fetchRow($select, $bind); $model->setData(is_array($data) ? $data : array()); } return $this; }