Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for issue #292 #299

Closed
wants to merge 2 commits into from

2 participants

@ihor-sviziev

Fix for issue #292

@verklov

Hello igor-svizev,
Sorry for the delay with the response.
Thank you for your contribution! Could you please provide more information related to what was the reason for the refactoring that you offer and which issues you tried to solve with it?

@ihor-sviziev

Hi verklov,
For before refactoring we haven't ability to add store information to rating collection if it was loaded before.
Also after refactoring we have same interface for adding store information for rating and reviews.

@mage2-team mage2-team referenced this pull request from a commit
@mage2-team mage2-team 2.0.0.0-dev56
* Fixed bugs:
  * Fixed placing order with PayPal Payments Advanced and Payflow Link
  * Fixed losing previously assigned categories after saving the product with changed category selector field
  * Fixed losing of a newly created category assignment after variations generation during Configurable product or Gift Card creation
  * Fixed the error in order placement with Recurring profile payment
* GitHub requests:
  * [#299](#299) -- Fix for issue Refactor Mage_Rating_Model_Resource_Rating_Collection
  * [#341](#341) -- Replacing simple preg calls with less expensive alternates
* Modularity improvements:
  * Layout page type config moved to library
  * Design loader moved to library
  * Theme label moved to library
* Themes update:
  * Reduced amount of templates and layouts in magento_plushe theme
  * Responsive design improvements
* Integrity improvements:
  * Covered all Magento classes with argument sequence validator
  * Added arguments type duplication validator
* Implemented API Integration UX flows:
  * Ability to create and edit API Integrations
  * Ability to delete API integrations that were not created using configuration files
* Removed System REST menu item and all associated UX flows:
  * Users, Roles, and Webhook Subscriptions sub-menu items were removed
* Removed the Webhook module
86db2ed
@verklov

igor-svizev,
Our team has processed your pull request. The code is available in the version dev56 recently released.

Thank you for your contribution! Looking forward for your new contributions.

@verklov verklov closed this
@ihor-sviziev

Thanks!

@ihor-sviziev ihor-sviziev deleted the unknown repository branch
@SchumacherFM SchumacherFM referenced this pull request from a commit
@SchumacherFM SchumacherFM Merge remote-tracking branch 'upstream/master'
* upstream/master:
  2.0.0.0-dev56 * Fixed bugs:   * Fixed placing order with PayPal Payments Advanced and Payflow Link   * Fixed losing previously assigned categories after saving the product with changed category selector field   * Fixed losing of a newly created category assignment after variations generation during Configurable product or Gift Card creation   * Fixed the error in order placement with Recurring profile payment * GitHub requests:   * [#299](#299) -- Fix for issue Refactor Mage_Rating_Model_Resource_Rating_Collection   * [#341](#341) -- Replacing simple preg calls with less expensive alternates * Modularity improvements:   * Layout page type config moved to library   * Design loader moved to library   * Theme label moved to library * Themes update:   * Reduced amount of templates and layouts in magento_plushe theme   * Responsive design improvements * Integrity improvements:   * Covered all Magento classes with argument sequence validator   * Added arguments type duplication validator * Implemented API Integration UX flows:   * Ability to create and edit API Integrations   * Ability to delete API integrations that were not created using configuration files * Removed System REST menu item and all associated UX flows:   * Users, Roles, and Webhook Subscriptions sub-menu items were removed * Removed the Webhook module
02bea22
@Nas1k Nas1k referenced this pull request from a commit
@mage2-team mage2-team 2.0.0.0-dev56
* Fixed bugs:
  * Fixed placing order with PayPal Payments Advanced and Payflow Link
  * Fixed losing previously assigned categories after saving the product with changed category selector field
  * Fixed losing of a newly created category assignment after variations generation during Configurable product or Gift Card creation
  * Fixed the error in order placement with Recurring profile payment
* GitHub requests:
  * [#299](#299) -- Fix for issue Refactor Mage_Rating_Model_Resource_Rating_Collection
  * [#341](#341) -- Replacing simple preg calls with less expensive alternates
* Modularity improvements:
  * Layout page type config moved to library
  * Design loader moved to library
  * Theme label moved to library
* Themes update:
  * Reduced amount of templates and layouts in magento_plushe theme
  * Responsive design improvements
* Integrity improvements:
  * Covered all Magento classes with argument sequence validator
  * Added arguments type duplication validator
* Implemented API Integration UX flows:
  * Ability to create and edit API Integrations
  * Ability to delete API integrations that were not created using configuration files
* Removed System REST menu item and all associated UX flows:
  * Users, Roles, and Webhook Subscriptions sub-menu items were removed
* Removed the Webhook module
7ab9c33
@Nas1k Nas1k referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@Nas1k Nas1k referenced this pull request from a commit
@mage2-team mage2-team (split Module_Customer)2.0.0.0-dev56
* Fixed bugs:
  * Fixed placing order with PayPal Payments Advanced and Payflow Link
  * Fixed losing previously assigned categories after saving the product with changed category selector field
  * Fixed losing of a newly created category assignment after variations generation during Configurable product or Gift Card creation
  * Fixed the error in order placement with Recurring profile payment
* GitHub requests:
  * [#299](#299) -- Fix for issue Refactor Mage_Rating_Model_Resource_Rating_Collection
  * [#341](#341) -- Replacing simple preg calls with less expensive alternates
* Modularity improvements:
  * Layout page type config moved to library
  * Design loader moved to library
  * Theme label moved to library
* Themes update:
  * Reduced amount of templates and layouts in magento_plushe theme
  * Responsive design improvements
* Integrity improvements:
  * Covered all Magento classes with argument sequence validator
  * Added arguments type duplication validator
* Implemented API Integration UX flows:
  * Ability to create and edit API Integrations
  * Ability to delete API integrations that were not created using configuration files
* Removed System REST menu item and all associated UX flows:
  * Users, Roles, and Webhook Subscriptions sub-menu items were removed
* Removed the Webhook module
57841b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 68 additions and 18 deletions.
  1. +68 −18 app/code/Mage/Rating/Model/Resource/Rating/Collection.php
View
86 app/code/Mage/Rating/Model/Resource/Rating/Collection.php
@@ -41,6 +41,12 @@ class Mage_Rating_Model_Resource_Rating_Collection extends Mage_Core_Model_Resou
protected $_app;
/**
+ * Add store data flag
+ * @var bool
+ */
+ protected $_addStoreDataFlag = false;
+
+ /**
* Collection constructor
*
* @param Mage_Core_Model_Resource_Db_Abstract $resource
@@ -99,7 +105,7 @@ public function addEntityFilter($entity)
}
/**
- * set order by position field
+ * Set order by position field
*
* @param string $dir
* @return Mage_Rating_Model_Resource_Rating_Collection
@@ -113,7 +119,7 @@ public function setPositionOrder($dir='ASC')
/**
* Set store filter
*
- * @param int_type $storeId
+ * @param int $storeId
* @return Mage_Rating_Model_Resource_Rating_Collection
*/
public function setStoreFilter($storeId)
@@ -253,18 +259,73 @@ public function addRatingPerStoreName($storeId)
}
/**
+ * Add stores data to collection
+ *
+ * @return Mage_Rating_Model_Resource_Rating_Collection
+ */
+ public function addStoreData() {
+ if (!$this->_app->isSingleStoreMode()) {
+ if (!$this->_isCollectionLoaded) {
+ $this->_addStoreDataFlag = true;
+ } elseif (!$this->_addStoreDataFlag) {
+ $this->_addStoreData();
+ }
+ }
+
+ return $this;
+ }
+
+ /**
* Add stores to collection
*
+ * @todo mate method deprecated
+ *
* @return Mage_Rating_Model_Resource_Rating_Collection
*/
public function addStoresToCollection()
{
- if ($this->_app->isSingleStoreMode()) {
+ return $this->addStoreData();
+ }
+
+ /**
+ * Set Active Filter
+ *
+ * @param bool $isActive
+ * @return Mage_Rating_Model_Resource_Rating_Collection
+ */
+ public function setActiveFilter($isActive = true)
+ {
+ $this->getSelect()->where('main_table.is_active=?', $isActive);
+ return $this;
+ }
+
+ /**
+ * Load data
+ *
+ * @param boolean $printQuery
+ * @param boolean $logQuery
+ * @return Mage_Review_Model_Resource_Review_Collection
+ */
+ public function load($printQuery = false, $logQuery = false)
+ {
+ if ($this->isLoaded()) {
return $this;
}
- if (!$this->_isCollectionLoaded) {
- return $this;
+ Mage::dispatchEvent('rating_rating_collection_load_before', array('collection' => $this));
+ parent::load($printQuery, $logQuery);
+ if ($this->_addStoreDataFlag) {
+ $this->_addStoreData();
}
+ return $this;
+ }
+
+ /**
+ * Add store data
+ *
+ * @return Mage_Review_Model_Resource_Review_Collection
+ */
+ protected function _addStoreData()
+ {
$ratingIds = array();
foreach ($this as $item) {
$ratingIds[] = $item->getId();
@@ -275,14 +336,14 @@ public function addStoresToCollection()
}
$adapter = $this->getConnection();
- $inCond = $adapter->prepareSqlCondition('rating_id', array(
+ $inCondition = $adapter->prepareSqlCondition('rating_id', array(
'in' => $ratingIds
));
$this->_select = $adapter
->select()
->from($this->getTable('rating_store'))
- ->where($inCond);
+ ->where($inCondition);
$data = $adapter->fetchAll($this->_select);
if (is_array($data) && count($data) > 0) {
@@ -291,18 +352,7 @@ public function addStoresToCollection()
$item->setStores(array_merge($item->getStores(), array($row['store_id'])));
}
}
- return $this;
- }
- /**
- * Set Active Filter
- *
- * @param bool $isActive
- * @return Mage_Rating_Model_Resource_Rating_Collection
- */
- public function setActiveFilter($isActive = true)
- {
- $this->getSelect()->where('main_table.is_active=?', $isActive);
return $this;
}
}
Something went wrong with that request. Please try again.