Exporting Full Custom Grid Data
Trying to export the full grid data of a custom module. The function itself works but there's a limit of 20 (well a limit of how many rows are visible on the page). I need to export the full data from the button. I tried adding: $grid->setDefaultLimit(4000) but I realised that 4000 isn't always going to be correct. So I need something to say do all data. Here's my current function:
<?php
class Namespae_Module_Adminhtml_GridController extends Mage_Adminhtml_Controller_Action {
protected function _createSerializerBlock($inputName, Mage_Adminhtml_Block_Widget_Grid $gridBlock, $productsArray) {
return $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_ajax_serializer')
->setGridBlock($gridBlock)
->setProducts($productsArray)
->setInputElementName($inputName);
}
public function indexAction() {
$this->loadLayout();
$this->_setActiveMenu('adminhtml/grid/index');
$this->_addContent($this->getLayout()->createBlock('namespace_module/adminhtml_grid'));
$this->renderLayout();
}
public function exportCsvAction() {
$filename = 'inventory_report-' . date('d-m-Y') . '_' . date('H:i:s') . '.csv';
$grid = $this->getLayout()->createBlock('namespace_module/adminhtml_grid');
//$grid->setDefaultLimit(4000);
$this->_prepareDownloadResponse($filename, $grid->getCsvFile());
}
}
As I said, it all works but I need it for all data, not just what's visible on the screen.
How can I go about doing this??
module grid csv export
bumped to the homepage by Community♦ 3 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Trying to export the full grid data of a custom module. The function itself works but there's a limit of 20 (well a limit of how many rows are visible on the page). I need to export the full data from the button. I tried adding: $grid->setDefaultLimit(4000) but I realised that 4000 isn't always going to be correct. So I need something to say do all data. Here's my current function:
<?php
class Namespae_Module_Adminhtml_GridController extends Mage_Adminhtml_Controller_Action {
protected function _createSerializerBlock($inputName, Mage_Adminhtml_Block_Widget_Grid $gridBlock, $productsArray) {
return $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_ajax_serializer')
->setGridBlock($gridBlock)
->setProducts($productsArray)
->setInputElementName($inputName);
}
public function indexAction() {
$this->loadLayout();
$this->_setActiveMenu('adminhtml/grid/index');
$this->_addContent($this->getLayout()->createBlock('namespace_module/adminhtml_grid'));
$this->renderLayout();
}
public function exportCsvAction() {
$filename = 'inventory_report-' . date('d-m-Y') . '_' . date('H:i:s') . '.csv';
$grid = $this->getLayout()->createBlock('namespace_module/adminhtml_grid');
//$grid->setDefaultLimit(4000);
$this->_prepareDownloadResponse($filename, $grid->getCsvFile());
}
}
As I said, it all works but I need it for all data, not just what's visible on the screen.
How can I go about doing this??
module grid csv export
bumped to the homepage by Community♦ 3 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Trying to export the full grid data of a custom module. The function itself works but there's a limit of 20 (well a limit of how many rows are visible on the page). I need to export the full data from the button. I tried adding: $grid->setDefaultLimit(4000) but I realised that 4000 isn't always going to be correct. So I need something to say do all data. Here's my current function:
<?php
class Namespae_Module_Adminhtml_GridController extends Mage_Adminhtml_Controller_Action {
protected function _createSerializerBlock($inputName, Mage_Adminhtml_Block_Widget_Grid $gridBlock, $productsArray) {
return $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_ajax_serializer')
->setGridBlock($gridBlock)
->setProducts($productsArray)
->setInputElementName($inputName);
}
public function indexAction() {
$this->loadLayout();
$this->_setActiveMenu('adminhtml/grid/index');
$this->_addContent($this->getLayout()->createBlock('namespace_module/adminhtml_grid'));
$this->renderLayout();
}
public function exportCsvAction() {
$filename = 'inventory_report-' . date('d-m-Y') . '_' . date('H:i:s') . '.csv';
$grid = $this->getLayout()->createBlock('namespace_module/adminhtml_grid');
//$grid->setDefaultLimit(4000);
$this->_prepareDownloadResponse($filename, $grid->getCsvFile());
}
}
As I said, it all works but I need it for all data, not just what's visible on the screen.
How can I go about doing this??
module grid csv export
Trying to export the full grid data of a custom module. The function itself works but there's a limit of 20 (well a limit of how many rows are visible on the page). I need to export the full data from the button. I tried adding: $grid->setDefaultLimit(4000) but I realised that 4000 isn't always going to be correct. So I need something to say do all data. Here's my current function:
<?php
class Namespae_Module_Adminhtml_GridController extends Mage_Adminhtml_Controller_Action {
protected function _createSerializerBlock($inputName, Mage_Adminhtml_Block_Widget_Grid $gridBlock, $productsArray) {
return $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_ajax_serializer')
->setGridBlock($gridBlock)
->setProducts($productsArray)
->setInputElementName($inputName);
}
public function indexAction() {
$this->loadLayout();
$this->_setActiveMenu('adminhtml/grid/index');
$this->_addContent($this->getLayout()->createBlock('namespace_module/adminhtml_grid'));
$this->renderLayout();
}
public function exportCsvAction() {
$filename = 'inventory_report-' . date('d-m-Y') . '_' . date('H:i:s') . '.csv';
$grid = $this->getLayout()->createBlock('namespace_module/adminhtml_grid');
//$grid->setDefaultLimit(4000);
$this->_prepareDownloadResponse($filename, $grid->getCsvFile());
}
}
As I said, it all works but I need it for all data, not just what's visible on the screen.
How can I go about doing this??
module grid csv export
module grid csv export
asked Aug 25 '16 at 8:06
123TFO123TFO
64112
64112
bumped to the homepage by Community♦ 3 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 3 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Have you tried to extend getCsvFile() method?
Something like that should take of limiting and paging from your collection:
// ...
$this->getCollection()->getSelect()->limit();
$this->getCollection()->setPageSize(0);
$this->getCollection()->load();
foreach ($this->getCollection() as $item) {
$io->streamWriteCsv(array( // ...
I have not yet, will give it a go :)
– 123TFO
Aug 25 '16 at 9:04
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f132987%2fexporting-full-custom-grid-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Have you tried to extend getCsvFile() method?
Something like that should take of limiting and paging from your collection:
// ...
$this->getCollection()->getSelect()->limit();
$this->getCollection()->setPageSize(0);
$this->getCollection()->load();
foreach ($this->getCollection() as $item) {
$io->streamWriteCsv(array( // ...
I have not yet, will give it a go :)
– 123TFO
Aug 25 '16 at 9:04
add a comment |
Have you tried to extend getCsvFile() method?
Something like that should take of limiting and paging from your collection:
// ...
$this->getCollection()->getSelect()->limit();
$this->getCollection()->setPageSize(0);
$this->getCollection()->load();
foreach ($this->getCollection() as $item) {
$io->streamWriteCsv(array( // ...
I have not yet, will give it a go :)
– 123TFO
Aug 25 '16 at 9:04
add a comment |
Have you tried to extend getCsvFile() method?
Something like that should take of limiting and paging from your collection:
// ...
$this->getCollection()->getSelect()->limit();
$this->getCollection()->setPageSize(0);
$this->getCollection()->load();
foreach ($this->getCollection() as $item) {
$io->streamWriteCsv(array( // ...
Have you tried to extend getCsvFile() method?
Something like that should take of limiting and paging from your collection:
// ...
$this->getCollection()->getSelect()->limit();
$this->getCollection()->setPageSize(0);
$this->getCollection()->load();
foreach ($this->getCollection() as $item) {
$io->streamWriteCsv(array( // ...
answered Aug 25 '16 at 8:52
jimmyjimmy
787
787
I have not yet, will give it a go :)
– 123TFO
Aug 25 '16 at 9:04
add a comment |
I have not yet, will give it a go :)
– 123TFO
Aug 25 '16 at 9:04
I have not yet, will give it a go :)
– 123TFO
Aug 25 '16 at 9:04
I have not yet, will give it a go :)
– 123TFO
Aug 25 '16 at 9:04
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f132987%2fexporting-full-custom-grid-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown