Exporting Full Custom Grid Data












0















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??










share|improve this question














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.




















    0















    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??










    share|improve this question














    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.


















      0












      0








      0








      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??










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      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.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          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( // ...





          share|improve this answer
























          • I have not yet, will give it a go :)

            – 123TFO
            Aug 25 '16 at 9:04











          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          0














          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( // ...





          share|improve this answer
























          • I have not yet, will give it a go :)

            – 123TFO
            Aug 25 '16 at 9:04
















          0














          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( // ...





          share|improve this answer
























          • I have not yet, will give it a go :)

            – 123TFO
            Aug 25 '16 at 9:04














          0












          0








          0







          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( // ...





          share|improve this answer













          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( // ...






          share|improve this answer












          share|improve this answer



          share|improve this answer










          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



















          • 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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          what is the purpose of having a “thru cal” on RF PCB?

          What does Gandalf whisper to the Moth on the Orthanc in Isengard?

          magento2 creating a lot of catalogrule_product_temp tables