Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * Get relation model for product marked in store with tag by customer
  *
  * @param Mage_Tag_Model_Tag_Relation $relationModel
  * @return Mage_Tag_Model_Tag_Relation
  */
 protected function _getLinkBetweenTagCustomerProduct($relationModel)
 {
     return Mage::getModel('tag/tag_relation')->loadByTagCustomer($relationModel->getProductId(), $this->getId(), $relationModel->getCustomerId(), $relationModel->getStoreId());
 }
 /**
  * Retrieve related to product tag ids
  *
  * @param Mage_Tag_Model_Tag_Relation $model
  * @return array
  */
 public function getRelatedTagIds($model)
 {
     $productIds = is_array($model->getProductId()) ? $model->getProductId() : array($model->getProductId());
     $select = $this->_getReadAdapter()->select()->from($this->getMainTable(), 'tag_id')->where("product_id IN(?)", $productIds)->order('tag_id');
     return $this->_getReadAdapter()->fetchCol($select);
 }
Ejemplo n.º 4
0
 /**
  * Checks whether the already marked this product in this store by this tag and by this customer.
  * 
  * @param Mage_Tag_Model_Tag_Relation $tagRelationModel
  * @param Mage_Tag_Model_Tag $tagModel
  * @return boolean
  */
 protected function _checkLinkBetweenTagCustomerProduct($tagRelationModel, $tagModel)
 {
     return count(Mage::getModel('tag/tag_relation')->loadByTagCustomer($tagRelationModel->getProductId(), $tagModel->getId(), $tagRelationModel->getCustomerId(), $tagRelationModel->getStoreId())->getProductIds()) > 0;
 }