Magento 2: how can I remove columns in exported csv from order grid?How can I export fields which are not being displayed in admin grid?Export CSV file from order gridDataflow Profiles - Not amending customers - creating new oneCSV “Pick slip” from Sales Order GridIssue in Exporting CSV file from a custom moduleAdmin Grid - Remove columns from exportCan't find Magento attributes for Custom Export moduleCreate order progamatically with all parameter in magento 2?Magento 2 : Currency Symbol missing when exporting Saler Order GridHow to Spilt Address in Customer grid CSV Export

How can I prevent interns from being expendable?

The deliberate use of misleading terminology

Adding strings in lists together

Is floating in space similar to falling under gravity?

My player wants to cast multiple charges of magic missile from a wand

Possible nonclassical ion from a bicyclic system

find the Integer value after a string from a file

Differences between “pas vrai ?”, “c’est ça ?”, “hein ?”, and “n’est-ce pas ?”

Get LaTeX form from step by step solution

When a current flow in an inductor is interrupted, what limits the voltage rise?

Intuition behind eigenvalues of an adjacency matrix

Points within polygons in different projections

How was Apollo supposed to rendezvous in the case of a lunar abort?

What does "tea juice" mean in this context?

Is there an evolutionary advantage to having two heads?

In what episode of TOS did a character on the bridge make a comment about raising the number 1 to some power?

Fastest way to perform complex search on pandas dataframe

Modern approach to radio buttons

Expenditure in Poland - Forex doesn't have Zloty

count number of files in directory with a certain name

Can't connect to Internet in bash using Mac OS

Are there regional foods in Westeros?

Infinitely many hats

What caused the tendency for conservatives to not support climate change regulations?



Magento 2: how can I remove columns in exported csv from order grid?


How can I export fields which are not being displayed in admin grid?Export CSV file from order gridDataflow Profiles - Not amending customers - creating new oneCSV “Pick slip” from Sales Order GridIssue in Exporting CSV file from a custom moduleAdmin Grid - Remove columns from exportCan't find Magento attributes for Custom Export moduleCreate order progamatically with all parameter in magento 2?Magento 2 : Currency Symbol missing when exporting Saler Order GridHow to Spilt Address in Customer grid CSV Export






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I want remove columns while exporting order grid data in magento 2. I google it but didn't find solution. Like I want to remove these fields from exported csv.



  1. Payment Method

  2. Total Refunded

  3. Customer Group

  4. Grand Total (Base)

  5. Purchase Point

enter image description here










