Skip to content

Commit cb3fbba

Browse files
committed
moved duplicate code to parent class
1 parent 08e4ed2 commit cb3fbba

File tree

3 files changed

+40
-78
lines changed

3 files changed

+40
-78
lines changed

app/code/core/Mage/Reports/Model/Resource/Report/Collection/Abstract.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,44 @@ public function load($printQuery = false, $logQuery = false)
268268
}
269269
return parent::load($printQuery, $logQuery);
270270
}
271+
272+
273+
/**
274+
* Get SQL for get record count
275+
*
276+
* @return Varien_Db_Select
277+
*/
278+
public function getSelectCountSql()
279+
{
280+
$this->_renderFilters();
281+
$select = clone $this->getSelect();
282+
$select->reset(Zend_Db_Select::ORDER);
283+
return $this->getConnection()->select()->from($select, 'COUNT(*)');
284+
}
285+
286+
/**
287+
* Set ids for store restrictions
288+
*
289+
* @param array $storeIds
290+
* @return $this
291+
*/
292+
public function addStoreRestrictions($storeIds)
293+
{
294+
if (!is_array($storeIds)) {
295+
$storeIds = [$storeIds];
296+
}
297+
$currentStoreIds = $this->_storesIds;
298+
if (isset($currentStoreIds) && $currentStoreIds != Mage_Core_Model_App::ADMIN_STORE_ID
299+
&& $currentStoreIds != [Mage_Core_Model_App::ADMIN_STORE_ID]
300+
) {
301+
if (!is_array($currentStoreIds)) {
302+
$currentStoreIds = [$currentStoreIds];
303+
}
304+
$this->_storesIds = array_intersect($currentStoreIds, $storeIds);
305+
} else {
306+
$this->_storesIds = $storeIds;
307+
}
308+
309+
return $this;
310+
}
271311
}

app/code/core/Mage/Reports/Model/Resource/Report/Product/Viewed/Collection.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -157,45 +157,6 @@ protected function _initSelect()
157157
return $this;
158158
}
159159

160-
/**
161-
* Get SQL for get record count
162-
*
163-
* @return Varien_Db_Select
164-
*/
165-
public function getSelectCountSql()
166-
{
167-
$this->_renderFilters();
168-
$select = clone $this->getSelect();
169-
$select->reset(Zend_Db_Select::ORDER);
170-
return $this->getConnection()->select()->from($select, 'COUNT(*)');
171-
}
172-
173-
/**
174-
* Set ids for store restrictions
175-
*
176-
* @param array $storeIds
177-
* @return $this
178-
*/
179-
public function addStoreRestrictions($storeIds)
180-
{
181-
if (!is_array($storeIds)) {
182-
$storeIds = [$storeIds];
183-
}
184-
$currentStoreIds = $this->_storesIds;
185-
if (isset($currentStoreIds) && $currentStoreIds != Mage_Core_Model_App::ADMIN_STORE_ID
186-
&& $currentStoreIds != [Mage_Core_Model_App::ADMIN_STORE_ID]
187-
) {
188-
if (!is_array($currentStoreIds)) {
189-
$currentStoreIds = [$currentStoreIds];
190-
}
191-
$this->_storesIds = array_intersect($currentStoreIds, $storeIds);
192-
} else {
193-
$this->_storesIds = $storeIds;
194-
}
195-
196-
return $this;
197-
}
198-
199160
/**
200161
* Redeclare parent method for applying filters after parent method
201162
* but before adding unions and calculating totals

app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -158,45 +158,6 @@ protected function _initSelect()
158158
return $this;
159159
}
160160

161-
/**
162-
* Get SQL for get record count
163-
*
164-
* @return Varien_Db_Select
165-
*/
166-
public function getSelectCountSql()
167-
{
168-
$this->_renderFilters();
169-
$select = clone $this->getSelect();
170-
$select->reset(Zend_Db_Select::ORDER);
171-
return $this->getConnection()->select()->from($select, 'COUNT(*)');
172-
}
173-
174-
/**
175-
* Set ids for store restrictions
176-
*
177-
* @param array $storeIds
178-
* @return $this
179-
*/
180-
public function addStoreRestrictions($storeIds)
181-
{
182-
if (!is_array($storeIds)) {
183-
$storeIds = [$storeIds];
184-
}
185-
$currentStoreIds = $this->_storesIds;
186-
if (isset($currentStoreIds) && $currentStoreIds != Mage_Core_Model_App::ADMIN_STORE_ID
187-
&& $currentStoreIds != [Mage_Core_Model_App::ADMIN_STORE_ID]
188-
) {
189-
if (!is_array($currentStoreIds)) {
190-
$currentStoreIds = [$currentStoreIds];
191-
}
192-
$this->_storesIds = array_intersect($currentStoreIds, $storeIds);
193-
} else {
194-
$this->_storesIds = $storeIds;
195-
}
196-
197-
return $this;
198-
}
199-
200161
/**
201162
* Redeclare parent method for applying filters after parent method
202163
* but before adding unions and calculating totals

0 commit comments

Comments
 (0)