Example #1
0
 /**
  * @magentoAppIsolation enabled
  */
 public function testCRUD()
 {
     Mage::app()->setCurrentStore(Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID));
     $this->_model->setName('test');
     $crud = new Magento_Test_Entity($this->_model, array('name' => uniqid()));
     $crud->testCrud();
 }
Example #2
0
 /**
  * Loading tag by name
  *
  * @param Mage_Tag_Model_Tag $model
  * @param string $name
  * @return array|false
  */
 public function loadByName($model, $name)
 {
     if ($name) {
         $read = $this->_getReadAdapter();
         $select = $read->select();
         if (Mage::helper('Mage_Core_Helper_String')->strlen($name) > 255) {
             $name = Mage::helper('Mage_Core_Helper_String')->substr($name, 0, 255);
         }
         $select->from($this->getMainTable())->where('name = :name');
         $data = $read->fetchRow($select, array('name' => $name));
         $model->setData(is_array($data) ? $data : array());
     } else {
         return false;
     }
 }
Example #3
0
 public function getTaggedProductsUrl()
 {
     if (!Mage::helper('magenotification')->checkLicenseKey('Seobytag')) {
         return parent::getTaggedProductsUrl();
     }
     $tagId = $this->getTagId();
     $storeId = Mage::app()->getStore()->getId();
     if (!$storeId) {
         $storeId = $this->getFirstStoreId();
     }
     if (!$this->getSeoHelper()->getConfig('enable')) {
         return parent::getTaggedProductsUrl();
     }
     $rewrite = Mage::getModel('core/url_rewrite')->loadByIdPath("seobytag/{$storeId}/{$tagId}");
     if ($rewrite->getId() && $this->getSeoHelper()->getConfig('cache')) {
         return Mage::getUrl(null, array('_direct' => $rewrite->getRequestPath()));
     }
     try {
         $this->generateUrlKey()->save();
         $rewrite = $this->createRewrite();
         if ($rewrite && $rewrite->getId()) {
             return Mage::getUrl(null, array('_direct' => $rewrite->getRequestPath()));
         }
     } catch (Exception $e) {
     }
     return parent::getTaggedProductsUrl();
 }
Example #4
0
 /**
  * Retrieve link on product rss feed tagged with loaded tag
  *
  * @return bool|string
  */
 public function getLinkUrl()
 {
     if ($this->_isRssEnabled && $this->_tagId) {
         /** @var $tagModel Mage_Tag_Model_Tag */
         $this->_tagModel->load($this->_tagId);
         if ($this->_tagModel && $this->_tagModel->getId()) {
             return $this->_coreUrlModel->getUrl('rss/catalog/tag', array('tagName' => urlencode($this->_tagModel->getName())));
         }
     }
     return false;
 }
Example #5
0
 /**
  * Processing object after save data
  *
  * @return Mage_Core_Model_Abstract
  */
 protected function _afterSave()
 {
     //If the tag becomes approved, approve all associated pending tranfser
     if ($this->oldData['status'] == self::STATUS_PENDING && $this->getStatus() == self::STATUS_APPROVED) {
         $this->approvePendingTransfers();
         //If the review is new (hence not having an id before) get applicable rules,
         //and create a pending transfer for each one
     } elseif ($this->getTagId() && !isset($this->oldData['tag_id'])) {
         Mage::dispatchEvent('rewards_new_tag', array('tag' => &$this));
         $this->onNewTag();
     }
     return parent::_afterSave();
 }
Example #6
0
 public function getTaggedProductsUrl()
 {
     if ($this->getConfig()->isEnabledTagSeoUrls()) {
         $uri = Mage::getModel('catalog/product_url')->formatUrlKey($this->getName());
         $options = array();
         if ($this->getStoreId()) {
             $options['_store'] = $this->getStoreId();
         }
         return Mage::getUrl('tag/' . $uri . '-' . $this->getId(), $options);
     } else {
         return parent::getTaggedProductsUrl();
     }
 }
Example #7
0
 /**
  * Add TAG to PRODUCT relations
  *
  * @param Mage_Tag_Model_Tag $model
  * @param array $productIds
  * @return Mage_Tag_Model_Tag_Relation
  */
 public function addRelations(Mage_Tag_Model_Tag $model, $productIds = array())
 {
     $this->setAddedProductIds($productIds);
     $this->setTagId($model->getTagId());
     $this->setCustomerId(null);
     $this->setStoreId($model->getStore());
     $this->_getResource()->addRelations($this);
     return $this;
 }
Example #8
0
 /**
  * Add summary data to specified object
  *
  * @deprecated after 1.4.0.0
  *
  * @param Mage_Tag_Model_Tag $object
  * @return Mage_Tag_Model_Tag
  */
 public function addSummary($object)
 {
     $read = $this->_getReadAdapter();
     $select = $read->select()->from(array('relation' => $this->getTable('tag/relation')), array())->joinLeft(array('summary' => $this->getTable('tag/summary')), 'relation.tag_id = summary.tag_id AND relation.store_id = summary.store_id', array('customers', 'products', 'popularity'))->where('relation.tag_id = :tag_id')->where('relation.store_id = :store_id')->limit(1);
     $bind = array('tag_id' => (int) $object->getId(), 'store_id' => (int) $object->getStoreId());
     $row = $read->fetchRow($select, $bind);
     if ($row) {
         $object->addData($row);
     }
     return $object;
 }
Example #9
0
 /**
  * Validate if user has exclusive access to tag
  *
  * @param Mage_Tag_Model_Tag $model
  */
 public function tagSaveBefore($model)
 {
     $storeIds = $model->getVisibleInStoreIds();
     // Remove admin store with id 0
     $storeIds = array_filter((array) $storeIds);
     if ($model->getId() && !$this->_role->hasExclusiveStoreAccess((array) $storeIds)) {
         $this->_throwSave();
     }
 }
 /**
  * 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;
 }
 /**
  * Add summary data
  *
  * @param Mage_Tag_Model_Tag $object
  * @return Mage_Tag_Model_Tag
  */
 public function addSummary($object)
 {
     $select = $this->_getReadAdapter()->select()->from($this->getTable('summary'))->where('tag_id = ?', (int) $object->getId())->where('store_id = ?', (int) $object->getStoreId())->limit(1);
     $row = $this->_getReadAdapter()->fetchRow($select);
     if ($row) {
         $object->addData($row);
     }
     return $object;
 }