share|improve this question




























    2















    I want remove columns while exporting order grid data in magento 2. I google it but didn't find solution. Like I want to remove these fields from exported csv.



    1. Payment Method

    2. Total Refunded

    3. Customer Group

    4. Grand Total (Base)

    5. Purchase Point

    enter image description here










    share|improve this question
























      2












      2








      2








      I want remove columns while exporting order grid data in magento 2. I google it but didn't find solution. Like I want to remove these fields from exported csv.



      1. Payment Method

      2. Total Refunded

      3. Customer Group

      4. Grand Total (Base)

      5. Purchase Point

      enter image description here










      share|improve this question














      I want remove columns while exporting order grid data in magento 2. I google it but didn't find solution. Like I want to remove these fields from exported csv.



      1. Payment Method

      2. Total Refunded

      3. Customer Group

      4. Grand Total (Base)

      5. Purchase Point

      enter image description here







      magento-2.1 csv export order-grid






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 '17 at 16:59









      AbhishekAbhishek

      450824




      450824




















          4 Answers
          4






          active

          oldest

          votes


















          2














          Try following way:



          Create Vendor/Module/view/adminhtml/ui_component/sales_order_grid.xml




          <?xml version="1.0" encoding="UTF-8"?>
          <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
          <listingToolbar name="listing_top">
          <exportButton name="export_button" class="VendorModuleComponentExportButton" />
          </listingToolbar>
          </listing>


          And Create Vendor/Module/Component/ExportButton.php




          namespace VendorModuleComponent;

          use MagentoFrameworkViewElementUiComponentContextInterface;
          use MagentoFrameworkUrlInterface;

          class ExportButton extends MagentoUiComponentAbstractComponent

          /**
          * Component name
          */
          const NAME = 'exportButton';

          /**
          * @var MagentoFrameworkUrlInterface
          */
          protected $urlBuilder;

          /**
          * @param ContextInterface $context
          * @param UrlInterface $urlBuilder
          * @param array $components
          * @param array $data
          */
          public function __construct(
          ContextInterface $context,
          UrlInterface $urlBuilder,
          array $components = [],
          array $data = []
          )
          parent::__construct($context, $components, $data);
          $this->urlBuilder = $urlBuilder;


          /**
          * Get component name
          *
          * @return string
          */
          public function getComponentName()

          return static::NAME;


          /**
          * @return void
          */
          public function prepare()

          $config = $this->getData('config');
          if (isset($config['options']))
          $config['options'] = [];
          $this->setData('config', $config);

          parent::prepare();




          Clear cache.






          share|improve this answer























          • You can access exprt buttons options then, but in these options you cannot influence what columns will be exported.

            – skymeissner
            Sep 22 '17 at 8:27



















          0














          Right now it is not possible to change columns for export. See: https://github.com/magento/magento2/issues/3079






          share|improve this answer






























            0














            Extend MagentoUiModelExportConvertToCsv file in to your custom module to extend model file create di.xml





            and in your extended file add below conditions to remove unwanted columns and column value in order export CSV Format.



            if($component->getName()=='sales_order_grid')



             $fieldsVal = $this->metadataProvider->getFields($component);
            $removeFieldsArr = array('column names which you want to remove goes here ..');

            foreach($fieldsVal as $key=>$val)
            if(in_array($val,$removeFieldsArr))
            unset($fieldsVal[$key]);


            $fields = array_values($fieldsVal);

            else
            $fields = $this->metadataProvider->getFields($component);






            share|improve this answer






























              0














              Let me do that for you with step by step. 
              First Step: Register your export button in your: view/adminhtml/ui_component/[grid-view-id].xml



              <exportButton name="export_button" class="NamespaceAdvancedReportComponentExportButton">
              <argument name="data" xsi:type="array">
              <item name="config" xsi:type="array">
              <item name="component" xsi:type="string">Magento_Ui/js/grid/export</item>
              <item name="displayArea" xsi:type="string">dataGridActions</item>
              <item name="options" xsi:type="array">
              <item name="cvs" xsi:type="array">
              <item name="value" xsi:type="string">csv</item>
              <item name="label" xsi:type="string" translate="true">CSV</item>
              <item name="url" xsi:type="string">my_advancedreport/export/gridToCsv</item>
              </item>
              </item>
              </item>
              </argument>
              </exportButton>


              Of course, you need a controller to do this thing: 



              namespace NamespaceAdvancedReportControllerAdminhtmlExport;

              class GridToCsv extends MagentoUiControllerAdminhtmlExportGridToCsv

              const ADMIN_RESOURCE = 'My_AdvancedReport::advanced_invoice_report';



              Second Step: Modify your controller class to use custom Export Model. /code/Namespace/AdvancedReport/etc/di.xml (scope global or Adminhtml)



              <type name="NamespaceAdvancedReportModelExportConvertToCsv">
              <arguments>
              <argument name="metadataProvider" xsi:type="object">NamespaceAdvancedReportModelExportMetadataProvider</argument>
              </arguments>
              </type>
              <type name="NamespaceAdvancedReportControllerAdminhtmlExportGridToCsv">
              <arguments>
              <argument name="converter" xsi:type="object">NamespaceAdvancedReportModelExportConvertToCsv</argument>
              </arguments>
              </type>


              Custom data provider to get what are selected columns user have selected on Admin.
              app/code/Namespace/AdvancedReport/Model/Export/MetadataProvider.php
              about the idea I have used MagentoUiModelBookmarkManagement. to get stored grid for Admin User while User Edit selected or sort-ordered columns of the Report Grid.



              namespace NamespaceAdvancedReportModelExport;


              use MagentoFrameworkViewElementUiComponentInterface;
              use MagentoUiComponentMassActionFilter;
              use MagentoFrameworkLocaleResolverInterface;
              use MagentoFrameworkStdlibDateTimeTimezoneInterface;

              class MetadataProvider extends MagentoUiModelExportMetadataProvider

              /**
              * @var MagentoUiModelBookmarkManagement
              */
              protected $_bookmarkManagement;

              /**
              * MetadataProvider constructor.
              * @param Filter $filter
              * @param TimezoneInterface $localeDate
              * @param ResolverInterface $localeResolver
              * @param string $dateFormat
              * @param MagentoUiModelBookmarkManagement $bookmarkManagement
              * @param array $data
              */
              public function __construct(
              Filter $filter,
              TimezoneInterface $localeDate,
              ResolverInterface $localeResolver,
              MagentoUiModelBookmarkManagement $bookmarkManagement,
              $dateFormat = 'M j, Y H:i:s A',
              array $data = [])

              parent::__construct($filter, $localeDate, $localeResolver, $dateFormat, $data);
              $this->_bookmarkManagement = $bookmarkManagement;


              protected function getActiveColumns($component)
              $bookmark = $this->_bookmarkManagement->getByIdentifierNamespace('current', $component->getName());

              $config = $bookmark->getConfig();
              $columns = $config['current']['columns'];
              $_activeColumns = [];
              foreach ($columns as $column => $config)
              if(true === $config['visible'] && $column != 'ids')
              $_activeColumns[] = $column;


              return $_activeColumns;

              /**
              * @param UiComponentInterface $component
              * @return UiComponentInterface[]
              * @throws Exception
              */
              protected function getColumns(UiComponentInterface $component)

              if (!isset($this->columns[$component->getName()]))

              $activeColumns = $this->getActiveColumns($component);

              $columns = $this->getColumnsComponent($component);
              foreach ($columns->getChildComponents() as $column)
              if ($column->getData('config/label') && $column->getData('config/dataType') !== 'actions')
              if(in_array($column->getName(), $activeColumns))
              $this->columns[$component->getName()][$column->getName()] = $column;




              return $this->columns[$component->getName()];




              Done.






              share|improve this answer























                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%2f166610%2fmagento-2-how-can-i-remove-columns-in-exported-csv-from-order-grid%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                2














                Try following way:



                Create Vendor/Module/view/adminhtml/ui_component/sales_order_grid.xml




                <?xml version="1.0" encoding="UTF-8"?>
                <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
                <listingToolbar name="listing_top">
                <exportButton name="export_button" class="VendorModuleComponentExportButton" />
                </listingToolbar>
                </listing>


                And Create Vendor/Module/Component/ExportButton.php




                namespace VendorModuleComponent;

                use MagentoFrameworkViewElementUiComponentContextInterface;
                use MagentoFrameworkUrlInterface;

                class ExportButton extends MagentoUiComponentAbstractComponent

                /**
                * Component name
                */
                const NAME = 'exportButton';

                /**
                * @var MagentoFrameworkUrlInterface
                */
                protected $urlBuilder;

                /**
                * @param ContextInterface $context
                * @param UrlInterface $urlBuilder
                * @param array $components
                * @param array $data
                */
                public function __construct(
                ContextInterface $context,
                UrlInterface $urlBuilder,
                array $components = [],
                array $data = []
                )
                parent::__construct($context, $components, $data);
                $this->urlBuilder = $urlBuilder;


                /**
                * Get component name
                *
                * @return string
                */
                public function getComponentName()

                return static::NAME;


                /**
                * @return void
                */
                public function prepare()

                $config = $this->getData('config');
                if (isset($config['options']))
                $config['options'] = [];
                $this->setData('config', $config);

                parent::prepare();




                Clear cache.






                share|improve this answer























                • You can access exprt buttons options then, but in these options you cannot influence what columns will be exported.

                  – skymeissner
                  Sep 22 '17 at 8:27
















                2














                Try following way:



                Create Vendor/Module/view/adminhtml/ui_component/sales_order_grid.xml




                <?xml version="1.0" encoding="UTF-8"?>
                <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
                <listingToolbar name="listing_top">
                <exportButton name="export_button" class="VendorModuleComponentExportButton" />
                </listingToolbar>
                </listing>


                And Create Vendor/Module/Component/ExportButton.php




                namespace VendorModuleComponent;

                use MagentoFrameworkViewElementUiComponentContextInterface;
                use MagentoFrameworkUrlInterface;

                class ExportButton extends MagentoUiComponentAbstractComponent

                /**
                * Component name
                */
                const NAME = 'exportButton';

                /**
                * @var MagentoFrameworkUrlInterface
                */
                protected $urlBuilder;

                /**
                * @param ContextInterface $context
                * @param UrlInterface $urlBuilder
                * @param array $components
                * @param array $data
                */
                public function __construct(
                ContextInterface $context,
                UrlInterface $urlBuilder,
                array $components = [],
                array $data = []
                )
                parent::__construct($context, $components, $data);
                $this->urlBuilder = $urlBuilder;


                /**
                * Get component name
                *
                * @return string
                */
                public function getComponentName()

                return static::NAME;


                /**
                * @return void
                */
                public function prepare()

                $config = $this->getData('config');
                if (isset($config['options']))
                $config['options'] = [];
                $this->setData('config', $config);

                parent::prepare();




                Clear cache.






                share|improve this answer























                • You can access exprt buttons options then, but in these options you cannot influence what columns will be exported.

                  – skymeissner
                  Sep 22 '17 at 8:27














                2












                2








                2







                Try following way:



                Create Vendor/Module/view/adminhtml/ui_component/sales_order_grid.xml




                <?xml version="1.0" encoding="UTF-8"?>
                <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
                <listingToolbar name="listing_top">
                <exportButton name="export_button" class="VendorModuleComponentExportButton" />
                </listingToolbar>
                </listing>


                And Create Vendor/Module/Component/ExportButton.php




                namespace VendorModuleComponent;

                use MagentoFrameworkViewElementUiComponentContextInterface;
                use MagentoFrameworkUrlInterface;

                class ExportButton extends MagentoUiComponentAbstractComponent

                /**
                * Component name
                */
                const NAME = 'exportButton';

                /**
                * @var MagentoFrameworkUrlInterface
                */
                protected $urlBuilder;

                /**
                * @param ContextInterface $context
                * @param UrlInterface $urlBuilder
                * @param array $components
                * @param array $data
                */
                public function __construct(
                ContextInterface $context,
                UrlInterface $urlBuilder,
                array $components = [],
                array $data = []
                )
                parent::__construct($context, $components, $data);
                $this->urlBuilder = $urlBuilder;


                /**
                * Get component name
                *
                * @return string
                */
                public function getComponentName()

                return static::NAME;


                /**
                * @return void
                */
                public function prepare()

                $config = $this->getData('config');
                if (isset($config['options']))
                $config['options'] = [];
                $this->setData('config', $config);

                parent::prepare();




                Clear cache.






                share|improve this answer













                Try following way:



                Create Vendor/Module/view/adminhtml/ui_component/sales_order_grid.xml




                <?xml version="1.0" encoding="UTF-8"?>
                <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
                <listingToolbar name="listing_top">
                <exportButton name="export_button" class="VendorModuleComponentExportButton" />
                </listingToolbar>
                </listing>


                And Create Vendor/Module/Component/ExportButton.php




                namespace VendorModuleComponent;

                use MagentoFrameworkViewElementUiComponentContextInterface;
                use MagentoFrameworkUrlInterface;

                class ExportButton extends MagentoUiComponentAbstractComponent

                /**
                * Component name
                */
                const NAME = 'exportButton';

                /**
                * @var MagentoFrameworkUrlInterface
                */
                protected $urlBuilder;

                /**
                * @param ContextInterface $context
                * @param UrlInterface $urlBuilder
                * @param array $components
                * @param array $data
                */
                public function __construct(
                ContextInterface $context,
                UrlInterface $urlBuilder,
                array $components = [],
                array $data = []
                )
                parent::__construct($context, $components, $data);
                $this->urlBuilder = $urlBuilder;


                /**
                * Get component name
                *
                * @return string
                */
                public function getComponentName()

                return static::NAME;


                /**
                * @return void
                */
                public function prepare()

                $config = $this->getData('config');
                if (isset($config['options']))
                $config['options'] = [];
                $this->setData('config', $config);

                parent::prepare();




                Clear cache.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 29 '17 at 4:36









                Sohel RanaSohel Rana

                25k34663




                25k34663












                • You can access exprt buttons options then, but in these options you cannot influence what columns will be exported.

                  – skymeissner
                  Sep 22 '17 at 8:27


















                • You can access exprt buttons options then, but in these options you cannot influence what columns will be exported.

                  – skymeissner
                  Sep 22 '17 at 8:27

















                You can access exprt buttons options then, but in these options you cannot influence what columns will be exported.

                – skymeissner
                Sep 22 '17 at 8:27






                You can access exprt buttons options then, but in these options you cannot influence what columns will be exported.

                – skymeissner
                Sep 22 '17 at 8:27














                0














                Right now it is not possible to change columns for export. See: https://github.com/magento/magento2/issues/3079






                share|improve this answer



























                  0














                  Right now it is not possible to change columns for export. See: https://github.com/magento/magento2/issues/3079






                  share|improve this answer

























                    0












                    0








                    0







                    Right now it is not possible to change columns for export. See: https://github.com/magento/magento2/issues/3079






                    share|improve this answer













                    Right now it is not possible to change columns for export. See: https://github.com/magento/magento2/issues/3079







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 7 '17 at 22:06









                    MehdiMehdi

                    609721




                    609721





















                        0














                        Extend MagentoUiModelExportConvertToCsv file in to your custom module to extend model file create di.xml





                        and in your extended file add below conditions to remove unwanted columns and column value in order export CSV Format.



                        if($component->getName()=='sales_order_grid')



                         $fieldsVal = $this->metadataProvider->getFields($component);
                        $removeFieldsArr = array('column names which you want to remove goes here ..');

                        foreach($fieldsVal as $key=>$val)
                        if(in_array($val,$removeFieldsArr))
                        unset($fieldsVal[$key]);


                        $fields = array_values($fieldsVal);

                        else
                        $fields = $this->metadataProvider->getFields($component);






                        share|improve this answer



























                          0














                          Extend MagentoUiModelExportConvertToCsv file in to your custom module to extend model file create di.xml





                          and in your extended file add below conditions to remove unwanted columns and column value in order export CSV Format.



                          if($component->getName()=='sales_order_grid')



                           $fieldsVal = $this->metadataProvider->getFields($component);
                          $removeFieldsArr = array('column names which you want to remove goes here ..');

                          foreach($fieldsVal as $key=>$val)
                          if(in_array($val,$removeFieldsArr))
                          unset($fieldsVal[$key]);


                          $fields = array_values($fieldsVal);

                          else
                          $fields = $this->metadataProvider->getFields($component);






                          share|improve this answer

























                            0












                            0








                            0







                            Extend MagentoUiModelExportConvertToCsv file in to your custom module to extend model file create di.xml





                            and in your extended file add below conditions to remove unwanted columns and column value in order export CSV Format.



                            if($component->getName()=='sales_order_grid')



                             $fieldsVal = $this->metadataProvider->getFields($component);
                            $removeFieldsArr = array('column names which you want to remove goes here ..');

                            foreach($fieldsVal as $key=>$val)
                            if(in_array($val,$removeFieldsArr))
                            unset($fieldsVal[$key]);


                            $fields = array_values($fieldsVal);

                            else
                            $fields = $this->metadataProvider->getFields($component);






                            share|improve this answer













                            Extend MagentoUiModelExportConvertToCsv file in to your custom module to extend model file create di.xml





                            and in your extended file add below conditions to remove unwanted columns and column value in order export CSV Format.



                            if($component->getName()=='sales_order_grid')



                             $fieldsVal = $this->metadataProvider->getFields($component);
                            $removeFieldsArr = array('column names which you want to remove goes here ..');

                            foreach($fieldsVal as $key=>$val)
                            if(in_array($val,$removeFieldsArr))
                            unset($fieldsVal[$key]);


                            $fields = array_values($fieldsVal);

                            else
                            $fields = $this->metadataProvider->getFields($component);







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 2 at 11:57









                            NilimaNilima

                            1




                            1





















                                0














                                Let me do that for you with step by step. 
                                First Step: Register your export button in your: view/adminhtml/ui_component/[grid-view-id].xml



                                <exportButton name="export_button" class="NamespaceAdvancedReportComponentExportButton">
                                <argument name="data" xsi:type="array">
                                <item name="config" xsi:type="array">
                                <item name="component" xsi:type="string">Magento_Ui/js/grid/export</item>
                                <item name="displayArea" xsi:type="string">dataGridActions</item>
                                <item name="options" xsi:type="array">
                                <item name="cvs" xsi:type="array">
                                <item name="value" xsi:type="string">csv</item>
                                <item name="label" xsi:type="string" translate="true">CSV</item>
                                <item name="url" xsi:type="string">my_advancedreport/export/gridToCsv</item>
                                </item>
                                </item>
                                </item>
                                </argument>
                                </exportButton>


                                Of course, you need a controller to do this thing: 



                                namespace NamespaceAdvancedReportControllerAdminhtmlExport;

                                class GridToCsv extends MagentoUiControllerAdminhtmlExportGridToCsv

                                const ADMIN_RESOURCE = 'My_AdvancedReport::advanced_invoice_report';



                                Second Step: Modify your controller class to use custom Export Model. /code/Namespace/AdvancedReport/etc/di.xml (scope global or Adminhtml)



                                <type name="NamespaceAdvancedReportModelExportConvertToCsv">
                                <arguments>
                                <argument name="metadataProvider" xsi:type="object">NamespaceAdvancedReportModelExportMetadataProvider</argument>
                                </arguments>
                                </type>
                                <type name="NamespaceAdvancedReportControllerAdminhtmlExportGridToCsv">
                                <arguments>
                                <argument name="converter" xsi:type="object">NamespaceAdvancedReportModelExportConvertToCsv</argument>
                                </arguments>
                                </type>


                                Custom data provider to get what are selected columns user have selected on Admin.
                                app/code/Namespace/AdvancedReport/Model/Export/MetadataProvider.php
                                about the idea I have used MagentoUiModelBookmarkManagement. to get stored grid for Admin User while User Edit selected or sort-ordered columns of the Report Grid.



                                namespace NamespaceAdvancedReportModelExport;


                                use MagentoFrameworkViewElementUiComponentInterface;
                                use MagentoUiComponentMassActionFilter;
                                use MagentoFrameworkLocaleResolverInterface;
                                use MagentoFrameworkStdlibDateTimeTimezoneInterface;

                                class MetadataProvider extends MagentoUiModelExportMetadataProvider

                                /**
                                * @var MagentoUiModelBookmarkManagement
                                */
                                protected $_bookmarkManagement;

                                /**
                                * MetadataProvider constructor.
                                * @param Filter $filter
                                * @param TimezoneInterface $localeDate
                                * @param ResolverInterface $localeResolver
                                * @param string $dateFormat
                                * @param MagentoUiModelBookmarkManagement $bookmarkManagement
                                * @param array $data
                                */
                                public function __construct(
                                Filter $filter,
                                TimezoneInterface $localeDate,
                                ResolverInterface $localeResolver,
                                MagentoUiModelBookmarkManagement $bookmarkManagement,
                                $dateFormat = 'M j, Y H:i:s A',
                                array $data = [])

                                parent::__construct($filter, $localeDate, $localeResolver, $dateFormat, $data);
                                $this->_bookmarkManagement = $bookmarkManagement;


                                protected function getActiveColumns($component)
                                $bookmark = $this->_bookmarkManagement->getByIdentifierNamespace('current', $component->getName());

                                $config = $bookmark->getConfig();
                                $columns = $config['current']['columns'];
                                $_activeColumns = [];
                                foreach ($columns as $column => $config)
                                if(true === $config['visible'] && $column != 'ids')
                                $_activeColumns[] = $column;


                                return $_activeColumns;

                                /**
                                * @param UiComponentInterface $component
                                * @return UiComponentInterface[]
                                * @throws Exception
                                */
                                protected function getColumns(UiComponentInterface $component)

                                if (!isset($this->columns[$component->getName()]))

                                $activeColumns = $this->getActiveColumns($component);

                                $columns = $this->getColumnsComponent($component);
                                foreach ($columns->getChildComponents() as $column)
                                if ($column->getData('config/label') && $column->getData('config/dataType') !== 'actions')
                                if(in_array($column->getName(), $activeColumns))
                                $this->columns[$component->getName()][$column->getName()] = $column;




                                return $this->columns[$component->getName()];




                                Done.






                                share|improve this answer



























                                  0














                                  Let me do that for you with step by step. 
                                  First Step: Register your export button in your: view/adminhtml/ui_component/[grid-view-id].xml



                                  <exportButton name="export_button" class="NamespaceAdvancedReportComponentExportButton">
                                  <argument name="data" xsi:type="array">
                                  <item name="config" xsi:type="array">
                                  <item name="component" xsi:type="string">Magento_Ui/js/grid/export</item>
                                  <item name="displayArea" xsi:type="string">dataGridActions</item>
                                  <item name="options" xsi:type="array">
                                  <item name="cvs" xsi:type="array">
                                  <item name="value" xsi:type="string">csv</item>
                                  <item name="label" xsi:type="string" translate="true">CSV</item>
                                  <item name="url" xsi:type="string">my_advancedreport/export/gridToCsv</item>
                                  </item>
                                  </item>
                                  </item>
                                  </argument>
                                  </exportButton>


                                  Of course, you need a controller to do this thing: 



                                  namespace NamespaceAdvancedReportControllerAdminhtmlExport;

                                  class GridToCsv extends MagentoUiControllerAdminhtmlExportGridToCsv

                                  const ADMIN_RESOURCE = 'My_AdvancedReport::advanced_invoice_report';



                                  Second Step: Modify your controller class to use custom Export Model. /code/Namespace/AdvancedReport/etc/di.xml (scope global or Adminhtml)



                                  <type name="NamespaceAdvancedReportModelExportConvertToCsv">
                                  <arguments>
                                  <argument name="metadataProvider" xsi:type="object">NamespaceAdvancedReportModelExportMetadataProvider</argument>
                                  </arguments>
                                  </type>
                                  <type name="NamespaceAdvancedReportControllerAdminhtmlExportGridToCsv">
                                  <arguments>
                                  <argument name="converter" xsi:type="object">NamespaceAdvancedReportModelExportConvertToCsv</argument>
                                  </arguments>
                                  </type>


                                  Custom data provider to get what are selected columns user have selected on Admin.
                                  app/code/Namespace/AdvancedReport/Model/Export/MetadataProvider.php
                                  about the idea I have used MagentoUiModelBookmarkManagement. to get stored grid for Admin User while User Edit selected or sort-ordered columns of the Report Grid.



                                  namespace NamespaceAdvancedReportModelExport;


                                  use MagentoFrameworkViewElementUiComponentInterface;
                                  use MagentoUiComponentMassActionFilter;
                                  use MagentoFrameworkLocaleResolverInterface;
                                  use MagentoFrameworkStdlibDateTimeTimezoneInterface;

                                  class MetadataProvider extends MagentoUiModelExportMetadataProvider

                                  /**
                                  * @var MagentoUiModelBookmarkManagement
                                  */
                                  protected $_bookmarkManagement;

                                  /**
                                  * MetadataProvider constructor.
                                  * @param Filter $filter
                                  * @param TimezoneInterface $localeDate
                                  * @param ResolverInterface $localeResolver
                                  * @param string $dateFormat
                                  * @param MagentoUiModelBookmarkManagement $bookmarkManagement
                                  * @param array $data
                                  */
                                  public function __construct(
                                  Filter $filter,
                                  TimezoneInterface $localeDate,
                                  ResolverInterface $localeResolver,
                                  MagentoUiModelBookmarkManagement $bookmarkManagement,
                                  $dateFormat = 'M j, Y H:i:s A',
                                  array $data = [])

                                  parent::__construct($filter, $localeDate, $localeResolver, $dateFormat, $data);
                                  $this->_bookmarkManagement = $bookmarkManagement;


                                  protected function getActiveColumns($component)
                                  $bookmark = $this->_bookmarkManagement->getByIdentifierNamespace('current', $component->getName());

                                  $config = $bookmark->getConfig();
                                  $columns = $config['current']['columns'];
                                  $_activeColumns = [];
                                  foreach ($columns as $column => $config)
                                  if(true === $config['visible'] && $column != 'ids')
                                  $_activeColumns[] = $column;


                                  return $_activeColumns;

                                  /**
                                  * @param UiComponentInterface $component
                                  * @return UiComponentInterface[]
                                  * @throws Exception
                                  */
                                  protected function getColumns(UiComponentInterface $component)

                                  if (!isset($this->columns[$component->getName()]))

                                  $activeColumns = $this->getActiveColumns($component);

                                  $columns = $this->getColumnsComponent($component);
                                  foreach ($columns->getChildComponents() as $column)
                                  if ($column->getData('config/label') && $column->getData('config/dataType') !== 'actions')
                                  if(in_array($column->getName(), $activeColumns))
                                  $this->columns[$component->getName()][$column->getName()] = $column;




                                  return $this->columns[$component->getName()];




                                  Done.






                                  share|improve this answer

























                                    0












                                    0








                                    0







                                    Let me do that for you with step by step. 
                                    First Step: Register your export button in your: view/adminhtml/ui_component/[grid-view-id].xml



                                    <exportButton name="export_button" class="NamespaceAdvancedReportComponentExportButton">
                                    <argument name="data" xsi:type="array">
                                    <item name="config" xsi:type="array">
                                    <item name="component" xsi:type="string">Magento_Ui/js/grid/export</item>
                                    <item name="displayArea" xsi:type="string">dataGridActions</item>
                                    <item name="options" xsi:type="array">
                                    <item name="cvs" xsi:type="array">
                                    <item name="value" xsi:type="string">csv</item>
                                    <item name="label" xsi:type="string" translate="true">CSV</item>
                                    <item name="url" xsi:type="string">my_advancedreport/export/gridToCsv</item>
                                    </item>
                                    </item>
                                    </item>
                                    </argument>
                                    </exportButton>


                                    Of course, you need a controller to do this thing: 



                                    namespace NamespaceAdvancedReportControllerAdminhtmlExport;

                                    class GridToCsv extends MagentoUiControllerAdminhtmlExportGridToCsv

                                    const ADMIN_RESOURCE = 'My_AdvancedReport::advanced_invoice_report';



                                    Second Step: Modify your controller class to use custom Export Model. /code/Namespace/AdvancedReport/etc/di.xml (scope global or Adminhtml)



                                    <type name="NamespaceAdvancedReportModelExportConvertToCsv">
                                    <arguments>
                                    <argument name="metadataProvider" xsi:type="object">NamespaceAdvancedReportModelExportMetadataProvider</argument>
                                    </arguments>
                                    </type>
                                    <type name="NamespaceAdvancedReportControllerAdminhtmlExportGridToCsv">
                                    <arguments>
                                    <argument name="converter" xsi:type="object">NamespaceAdvancedReportModelExportConvertToCsv</argument>
                                    </arguments>
                                    </type>


                                    Custom data provider to get what are selected columns user have selected on Admin.
                                    app/code/Namespace/AdvancedReport/Model/Export/MetadataProvider.php
                                    about the idea I have used MagentoUiModelBookmarkManagement. to get stored grid for Admin User while User Edit selected or sort-ordered columns of the Report Grid.



                                    namespace NamespaceAdvancedReportModelExport;


                                    use MagentoFrameworkViewElementUiComponentInterface;
                                    use MagentoUiComponentMassActionFilter;
                                    use MagentoFrameworkLocaleResolverInterface;
                                    use MagentoFrameworkStdlibDateTimeTimezoneInterface;

                                    class MetadataProvider extends MagentoUiModelExportMetadataProvider

                                    /**
                                    * @var MagentoUiModelBookmarkManagement
                                    */
                                    protected $_bookmarkManagement;

                                    /**
                                    * MetadataProvider constructor.
                                    * @param Filter $filter
                                    * @param TimezoneInterface $localeDate
                                    * @param ResolverInterface $localeResolver
                                    * @param string $dateFormat
                                    * @param MagentoUiModelBookmarkManagement $bookmarkManagement
                                    * @param array $data
                                    */
                                    public function __construct(
                                    Filter $filter,
                                    TimezoneInterface $localeDate,
                                    ResolverInterface $localeResolver,
                                    MagentoUiModelBookmarkManagement $bookmarkManagement,
                                    $dateFormat = 'M j, Y H:i:s A',
                                    array $data = [])

                                    parent::__construct($filter, $localeDate, $localeResolver, $dateFormat, $data);
                                    $this->_bookmarkManagement = $bookmarkManagement;


                                    protected function getActiveColumns($component)
                                    $bookmark = $this->_bookmarkManagement->getByIdentifierNamespace('current', $component->getName());

                                    $config = $bookmark->getConfig();
                                    $columns = $config['current']['columns'];
                                    $_activeColumns = [];
                                    foreach ($columns as $column => $config)
                                    if(true === $config['visible'] && $column != 'ids')
                                    $_activeColumns[] = $column;


                                    return $_activeColumns;

                                    /**
                                    * @param UiComponentInterface $component
                                    * @return UiComponentInterface[]
                                    * @throws Exception
                                    */
                                    protected function getColumns(UiComponentInterface $component)

                                    if (!isset($this->columns[$component->getName()]))

                                    $activeColumns = $this->getActiveColumns($component);

                                    $columns = $this->getColumnsComponent($component);
                                    foreach ($columns->getChildComponents() as $column)
                                    if ($column->getData('config/label') && $column->getData('config/dataType') !== 'actions')
                                    if(in_array($column->getName(), $activeColumns))
                                    $this->columns[$component->getName()][$column->getName()] = $column;




                                    return $this->columns[$component->getName()];




                                    Done.






                                    share|improve this answer













                                    Let me do that for you with step by step. 
                                    First Step: Register your export button in your: view/adminhtml/ui_component/[grid-view-id].xml



                                    <exportButton name="export_button" class="NamespaceAdvancedReportComponentExportButton">
                                    <argument name="data" xsi:type="array">
                                    <item name="config" xsi:type="array">
                                    <item name="component" xsi:type="string">Magento_Ui/js/grid/export</item>
                                    <item name="displayArea" xsi:type="string">dataGridActions</item>
                                    <item name="options" xsi:type="array">
                                    <item name="cvs" xsi:type="array">
                                    <item name="value" xsi:type="string">csv</item>
                                    <item name="label" xsi:type="string" translate="true">CSV</item>
                                    <item name="url" xsi:type="string">my_advancedreport/export/gridToCsv</item>
                                    </item>
                                    </item>
                                    </item>
                                    </argument>
                                    </exportButton>


                                    Of course, you need a controller to do this thing: 



                                    namespace NamespaceAdvancedReportControllerAdminhtmlExport;

                                    class GridToCsv extends MagentoUiControllerAdminhtmlExportGridToCsv

                                    const ADMIN_RESOURCE = 'My_AdvancedReport::advanced_invoice_report';



                                    Second Step: Modify your controller class to use custom Export Model. /code/Namespace/AdvancedReport/etc/di.xml (scope global or Adminhtml)



                                    <type name="NamespaceAdvancedReportModelExportConvertToCsv">
                                    <arguments>
                                    <argument name="metadataProvider" xsi:type="object">NamespaceAdvancedReportModelExportMetadataProvider</argument>
                                    </arguments>
                                    </type>
                                    <type name="NamespaceAdvancedReportControllerAdminhtmlExportGridToCsv">
                                    <arguments>
                                    <argument name="converter" xsi:type="object">NamespaceAdvancedReportModelExportConvertToCsv</argument>
                                    </arguments>
                                    </type>


                                    Custom data provider to get what are selected columns user have selected on Admin.
                                    app/code/Namespace/AdvancedReport/Model/Export/MetadataProvider.php
                                    about the idea I have used MagentoUiModelBookmarkManagement. to get stored grid for Admin User while User Edit selected or sort-ordered columns of the Report Grid.



                                    namespace NamespaceAdvancedReportModelExport;


                                    use MagentoFrameworkViewElementUiComponentInterface;
                                    use MagentoUiComponentMassActionFilter;
                                    use MagentoFrameworkLocaleResolverInterface;
                                    use MagentoFrameworkStdlibDateTimeTimezoneInterface;

                                    class MetadataProvider extends MagentoUiModelExportMetadataProvider

                                    /**
                                    * @var MagentoUiModelBookmarkManagement
                                    */
                                    protected $_bookmarkManagement;

                                    /**
                                    * MetadataProvider constructor.
                                    * @param Filter $filter
                                    * @param TimezoneInterface $localeDate
                                    * @param ResolverInterface $localeResolver
                                    * @param string $dateFormat
                                    * @param MagentoUiModelBookmarkManagement $bookmarkManagement
                                    * @param array $data
                                    */
                                    public function __construct(
                                    Filter $filter,
                                    TimezoneInterface $localeDate,
                                    ResolverInterface $localeResolver,
                                    MagentoUiModelBookmarkManagement $bookmarkManagement,
                                    $dateFormat = 'M j, Y H:i:s A',
                                    array $data = [])

                                    parent::__construct($filter, $localeDate, $localeResolver, $dateFormat, $data);
                                    $this->_bookmarkManagement = $bookmarkManagement;


                                    protected function getActiveColumns($component)
                                    $bookmark = $this->_bookmarkManagement->getByIdentifierNamespace('current', $component->getName());

                                    $config = $bookmark->getConfig();
                                    $columns = $config['current']['columns'];
                                    $_activeColumns = [];
                                    foreach ($columns as $column => $config)
                                    if(true === $config['visible'] && $column != 'ids')
                                    $_activeColumns[] = $column;


                                    return $_activeColumns;

                                    /**
                                    * @param UiComponentInterface $component
                                    * @return UiComponentInterface[]
                                    * @throws Exception
                                    */
                                    protected function getColumns(UiComponentInterface $component)

                                    if (!isset($this->columns[$component->getName()]))

                                    $activeColumns = $this->getActiveColumns($component);

                                    $columns = $this->getColumnsComponent($component);
                                    foreach ($columns->getChildComponents() as $column)
                                    if ($column->getData('config/label') && $column->getData('config/dataType') !== 'actions')
                                    if(in_array($column->getName(), $activeColumns))
                                    $this->columns[$component->getName()][$column->getName()] = $column;




                                    return $this->columns[$component->getName()];




                                    Done.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered May 23 at 8:58









                                    HoangHieuHoangHieu

                                    754514




                                    754514



























                                        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%2f166610%2fmagento-2-how-can-i-remove-columns-in-exported-csv-from-order-grid%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

                                        Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                                        Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                                        Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림