diff --git a/app/code/core/Mage/Rating/Block/Entity/Detailed.php b/app/code/core/Mage/Rating/Block/Entity/Detailed.php index 6a6e955ac34..0188d55a602 100644 --- a/app/code/core/Mage/Rating/Block/Entity/Detailed.php +++ b/app/code/core/Mage/Rating/Block/Entity/Detailed.php @@ -30,6 +30,8 @@ * @category Mage * @package Mage_Rating * @author Magento Core Team + * + * @method $this setEntityId(int $value) */ class Mage_Rating_Block_Entity_Detailed extends Mage_Core_Block_Template { @@ -39,6 +41,10 @@ public function __construct() $this->setTemplate('rating/detailed.phtml'); } + /** + * @return string + * @throws Mage_Core_Model_Store_Exception + */ protected function _toHtml() { $entityId = Mage::app()->getRequest()->getParam('id'); @@ -56,7 +62,7 @@ protected function _toHtml() $ratingCollection = Mage::getModel('rating/rating') ->getResourceCollection() - ->addEntityFilter('product') # TOFIX + ->addEntityFilter('product') # @todo TOFIX ->setPositionOrder() ->setStoreFilter(Mage::app()->getStore()->getId()) ->addRatingPerStoreName(Mage::app()->getStore()->getId()) diff --git a/app/code/core/Mage/Rating/Model/Mysql4/Rating/Option/Vote/Collection.php b/app/code/core/Mage/Rating/Model/Mysql4/Rating/Option/Vote/Collection.php index f1bcc40d9e1..37f915cac27 100644 --- a/app/code/core/Mage/Rating/Model/Mysql4/Rating/Option/Vote/Collection.php +++ b/app/code/core/Mage/Rating/Model/Mysql4/Rating/Option/Vote/Collection.php @@ -32,7 +32,6 @@ * @package Mage_Rating * @author Magento Core Team */ -class Mage_Rating_Model_Mysql4_Rating_Option_Vote_Collection - extends Mage_Rating_Model_Resource_Rating_Option_Vote_Collection +class Mage_Rating_Model_Mysql4_Rating_Option_Vote_Collection extends Mage_Rating_Model_Resource_Rating_Option_Vote_Collection { } diff --git a/app/code/core/Mage/Rating/Model/Observer.php b/app/code/core/Mage/Rating/Model/Observer.php index f8b2fd591e6..4028e336cd7 100644 --- a/app/code/core/Mage/Rating/Model/Observer.php +++ b/app/code/core/Mage/Rating/Model/Observer.php @@ -37,11 +37,12 @@ class Mage_Rating_Model_Observer /** * Cleanup product ratings after product delete * - * @param Varien_Event_Observer $observer - * @return Mage_CatalogIndex_Model_Observer + * @param Varien_Event_Observer $observer + * @return Mage_Rating_Model_Observer */ public function processProductAfterDeleteEvent(Varien_Event_Observer $observer) { + /** @var Mage_Catalog_Model_Product $eventProduct */ $eventProduct = $observer->getEvent()->getProduct(); if ($eventProduct && $eventProduct->getId()) { Mage::getResourceSingleton('rating/rating')->deleteAggregatedRatingsByProductId($eventProduct->getId()); diff --git a/app/code/core/Mage/Rating/Model/Rating.php b/app/code/core/Mage/Rating/Model/Rating.php index 2a4cccbd58d..b701502d66e 100644 --- a/app/code/core/Mage/Rating/Model/Rating.php +++ b/app/code/core/Mage/Rating/Model/Rating.php @@ -29,16 +29,36 @@ * * @method Mage_Rating_Model_Resource_Rating getResource() * @method Mage_Rating_Model_Resource_Rating _getResource() + * @method Mage_Rating_Model_Resource_Rating_Collection getCollection() + * @method Mage_Rating_Model_Resource_Rating_Collection getResourceCollection() + * + * @method $this setCount(int $value) + * @method $this setCustomerId(int $value) + * @method $this setEntityId(int $value) + * @method string getEntityPkValue() + * @method $this setEntityPkValue(string $value) + * @method $this setId(string $value) + * @method $this setPosition(string $value) + * @method bool hasRatingCodes() + * @method string getRatingCode() + * @method $this setRatingCode(string $value) * @method array getRatingCodes() - * @method Mage_Rating_Model_Rating setRatingCodes(array $value) + * @method $this setRatingCodes(array $value) + * @method $this setRatingId(int $value) + * @method int getReviewId() + * @method $this setReviewId(int $value) + * @method bool hasStores() + * @method int getStoreId() + * @method $this setStoreId(int $value) * @method array getStores() - * @method Mage_Rating_Model_Rating setStores(array $value) - * @method string getRatingCode() - * @method Mage_Rating_Model_Rating getRatingCode(string $value) + * @method $this setStores(array $value) + * @method $this setSum(int $value) + * @method $this setSummary(float|int $param) + * @method int getVoteId() * * @category Mage * @package Mage_Rating - * @author Magento Core Team + * @author Magento Core Team */ class Mage_Rating_Model_Rating extends Mage_Core_Model_Abstract { @@ -60,6 +80,11 @@ protected function _construct() $this->_init('rating/rating'); } + /** + * @param int $optionId + * @param string $entityPkValue + * @return $this + */ public function addOptionVote($optionId, $entityPkValue) { Mage::getModel('rating/rating_option')->setOptionId($optionId) @@ -70,6 +95,10 @@ public function addOptionVote($optionId, $entityPkValue) return $this; } + /** + * @param int $optionId + * @return $this + */ public function updateOptionVote($optionId) { Mage::getModel('rating/rating_option')->setOptionId($optionId) @@ -89,8 +118,7 @@ public function getOptions() { if ($options = $this->getData('options')) { return $options; - } - elseif ($id = $this->getId()) { + } elseif ($id = $this->getId()) { return Mage::getResourceModel('rating/rating_option_collection') ->addRatingFilter($id) ->setPositionOrder() @@ -103,16 +131,23 @@ public function getOptions() /** * Get rating collection object * - * @return array + * @param string $entityPkValue + * @param bool $onlyForCurrentStore + * @return array|Mage_Rating_Model_Rating */ - public function getEntitySummary($entityPkValue, $onlyForCurrentStore = true) + public function getEntitySummary($entityPkValue, $onlyForCurrentStore = true) { $this->setEntityPkValue($entityPkValue); return $this->_getResource()->getEntitySummary($this, $onlyForCurrentStore); } - public function getReviewSummary($reviewId, $onlyForCurrentStore = true) + /** + * @param int $reviewId + * @param bool $onlyForCurrentStore + * @return array + */ + public function getReviewSummary($reviewId, $onlyForCurrentStore = true) { $this->setReviewId($reviewId); return $this->_getResource()->getReviewSummary($this, $onlyForCurrentStore); diff --git a/app/code/core/Mage/Rating/Model/Rating/Entity.php b/app/code/core/Mage/Rating/Model/Rating/Entity.php index c317e3e264f..d6fadc37b73 100644 --- a/app/code/core/Mage/Rating/Model/Rating/Entity.php +++ b/app/code/core/Mage/Rating/Model/Rating/Entity.php @@ -44,6 +44,10 @@ protected function _construct() $this->_init('rating/rating_entity'); } + /** + * @param string $entityCode + * @return int + */ public function getIdByCode($entityCode) { return $this->_getResource()->getIdByCode($entityCode); diff --git a/app/code/core/Mage/Rating/Model/Rating/Option.php b/app/code/core/Mage/Rating/Model/Rating/Option.php index c1e82fc98b4..c7f4103d334 100644 --- a/app/code/core/Mage/Rating/Model/Rating/Option.php +++ b/app/code/core/Mage/Rating/Model/Rating/Option.php @@ -27,16 +27,26 @@ /** * Rating option model * + * @method Mage_Rating_Model_Resource_Rating_Option_Collection getResourceCollection() * @method Mage_Rating_Model_Resource_Rating_Option _getResource() * @method Mage_Rating_Model_Resource_Rating_Option getResource() - * @method int getRatingId() - * @method Mage_Rating_Model_Rating_Option setRatingId(int $value) * @method string getCode() - * @method Mage_Rating_Model_Rating_Option setCode(string $value) - * @method int getValue() - * @method Mage_Rating_Model_Rating_Option setValue(int $value) + * @method $this setCode(string $value) + * @method int getDoUpdate() + * @method $this setDoUpdate(int $value) + * @method string getEntityPkValue() + * @method $this setEntityPkValue(string $value) + * @method $this setOptionId(int $value) * @method int getPosition() - * @method Mage_Rating_Model_Rating_Option setPosition(int $value) + * @method $this setPosition(int $value) + * @method int getRatingId() + * @method $this setRatingId(int $value) + * @method int getReviewId() + * @method $this setReviewId(int $value) + * @method int getValue() + * @method $this setValue(int $value) + * @method int getVoteId() + * @method $this setVoteId(int $value) * * @category Mage * @package Mage_Rating @@ -49,12 +59,20 @@ protected function _construct() $this->_init('rating/rating_option'); } + /** + * @return $this + * @throws Exception + */ public function addVote() { $this->getResource()->addVote($this); return $this; } + /** + * @param int $id + * @return $this + */ public function setId($id) { $this->setOptionId($id); diff --git a/app/code/core/Mage/Rating/Model/Rating/Option/Vote.php b/app/code/core/Mage/Rating/Model/Rating/Option/Vote.php index de95f5a9b08..04f4e4e8156 100644 --- a/app/code/core/Mage/Rating/Model/Rating/Option/Vote.php +++ b/app/code/core/Mage/Rating/Model/Rating/Option/Vote.php @@ -30,6 +30,11 @@ * @category Mage * @package Mage_Rating * @author Magento Core Team + * + * @method Mage_Rating_Model_Resource_Rating_Option_Vote_Collection getResourceCollection()() + * @method string getEntityPkValue() + * @method int getRatingId() + * @method $this setRatingOptions(Mage_Rating_Model_Resource_Rating_Option_Collection $options) */ class Mage_Rating_Model_Rating_Option_Vote extends Mage_Core_Model_Abstract diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating.php b/app/code/core/Mage/Rating/Model/Resource/Rating.php index 03b126a83b7..41bb9eb1ba8 100644 --- a/app/code/core/Mage/Rating/Model/Resource/Rating.php +++ b/app/code/core/Mage/Rating/Model/Resource/Rating.php @@ -77,7 +77,8 @@ protected function _getLoadSelect($field, $value, $object) $select->joinLeft( array('title' => $this->getTable('rating/rating_title')), $adapter->quoteInto("{$table}.rating_id = title.rating_id AND title.store_id = ?", $storeId), - array('rating_code' => $codeExpr)); + array('rating_code' => $codeExpr) + ); return $select; } @@ -85,7 +86,7 @@ protected function _getLoadSelect($field, $value, $object) /** * Actions after load * - * @param Mage_Rating_Model_Rating $object + * @param Mage_Core_Model_Abstract|Mage_Rating_Model_Rating $object * @return $this */ protected function _afterLoad(Mage_Core_Model_Abstract $object) @@ -131,7 +132,7 @@ public function getStores($ratingId) /** * Actions after save * - * @param Mage_Rating_Model_Rating $object + * @param Mage_Core_Model_Abstract|Mage_Rating_Model_Rating $object * @return $this */ protected function _afterSave(Mage_Core_Model_Abstract $object) @@ -227,7 +228,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $object) * Perform actions after object delete * Prepare rating data for reaggregate all data for reviews * - * @param Mage_Rating_Model_Rating $object + * @param Mage_Core_Model_Abstract|Mage_Rating_Model_Rating $object * @return $this */ protected function _afterDelete(Mage_Core_Model_Abstract $object) @@ -252,7 +253,7 @@ protected function _afterDelete(Mage_Core_Model_Abstract $object) * * @param Mage_Rating_Model_Rating $object * @param boolean $onlyForCurrentStore - * @return array + * @return array|Mage_Rating_Model_Rating */ public function getEntitySummary($object, $onlyForCurrentStore = true) { @@ -280,6 +281,7 @@ public function getEntitySummary($object, $onlyForCurrentStore = true) $usedStoresId = array_keys($result); + /** @var Mage_Core_Model_Store $store */ foreach ($stores as $store) { if (!in_array($store->getId(), $usedStoresId)) { $clone = clone $object; @@ -307,23 +309,33 @@ protected function _getEntitySummaryData($object) $countColumn = new Zend_Db_Expr("COUNT(*)"); $select = $adapter->select() - ->from(array('rating_vote' => $this->getTable('rating/rating_option_vote')), + ->from( + array('rating_vote' => $this->getTable('rating/rating_option_vote')), array( 'entity_pk_value' => 'rating_vote.entity_pk_value', 'sum' => $sumColumn, - 'count' => $countColumn)) - ->join(array('review' => $this->getTable('review/review')), + 'count' => $countColumn) + ) + ->join( + array('review' => $this->getTable('review/review')), 'rating_vote.review_id=review.review_id', - array()) - ->joinLeft(array('review_store' => $this->getTable('review/review_store')), + array() + ) + ->joinLeft( + array('review_store' => $this->getTable('review/review_store')), 'rating_vote.review_id=review_store.review_id', - array('review_store.store_id')) - ->join(array('rating_store' => $this->getTable('rating/rating_store')), + array('review_store.store_id') + ) + ->join( + array('rating_store' => $this->getTable('rating/rating_store')), 'rating_store.rating_id = rating_vote.rating_id AND rating_store.store_id = review_store.store_id', - array()) - ->join(array('review_status' => $this->getTable('review/review_status')), + array() + ) + ->join( + array('review_status' => $this->getTable('review/review_status')), 'review.status_id = review_status.status_id', - array()) + array() + ) ->where('review_status.status_code = :status_code') ->group('rating_vote.entity_pk_value') ->group('review_store.store_id'); @@ -343,7 +355,7 @@ protected function _getEntitySummaryData($object) * * @param Mage_Rating_Model_Rating $object * @param boolean $onlyForCurrentStore - * @return array + * @return array|Mage_Rating_Model_Rating */ public function getReviewSummary($object, $onlyForCurrentStore = true) { @@ -352,17 +364,23 @@ public function getReviewSummary($object, $onlyForCurrentStore = true) $sumColumn = new Zend_Db_Expr("SUM(rating_vote.{$adapter->quoteIdentifier('percent')})"); $countColumn = new Zend_Db_Expr('COUNT(*)'); $select = $adapter->select() - ->from(array('rating_vote' => $this->getTable('rating/rating_option_vote')), + ->from( + array('rating_vote' => $this->getTable('rating/rating_option_vote')), array( 'sum' => $sumColumn, 'count' => $countColumn - )) - ->joinLeft(array('review_store' => $this->getTable('review/review_store')), + ) + ) + ->joinLeft( + array('review_store' => $this->getTable('review/review_store')), 'rating_vote.review_id = review_store.review_id', - array('review_store.store_id')) - ->join(array('rating_store' => $this->getTable('rating/rating_store')), + array('review_store.store_id') + ) + ->join( + array('rating_store' => $this->getTable('rating/rating_store')), 'rating_store.rating_id = rating_vote.rating_id AND rating_store.store_id = review_store.store_id', - array()) + array() + ) ->where('rating_vote.review_id = :review_id') ->group('rating_vote.review_id') ->group('review_store.store_id'); @@ -390,15 +408,15 @@ public function getReviewSummary($object, $onlyForCurrentStore = true) $usedStoresId = array_keys($result); + /** @var Mage_Core_Model_Store $store */ foreach ($stores as $store) { - if (!in_array($store->getId(), $usedStoresId)) { - $clone = clone $object; + if (!in_array($store->getId(), $usedStoresId)) { + $clone = clone $object; $clone->setCount(0); $clone->setSum(0); $clone->setStoreId($store->getId()); $result[$store->getId()] = $clone; - - } + } } return array_values($result); diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Collection.php b/app/code/core/Mage/Rating/Model/Resource/Rating/Collection.php index 6b928c86bd5..fbe5b139704 100644 --- a/app/code/core/Mage/Rating/Model/Resource/Rating/Collection.php +++ b/app/code/core/Mage/Rating/Model/Resource/Rating/Collection.php @@ -30,6 +30,8 @@ * @category Mage * @package Mage_Rating * @author Magento Core Team + * + * @method Mage_Rating_Model_Rating getItemById() */ class Mage_Rating_Model_Resource_Rating_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract { @@ -58,18 +60,24 @@ public function addEntityFilter($entity) $adapter = $this->getConnection(); $this->getSelect() - ->join($this->getTable('rating_entity'), + ->join( + $this->getTable('rating_entity'), 'main_table.entity_id=' . $this->getTable('rating_entity') . '.entity_id', - array('entity_code')); + array('entity_code') + ); if (is_numeric($entity)) { - $this->addFilter('entity', + $this->addFilter( + 'entity', $adapter->quoteInto($this->getTable('rating_entity') . '.entity_id=?', $entity), - 'string'); + 'string' + ); } elseif (is_string($entity)) { - $this->addFilter('entity', + $this->addFilter( + 'entity', $adapter->quoteInto($this->getTable('rating_entity') . '.entity_code=?', $entity), - 'string'); + 'string' + ); } return $this; } @@ -80,7 +88,7 @@ public function addEntityFilter($entity) * @param string $dir * @return Mage_Rating_Model_Resource_Rating_Collection */ - public function setPositionOrder($dir='ASC') + public function setPositionOrder($dir = 'ASC') { $this->setOrder('main_table.position', $dir); return $this; @@ -89,7 +97,7 @@ public function setPositionOrder($dir='ASC') /** * Set store filter * - * @param int_type $storeId + * @param int $storeId * @return $this */ public function setStoreFilter($storeId) @@ -107,7 +115,8 @@ public function setStoreFilter($storeId) ->join( array('store'=>$this->getTable('rating_store')), 'main_table.rating_id = store.rating_id', - array()) + array() + ) // ->group('main_table.rating_id') ; $this->_isStoreJoined = true; @@ -166,23 +175,29 @@ public function addEntitySummaryToItem($entityPkValue, $storeId) $sumCond = new Zend_Db_Expr("SUM(rating_option_vote.{$adapter->quoteIdentifier('percent')})"); $countCond = new Zend_Db_Expr('COUNT(*)'); $select = $adapter->select() - ->from(array('rating_option_vote' => $this->getTable('rating/rating_option_vote')), + ->from( + array('rating_option_vote' => $this->getTable('rating/rating_option_vote')), array( 'rating_id' => 'rating_option_vote.rating_id', 'sum' => $sumCond, 'count' => $countCond - )) + ) + ) ->join( array('review_store' => $this->getTable('review/review_store')), 'rating_option_vote.review_id=review_store.review_id AND review_store.store_id = :store_id', - array()) + array() + ) ->join( array('rst' => $this->getTable('rating/rating_store')), 'rst.rating_id = rating_option_vote.rating_id AND rst.store_id = :rst_store_id', - array()) - ->join(array('review' => $this->getTable('review/review')), + array() + ) + ->join( + array('review' => $this->getTable('review/review')), 'review_store.review_id=review.review_id AND review.status_id=1', - array()) + array() + ) ->where($inCond) ->where('rating_option_vote.entity_pk_value=:pk_value') ->group('rating_option_vote.rating_id'); @@ -213,9 +228,11 @@ public function addRatingPerStoreName($storeId) $adapter = $this->getConnection(); $ratingCodeCond = $adapter->getIfNullSql('title.value', 'main_table.rating_code'); $this->getSelect() - ->joinLeft(array('title' => $this->getTable('rating_title')), + ->joinLeft( + array('title' => $this->getTable('rating_title')), $adapter->quoteInto('main_table.rating_id=title.rating_id AND title.store_id = ?', (int) $storeId), - array('rating_code' => $ratingCodeCond)); + array('rating_code' => $ratingCodeCond) + ); return $this; } diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Option.php b/app/code/core/Mage/Rating/Model/Resource/Rating/Option.php index d791d2c80ad..c9809c6309d 100644 --- a/app/code/core/Mage/Rating/Model/Resource/Rating/Option.php +++ b/app/code/core/Mage/Rating/Model/Resource/Rating/Option.php @@ -185,20 +185,29 @@ public function aggregateEntityByRatingId($ratingId, $entityPkValue) $appVoteValueSumCond = $readAdapter->getCheckSql('review.status_id=1', 'vote.value', '0'); $select = $readAdapter->select() - ->from(array('vote'=>$this->_ratingVoteTable), + ->from( + array('vote'=>$this->_ratingVoteTable), array( 'vote_count' => new Zend_Db_Expr('COUNT(vote.vote_id)'), 'vote_value_sum' => new Zend_Db_Expr('SUM(vote.value)'), 'app_vote_count' => new Zend_Db_Expr("COUNT({$appVoteCountCond})"), - 'app_vote_value_sum' => new Zend_Db_Expr("SUM({$appVoteValueSumCond})") )) - ->join(array('review' =>$this->_reviewTable), + 'app_vote_value_sum' => new Zend_Db_Expr("SUM({$appVoteValueSumCond})") ) + ) + ->join( + array('review' =>$this->_reviewTable), 'vote.review_id=review.review_id', - array()) - ->joinLeft(array('store'=>$this->_reviewStoreTable), - 'vote.review_id=store.review_id', 'store_id') - ->join(array('rstore' =>$this->_ratingStoreTable), + array() + ) + ->joinLeft( + array('store'=>$this->_reviewStoreTable), + 'vote.review_id=store.review_id', + 'store_id' + ) + ->join( + array('rstore' =>$this->_ratingStoreTable), 'vote.rating_id=rstore.rating_id AND rstore.store_id=store.store_id', - array()) + array() + ) ->where('vote.rating_id = :rating_id') ->where('vote.entity_pk_value = :pk_value') ->group(array( @@ -263,5 +272,4 @@ public function loadDataById($optionId) return $this->_optionData; } - } diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Collection.php b/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Collection.php index c1b3a73acd2..083b8f612eb 100644 --- a/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Collection.php +++ b/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Collection.php @@ -64,7 +64,7 @@ protected function _construct() * Add rating filter * * @param int|array $rating - * @return Mage_Rating_Model_Resource_Rating_Option_Collection + * @return $this */ public function addRatingFilter($rating) { @@ -80,9 +80,9 @@ public function addRatingFilter($rating) * Set order by position field * * @param string $dir - * @return Mage_Rating_Model_Resource_Rating_Option_Collection + * @return $this */ - public function setPositionOrder($dir='ASC') + public function setPositionOrder($dir = 'ASC') { $this->setOrder('main_table.position', $dir); return $this; diff --git a/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Vote/Collection.php b/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Vote/Collection.php index 223e66f8320..17589fbcb7f 100644 --- a/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Vote/Collection.php +++ b/app/code/core/Mage/Rating/Model/Resource/Rating/Option/Vote/Collection.php @@ -30,6 +30,8 @@ * @category Mage * @package Mage_Rating * @author Magento Core Team + * + * @method Mage_Rating_Model_Rating_Option_Vote[] getItems() */ class Mage_Rating_Model_Resource_Rating_Option_Vote_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract { @@ -77,11 +79,14 @@ public function setEntityPkFilter($entityId) public function setStoreFilter($storeId) { $this->getSelect() - ->join(array('rstore'=>$this->getTable('review/review_store')), + ->join( + array('rstore'=>$this->getTable('review/review_store')), $this->getConnection()->quoteInto( 'main_table.review_id=rstore.review_id AND rstore.store_id=?', - (int)$storeId), - array()); + (int)$storeId + ), + array() + ); return $this; } @@ -91,7 +96,7 @@ public function setStoreFilter($storeId) * @param int $storeId * @return $this */ - public function addRatingInfo($storeId=null) + public function addRatingInfo($storeId = null) { $adapter=$this->getConnection(); $ratingCodeCond = $adapter->getIfNullSql('title.value', 'rating.rating_code'); @@ -99,12 +104,16 @@ public function addRatingInfo($storeId=null) ->join( array('rating' => $this->getTable('rating/rating')), 'rating.rating_id = main_table.rating_id', - array('rating_code')) + array('rating_code') + ) ->joinLeft( array('title' => $this->getTable('rating/rating_title')), - $adapter->quoteInto('main_table.rating_id=title.rating_id AND title.store_id = ?', - (int)Mage::app()->getStore()->getId()), - array('rating_code' => $ratingCodeCond)); + $adapter->quoteInto( + 'main_table.rating_id=title.rating_id AND title.store_id = ?', + (int)Mage::app()->getStore()->getId() + ), + array('rating_code' => $ratingCodeCond) + ); if ($storeId == null) { $storeId = Mage::app()->getStore()->getId(); @@ -121,7 +130,8 @@ public function addRatingInfo($storeId=null) $this->getSelect() ->join( array('store' => $this->getTable('rating_store')), - 'main_table.rating_id = store.rating_id AND ' . $condition) + 'main_table.rating_id = store.rating_id AND ' . $condition + ) // ->group('main_table.vote_id') ; @@ -137,8 +147,10 @@ public function addRatingInfo($storeId=null) public function addOptionInfo() { $this->getSelect() - ->join(array('rating_option' => $this->getTable('rating/rating_option')), - 'main_table.option_id = rating_option.option_id'); + ->join( + array('rating_option' => $this->getTable('rating/rating_option')), + 'main_table.option_id = rating_option.option_id' + ); return $this; } @@ -161,7 +173,7 @@ public function addRatingOptions() if ($item->getRatingId()) { $item->setRatingOptions($options); } else { - return; + return $this; } } return $this; diff --git a/app/code/core/Mage/Rating/data/rating_setup/data-install-1.6.0.0.php b/app/code/core/Mage/Rating/data/rating_setup/data-install-1.6.0.0.php index f7e128bacea..977cd10c058 100644 --- a/app/code/core/Mage/Rating/data/rating_setup/data-install-1.6.0.0.php +++ b/app/code/core/Mage/Rating/data/rating_setup/data-install-1.6.0.0.php @@ -32,7 +32,7 @@ * @author Magento Core Team */ -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer = $this; $data = array( diff --git a/app/code/core/Mage/Rating/sql/rating_setup/install-1.6.0.0.php b/app/code/core/Mage/Rating/sql/rating_setup/install-1.6.0.0.php index 0508c0200bb..23da94b531d 100644 --- a/app/code/core/Mage/Rating/sql/rating_setup/install-1.6.0.0.php +++ b/app/code/core/Mage/Rating/sql/rating_setup/install-1.6.0.0.php @@ -32,7 +32,7 @@ * @author Magento Core Team */ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer->startSetup(); @@ -50,8 +50,11 @@ ->addColumn('entity_code', Varien_Db_Ddl_Table::TYPE_TEXT, 64, array( 'nullable' => false ), 'Entity Code') - ->addIndex($installer->getIdxName('rating/rating_entity', array('entity_code'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), - array('entity_code'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) + ->addIndex( + $installer->getIdxName('rating/rating_entity', array('entity_code'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), + array('entity_code'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) + ) ->setComment('Rating entities'); $installer->getConnection()->createTable($table); @@ -79,13 +82,23 @@ 'nullable' => false, 'default' => 0 ), 'Rating Position On Frontend') - ->addIndex($installer->getIdxName('rating/rating', array('rating_code'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), - array('rating_code'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)) - ->addIndex($installer->getIdxName('rating/rating', array('entity_id')), - array('entity_id')) - ->addForeignKey($installer->getFkName('rating/rating', 'entity_id', 'rating/rating_entity', 'entity_id'), - 'entity_id', $installer->getTable('rating/rating_entity'), 'entity_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addIndex( + $installer->getIdxName('rating/rating', array('rating_code'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), + array('rating_code'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) + ) + ->addIndex( + $installer->getIdxName('rating/rating', array('entity_id')), + array('entity_id') + ) + ->addForeignKey( + $installer->getFkName('rating/rating', 'entity_id', 'rating/rating_entity', 'entity_id'), + 'entity_id', + $installer->getTable('rating/rating_entity'), + 'entity_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) ->setComment('Ratings'); $installer->getConnection()->createTable($table); @@ -118,11 +131,18 @@ 'nullable' => false, 'default' => 0 ), 'Ration option position on frontend') - ->addIndex($installer->getIdxName('rating/rating_option', array('rating_id')), - array('rating_id')) - ->addForeignKey($installer->getFkName('rating/rating_option', 'rating_id', 'rating/rating', 'rating_id'), - 'rating_id', $installer->getTable('rating/rating'), 'rating_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addIndex( + $installer->getIdxName('rating/rating_option', array('rating_id')), + array('rating_id') + ) + ->addForeignKey( + $installer->getFkName('rating/rating_option', 'rating_id', 'rating/rating', 'rating_id'), + 'rating_id', + $installer->getTable('rating/rating'), + 'rating_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) ->setComment('Rating options'); $installer->getConnection()->createTable($table); @@ -174,11 +194,18 @@ 'nullable' => false, 'default' => 0 ), 'Vote option value') - ->addIndex($installer->getIdxName('rating/rating_option_vote', array('option_id')), - array('option_id')) - ->addForeignKey($installer->getFkName('rating/rating_option_vote', 'option_id', 'rating/rating_option', 'option_id'), - 'option_id', $installer->getTable('rating/rating_option'), 'option_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addIndex( + $installer->getIdxName('rating/rating_option_vote', array('option_id')), + array('option_id') + ) + ->addForeignKey( + $installer->getFkName('rating/rating_option_vote', 'option_id', 'rating/rating_option', 'option_id'), + 'option_id', + $installer->getTable('rating/rating_option'), + 'option_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) ->setComment('Rating option values'); $installer->getConnection()->createTable($table); @@ -224,16 +251,30 @@ 'nullable' => false, 'default' => 0 ), 'Store Id') - ->addIndex($installer->getIdxName('rating/rating_vote_aggregated', array('rating_id')), - array('rating_id')) - ->addIndex($installer->getIdxName('rating/rating_vote_aggregated', array('store_id')), - array('store_id')) - ->addForeignKey($installer->getFkName('rating/rating_vote_aggregated', 'rating_id', 'rating/rating', 'rating_id'), - 'rating_id', $installer->getTable('rating/rating'), 'rating_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) - ->addForeignKey($installer->getFkName('rating/rating_vote_aggregated', 'store_id', 'core/store', 'store_id'), - 'store_id', $installer->getTable('core/store'), 'store_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addIndex( + $installer->getIdxName('rating/rating_vote_aggregated', array('rating_id')), + array('rating_id') + ) + ->addIndex( + $installer->getIdxName('rating/rating_vote_aggregated', array('store_id')), + array('store_id') + ) + ->addForeignKey( + $installer->getFkName('rating/rating_vote_aggregated', 'rating_id', 'rating/rating', 'rating_id'), + 'rating_id', + $installer->getTable('rating/rating'), + 'rating_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->addForeignKey( + $installer->getFkName('rating/rating_vote_aggregated', 'store_id', 'core/store', 'store_id'), + 'store_id', + $installer->getTable('core/store'), + 'store_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) ->setComment('Rating vote aggregated'); $installer->getConnection()->createTable($table); @@ -254,14 +295,26 @@ 'default' => 0, 'primary' => true ), 'Store id') - ->addIndex($installer->getIdxName('rating/rating_store', array('store_id')), - array('store_id')) - ->addForeignKey($installer->getFkName('rating/rating_store', 'store_id', 'core/store', 'store_id'), - 'store_id', $installer->getTable('core/store'), 'store_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) - ->addForeignKey($installer->getFkName('rating/rating_store', 'rating_id', 'rating/rating', 'rating_id'), - 'rating_id', $installer->getTable('rating/rating'), 'rating_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_NO_ACTION) + ->addIndex( + $installer->getIdxName('rating/rating_store', array('store_id')), + array('store_id') + ) + ->addForeignKey( + $installer->getFkName('rating/rating_store', 'store_id', 'core/store', 'store_id'), + 'store_id', + $installer->getTable('core/store'), + 'store_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->addForeignKey( + $installer->getFkName('rating/rating_store', 'rating_id', 'rating/rating', 'rating_id'), + 'rating_id', + $installer->getTable('rating/rating'), + 'rating_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_NO_ACTION + ) ->setComment('Rating Store'); $installer->getConnection()->createTable($table); @@ -285,14 +338,26 @@ ->addColumn('value', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( 'nullable' => false ), 'Rating Label') - ->addIndex($installer->getIdxName('rating/rating_title', array('store_id')), - array('store_id')) - ->addForeignKey($installer->getFkName('rating/rating_title', 'rating_id', 'rating/rating', 'rating_id'), - 'rating_id', $installer->getTable('rating/rating'), 'rating_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) - ->addForeignKey($installer->getFkName('rating/rating_title', 'store_id', 'core/store', 'store_id'), - 'store_id', $installer->getTable('core/store'), 'store_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE) + ->addIndex( + $installer->getIdxName('rating/rating_title', array('store_id')), + array('store_id') + ) + ->addForeignKey( + $installer->getFkName('rating/rating_title', 'rating_id', 'rating/rating', 'rating_id'), + 'rating_id', + $installer->getTable('rating/rating'), + 'rating_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->addForeignKey( + $installer->getFkName('rating/rating_title', 'store_id', 'core/store', 'store_id'), + 'store_id', + $installer->getTable('core/store'), + 'store_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) ->setComment('Rating Title'); $installer->getConnection()->createTable($table); @@ -302,8 +367,12 @@ */ $table = $installer->getConnection()->addForeignKey( $installer->getFkName('rating/rating_option_vote', 'review_id', 'review/review', 'review_id'), - $installer->getTable('rating/rating_option_vote'), 'review_id', - $installer->getTable('review/review'), 'review_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE); + $installer->getTable('rating/rating_option_vote'), + 'review_id', + $installer->getTable('review/review'), + 'review_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE +); $installer->endSetup(); diff --git a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-install-0.7.0.php b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-install-0.7.0.php index d8e65d0c2cd..5ea86df67bf 100644 --- a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-install-0.7.0.php +++ b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-install-0.7.0.php @@ -25,7 +25,7 @@ */ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer->startSetup(); diff --git a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-0.7.0-0.7.1.php b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-0.7.0-0.7.1.php index 1cc9cf388f6..ef6f4a7f071 100644 --- a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-0.7.0-0.7.1.php +++ b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-0.7.0-0.7.1.php @@ -33,7 +33,7 @@ */ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer->startSetup(); diff --git a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-0.7.1-0.7.2.php b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-0.7.1-0.7.2.php index 0b95743314e..3b7bd224881 100644 --- a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-0.7.1-0.7.2.php +++ b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-0.7.1-0.7.2.php @@ -25,7 +25,7 @@ */ $installer = $this; -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer->startSetup(); diff --git a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php index 76e0c4396ae..516da714ca8 100644 --- a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php +++ b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer = $this; $installer->startSetup(); diff --git a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php index 98822060568..79a92ebb9d1 100644 --- a/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php +++ b/app/code/core/Mage/Rating/sql/rating_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* @var $installer Mage_Core_Model_Resource_Setup */ +/* @var Mage_Core_Model_Resource_Setup $installer */ $installer = $this; $installer->startSetup(); @@ -51,4 +51,3 @@ ); $installer->endSetup(); -