Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Rating_Block_Entity_Detailed
  • Mage_Rating_Helper_Data
  • Mage_Rating_Model_Mysql4_Rating
  • Mage_Rating_Model_Mysql4_Rating_Collection
  • Mage_Rating_Model_Mysql4_Rating_Entity
  • Mage_Rating_Model_Mysql4_Rating_Option
  • Mage_Rating_Model_Mysql4_Rating_Option_Collection
  • Mage_Rating_Model_Mysql4_Rating_Option_Vote
  • Mage_Rating_Model_Mysql4_Rating_Option_Vote_Collection
  • Mage_Rating_Model_Observer
  • Mage_Rating_Model_Rating
  • Mage_Rating_Model_Rating_Entity
  • Mage_Rating_Model_Rating_Option
  • Mage_Rating_Model_Rating_Option_Vote
  • Mage_Rating_Model_Resource_Rating
  • Mage_Rating_Model_Resource_Rating_Collection
  • Mage_Rating_Model_Resource_Rating_Entity
  • Mage_Rating_Model_Resource_Rating_Option
  • Mage_Rating_Model_Resource_Rating_Option_Collection
  • Mage_Rating_Model_Resource_Rating_Option_Vote
  • Mage_Rating_Model_Resource_Rating_Option_Vote_Collection
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Rating
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Rating votes collection
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_Rating
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Rating_Model_Resource_Rating_Option_Vote_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
 35: {
 36:     /**
 37:      * Define model
 38:      *
 39:      */
 40:     protected function _construct()
 41:     {
 42:         $this->_init('rating/rating_option_vote');
 43:     }
 44: 
 45:     /**
 46:      * Set review filter
 47:      *
 48:      * @param int $reviewId
 49:      * @return Mage_Rating_Model_Resource_Rating_Option_Vote_Collection
 50:      */
 51:     public function setReviewFilter($reviewId)
 52:     {
 53:         $this->getSelect()
 54:             ->where("main_table.review_id = ?", $reviewId);
 55:         return $this;
 56:     }
 57: 
 58:     /**
 59:      * Set EntityPk filter
 60:      *
 61:      * @param int $entityId
 62:      * @return Mage_Rating_Model_Resource_Rating_Option_Vote_Collection
 63:      */
 64:     public function setEntityPkFilter($entityId)
 65:     {
 66:         $this->getSelect()
 67:             ->where("entity_pk_value = ?", $entityId);
 68:         return $this;
 69:     }
 70: 
 71:     /**
 72:      * Set store filter
 73:      *
 74:      * @param int $storeId
 75:      * @return Mage_Rating_Model_Resource_Rating_Option_Vote_Collection
 76:      */
 77:     public function setStoreFilter($storeId)
 78:     {
 79:         $this->getSelect()
 80:             ->join(array('rstore'=>$this->getTable('review/review_store')),
 81:                 $this->getConnection()->quoteInto(
 82:                     'main_table.review_id=rstore.review_id AND rstore.store_id=?',
 83:                     (int)$storeId),
 84:             array());
 85:         return $this;
 86:     }
 87: 
 88:     /**
 89:      * Add rating info to select
 90:      *
 91:      * @param int $storeId
 92:      * @return Mage_Rating_Model_Resource_Rating_Option_Vote_Collection
 93:      */
 94:     public function addRatingInfo($storeId=null)
 95:     {
 96:         $adapter=$this->getConnection();
 97:         $ratingCodeCond = $adapter->getIfNullSql('title.value', 'rating.rating_code');
 98:         $this->getSelect()
 99:             ->join(
100:                 array('rating'    => $this->getTable('rating/rating')),
101:                 'rating.rating_id = main_table.rating_id',
102:                 array('rating_code'))
103:             ->joinLeft(
104:                 array('title' => $this->getTable('rating/rating_title')),
105:                 $adapter->quoteInto('main_table.rating_id=title.rating_id AND title.store_id = ?',
106:                     (int)Mage::app()->getStore()->getId()),
107:                 array('rating_code' => $ratingCodeCond));
108: 
109:         if ($storeId == null) {
110:             $storeId = Mage::app()->getStore()->getId();
111:         }
112: 
113:         if (is_array($storeId)) {
114:             $condition = $adapter->prepareSqlCondition('store.store_id', array(
115:                 'in' => $storeId
116:             ));
117:         } else {
118:             $condition = $adapter->quoteInto('store.store_id = ?', $storeId);
119:         }
120: 
121:         $this->getSelect()
122:             ->join(
123:                 array('store' => $this->getTable('rating_store')),
124:                 'main_table.rating_id = store.rating_id AND ' . $condition)
125: //            ->group('main_table.vote_id')
126:         ;
127: 
128:         $adapter->fetchAll($this->getSelect());
129:         return $this;
130:     }
131: 
132:     /**
133:      * Add option info to select
134:      *
135:      * @return Mage_Rating_Model_Resource_Rating_Option_Vote_Collection
136:      */
137:     public function addOptionInfo()
138:     {
139:         $this->getSelect()
140:             ->join(array('rating_option' => $this->getTable('rating/rating_option')),
141:                 'main_table.option_id = rating_option.option_id');
142:         return $this;
143:     }
144: 
145:     /**
146:      * Add rating options
147:      *
148:      * @return Mage_Rating_Model_Resource_Rating_Option_Vote_Collection
149:      */
150:     public function addRatingOptions()
151:     {
152:         if (!$this->getSize()) {
153:             return $this;
154:         }
155:         foreach ($this->getItems() as $item) {
156:             $options = Mage::getModel('rating/rating_option')
157:                     ->getResourceCollection()
158:                     ->addRatingFilter($item->getRatingId())
159:                     ->load();
160: 
161:             if ($item->getRatingId()) {
162:                 $item->setRatingOptions($options);
163:             } else {
164:                 return;
165:             }
166:         }
167:         return $this;
168:     }
169: }
170: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0