/** * @param $observer * @return $this */ protected function _addPointsForTagging($observer) { $object = $observer->getObject(); if (($tagToApprove = $object) instanceof Mage_Tag_Model_Tag) { if ($this->_isModuleDisabled($tagToApprove->getStoreId())) { return $this; } $tagCollection = Mage::getModel('tag/tag')->getCollection()->joinRel()->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED); $tagCollection->getSelect()->where('main_table.tag_id = ?', $tagToApprove->getTagId()); foreach ($tagCollection->getData() as $tag) { $tagObject = new Varien_Object(); unset($tag['tag_id']); $tagObject->setData($tag); $customer = Mage::getModel('customer/customer')->load($tagObject->getCustomerId()); if ($this->_isNotSetInSummary($customer, $tagObject->getTagRelationId())) { $pointsForTagging = Mage::helper('points/config')->getPointsForTaggingProduct($customer->getStoreId()); $product = Mage::getModel('catalog/product')->load($tagObject->getProductId()); Mage::getModel('points/api')->addTransaction($pointsForTagging, 'customer_tag_product', $customer, $tagObject, array('product_name' => $product->getName())); $this->_addRelationIdToSummary($customer, $tagObject->getTagRelationId()); } } } return $this; }