This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for transactions grid collection not being reloaded properly
The extension relies on the fact that a new collection object is created during the second call to _prepareCollection(). This doesn't happen with the transactions grid, because it always first looks to see if there is a collection already set. It does this because there is a subclass which also creates a collection, and utilises this class to do most of the work. We don't need this for the main transactions grid, so we unset the collection before calling _prepareCollection() for the 2nd time. This makes everything work a lot more nicely.
- Loading branch information
Matthew Gamble
committed
Aug 3, 2015
1 parent
024e39c
commit 6a9d8e1
Showing
4 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
app/code/community/BL/CustomGrid/Model/Grid/Type/Sales/Transactions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* | ||
* @category BL | ||
* @package BL_CustomGrid | ||
* @copyright Copyright (c) 2014 Benoît Leulliette <[email protected]> | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
class BL_CustomGrid_Model_Grid_Type_Sales_Transactions extends BL_CustomGrid_Model_Grid_Type_Abstract | ||
{ | ||
/** | ||
* @return string[]|string | ||
*/ | ||
protected function _getSupportedBlockTypes() | ||
{ | ||
return array('adminhtml/sales_transactions_grid'); | ||
} | ||
|
||
/** | ||
* Do some actions before grid collection is prepared | ||
* | ||
* @param Mage_Adminhtml_Block_Widget_Grid $gridBlock Grid block | ||
* @param bool $firstTime Whether this is the first (= incomplete) grid collection preparation | ||
* @return BL_CustomGrid_Model_Grid_Type_Sales_Transactions | ||
*/ | ||
public function beforeGridPrepareCollection(Mage_Adminhtml_Block_Widget_Grid $gridBlock, $firstTime = true) | ||
{ | ||
if (!$firstTime) { | ||
$gridBlock->blcg_addCollectionCallback( | ||
'before_prepare', | ||
array($this, 'removeFirstTimeCollection'), | ||
array(), | ||
true | ||
); | ||
} | ||
return $this; | ||
} | ||
|
||
/** | ||
* When calling _prepareCollection(), this grid by default looks to see if one is already set, rather | ||
* than just overriding any existing collection. This is unique in Magento, and causes all sorts of | ||
* problems because the collection has already been loaded. | ||
* | ||
* @param Mage_Adminhtml_Block_Widget_Grid $gridBlock | ||
* @param Varien_Data_Collection_Db $collection | ||
* @param bool $firstTime | ||
*/ | ||
public function removeFirstTimeCollection( | ||
Mage_Adminhtml_Block_Widget_Grid $gridBlock, | ||
Varien_Data_Collection_Db $collection, | ||
$firstTime | ||
) { | ||
if (!$firstTime) { | ||
$gridBlock->blcg_unsetCollection(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters