diff --git a/app/code/community/BL/CustomGrid/Model/Grid/Exporter.php b/app/code/community/BL/CustomGrid/Model/Grid/Exporter.php
index ea90f90..8ecd851 100644
--- a/app/code/community/BL/CustomGrid/Model/Grid/Exporter.php
+++ b/app/code/community/BL/CustomGrid/Model/Grid/Exporter.php
@@ -76,8 +76,9 @@ protected function _exportTo($format, $config = null)
$typeModel->beforeGridExport($format, null);
/** @var $layout Mage_Core_Model_Layout */
$layout = Mage::getSingleton('core/layout');
+ /** @var $gridBlock Mage_Adminhtml_Block_Widget_Grid */
$gridBlock = $layout->createBlock($gridModel->getBlockType());
-
+
if (is_array($config)) {
$gridBlock->blcg_setExportConfig($config);
}
diff --git a/app/code/community/BL/CustomGrid/Model/Grid/Rewriter/Abstract.php b/app/code/community/BL/CustomGrid/Model/Grid/Rewriter/Abstract.php
index 4c3d7b4..43bf14d 100644
--- a/app/code/community/BL/CustomGrid/Model/Grid/Rewriter/Abstract.php
+++ b/app/code/community/BL/CustomGrid/Model/Grid/Rewriter/Abstract.php
@@ -15,8 +15,8 @@
abstract class BL_CustomGrid_Model_Grid_Rewriter_Abstract extends BL_CustomGrid_Object
{
- const REWRITE_CODE_VERSION = 3; // bump this value when significant changes are made to the rewriting code
-
+ const REWRITE_CODE_VERSION = 4; // bump this value when significant changes are made to the rewriting code
+
/**
* Return the fixed base of the rewriting class names used by the extension
*
@@ -108,7 +108,14 @@ protected function _getRewriteCode($blcgClassName, $originalClassName, $blockTyp
{
return 'class ' . $blcgClassName . ' extends ' . $originalClassName . '
{
+ /**
+ * @var BL_CustomGrid_Model_Grid
+ */
private $_blcg_gridModel = null;
+
+ /**
+ * @var BL_CustomGrid_Model_Grid_Type_Abstract
+ */
private $_blcg_typeModel = null;
private $_blcg_filterParam = null;
private $_blcg_exportConfig = null;
@@ -160,6 +167,12 @@ public function setCollection($collection)
return $return;
}
+
+ public function blcg_unsetCollection()
+ {
+ $this->_collection = null;
+ return $this;
+ }
public function getCollection()
{
@@ -259,9 +272,18 @@ public function _exportIterateCollection($callback, array $args)
$break = false;
$first = false;
$count = null;
-
+
+ if ($originalCollection instanceof Varien_Data_Collection_Db) {
+ $selectProperty = new ReflectionProperty(get_class($originalCollection), "_select");
+ $selectProperty->setAccessible(true);
+ $originalSelect = $originalCollection->getSelect();
+ }
while ($break !== true) {
$collection = clone $originalCollection;
+ if ($originalCollection instanceof Varien_Data_Collection_Db) {
+ $select = clone $originalSelect;
+ $selectProperty->setValue($collection, $select);
+ }
$collection->setPageSize($pageSize);
$collection->setCurPage($page);
diff --git a/app/code/community/BL/CustomGrid/Model/Grid/Type/Sales/Transactions.php b/app/code/community/BL/CustomGrid/Model/Grid/Type/Sales/Transactions.php
new file mode 100644
index 0000000..13aa3ad
--- /dev/null
+++ b/app/code/community/BL/CustomGrid/Model/Grid/Type/Sales/Transactions.php
@@ -0,0 +1,64 @@
+
+ * @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();
+ }
+ }
+}
diff --git a/app/code/community/BL/CustomGrid/etc/customgrid.xml b/app/code/community/BL/CustomGrid/etc/customgrid.xml
index 04a7f0b..cd881f7 100644
--- a/app/code/community/BL/CustomGrid/etc/customgrid.xml
+++ b/app/code/community/BL/CustomGrid/etc/customgrid.xml
@@ -489,7 +489,12 @@
-
+
+
+ Transactions
+ 240000
+
+
Other
1000000000