{"id":133567,"date":"2018-07-14T13:17:37","date_gmt":"2018-07-14T13:17:37","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=133567"},"modified":"2018-07-14T13:18:09","modified_gmt":"2018-07-14T13:18:09","slug":"export-grid-data-magento2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/","title":{"rendered":"How To Export Filtered Collection From Ui Grid Magento 2"},"content":{"rendered":"<p>How To Export Filtered Collection From Ui Grid Magento 2 =&gt; Almost all the grids are made using ui component in magento 2.Ui component has a feature to export collection data in csv and xml format.<br \/>\nBy default it exports complete collection.<br \/>\nso if you want to export few records from the collection using a filter.<br \/>\nthen i am going to explain how you can do this.<\/p>\n<p>First of all you have set the class for export_button element, where you can filter the collection.<\/p>\n<pre class=\"brush:php\">&lt;exportButton name=\"export_button\" class=\"Webkul\\FilterCollectionTest\\Ui\\Component\\ExportButton\"&gt;\r\n    &lt;argument name=\"data\" xsi:type=\"array\"&gt;\r\n        &lt;item name=\"config\" xsi:type=\"array\"&gt;\r\n            &lt;item name=\"selectProvider\" xsi:type=\"string\"&gt;filtercollectiontest_chat_listing.filtercollectiontest_chat_listing.filtercollectiontest_chat_columns.ids&lt;\/item&gt;\r\n        &lt;\/item&gt;\r\n    &lt;\/argument&gt;\r\n&lt;\/exportButton&gt;<\/pre>\n<p>Then create the file on above mentioned location (Webkul\\FilterCollectionTest\\Ui\\Component\\ExportButton).<\/p>\n<pre class=\"brush:php\">&lt;?php\r\n\/**\r\n * Webkul Software.\r\n *\r\n * @category  Webkul\r\n * @package   Webkul_FilterCollectionTest\r\n * @author    Webkul\r\n * @copyright Copyright (c) Webkul Software Private Limited (https:\/\/webkul.com)\r\n * @license   https:\/\/store.webkul.com\/license.html\r\n *\/\r\n\r\nnamespace Webkul\\FilterCollectionTest\\Ui\\Component;\r\n\r\n\/**\r\n * Class ExportButton\r\n *\/\r\nclass ExportButton extends \\Magento\\Ui\\Component\\AbstractComponent\r\n{\r\n    \/**\r\n     * Component name\r\n     *\/\r\n    const NAME = 'exportButton';\r\n\r\n    \/**\r\n     * @var \\Magento\\Framework\\UrlInterface\r\n     *\/\r\n    protected $_urlBuilder;\r\n\r\n    \/**\r\n     * @var \\Magento\\Framework\\App\\Request\\Http\r\n     *\/\r\n    protected $_request;\r\n\r\n    \/**\r\n     * @param ContextInterface $context\r\n     * @param UrlInterface $urlBuilder\r\n     * @param \\Magento\\Framework\\App\\Request\\Http $request\r\n     * @param array $components\r\n     * @param array $data\r\n     *\/\r\n    public function __construct(\r\n        \\Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface $context,\r\n        \\Magento\\Framework\\UrlInterface $urlBuilder,\r\n        \\Magento\\Framework\\App\\Request\\Http $request,\r\n        array $components = [],\r\n        array $data = []\r\n    ) {\r\n        parent::__construct($context, $components, $data);\r\n        $this-&gt;_urlBuilder = $urlBuilder;\r\n        $this-&gt;_request = $request;\r\n    }\r\n\r\n    \/**\r\n     * @return void\r\n     *\/\r\n    public function prepare()\r\n    {\r\n        $customerId = $this-&gt;_request-&gt;getParam('customer_id');\r\n        if (isset($customerId)) {\r\n            $configData = $this-&gt;getData('config');\r\n            if (isset($configData['options'])) {\r\n                $configOptions = [];\r\n                foreach ($configData['options'] as $configOption) {\r\n                    $configOption['url'] = $this-&gt;_urlBuilder-&gt;getUrl(\r\n                        $configOption['url'],\r\n                        [\"customer_id\"=&gt;$customerId]\r\n                    );\r\n                    $configOptions[] = $configOption;\r\n                }\r\n                $configData['options'] = $configOptions;\r\n                $this-&gt;setData('config', $configData);\r\n            }\r\n        }\r\n        parent::prepare();\r\n    }\r\n}\r\n<\/pre>\n<p>So now when you do the export filter collection will be exported. here i have made filter of customer id.<\/p>\n<p>Hope so it will help someone.<\/p>\n<p>Thank you<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How To Export Filtered Collection From Ui Grid Magento 2 =&gt; Almost all the grids are made using ui component in magento 2.Ui component has a feature to export collection data in csv and xml format. By default it exports complete collection. so if you want to export few records from the collection using a <a href=\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":92,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[7080,7079,7081],"class_list":["post-133567","post","type-post","status-publish","format-standard","hentry","category-magento2","tag-export-collection-magento-2","tag-export-filtered-collection-magento-2","tag-export-grid-collection-maento-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Export Filtered Collection From Ui Grid Magento 2<\/title>\n<meta name=\"description\" content=\"How To Export Filtered Collection From Ui Grid Magento 2, export data, magento 2 export collection data, export filtered data from grid magento 2, export magento 2 grid collection\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Export Filtered Collection From Ui Grid Magento 2\" \/>\n<meta property=\"og:description\" content=\"How To Export Filtered Collection From Ui Grid Magento 2, export data, magento 2 export collection data, export filtered data from grid magento 2, export magento 2 grid collection\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-14T13:17:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-07-14T13:18:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Narendra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Narendra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/\"},\"author\":{\"name\":\"Narendra\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3c4771ea9c127b5c6e7d1ff8b58ec70a\"},\"headline\":\"How To Export Filtered Collection From Ui Grid Magento 2\",\"datePublished\":\"2018-07-14T13:17:37+00:00\",\"dateModified\":\"2018-07-14T13:18:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/\"},\"wordCount\":134,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"export collection magento 2\",\"export filtered collection magento 2\",\"export grid collection maento 2\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/\",\"url\":\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/\",\"name\":\"How To Export Filtered Collection From Ui Grid Magento 2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2018-07-14T13:17:37+00:00\",\"dateModified\":\"2018-07-14T13:18:09+00:00\",\"description\":\"How To Export Filtered Collection From Ui Grid Magento 2, export data, magento 2 export collection data, export filtered data from grid magento 2, export magento 2 grid collection\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Export Filtered Collection From Ui Grid Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3c4771ea9c127b5c6e7d1ff8b58ec70a\",\"name\":\"Narendra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/303d2e21e5f58ef4ebc1e13fa3c2ef91c7e27b33a9add5728a40545b6de1d269?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/303d2e21e5f58ef4ebc1e13fa3c2ef91c7e27b33a9add5728a40545b6de1d269?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Narendra\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/narendra962\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Export Filtered Collection From Ui Grid Magento 2","description":"How To Export Filtered Collection From Ui Grid Magento 2, export data, magento 2 export collection data, export filtered data from grid magento 2, export magento 2 grid collection","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/","og_locale":"en_US","og_type":"article","og_title":"How To Export Filtered Collection From Ui Grid Magento 2","og_description":"How To Export Filtered Collection From Ui Grid Magento 2, export data, magento 2 export collection data, export filtered data from grid magento 2, export magento 2 grid collection","og_url":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-07-14T13:17:37+00:00","article_modified_time":"2018-07-14T13:18:09+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Narendra","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Narendra","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/"},"author":{"name":"Narendra","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3c4771ea9c127b5c6e7d1ff8b58ec70a"},"headline":"How To Export Filtered Collection From Ui Grid Magento 2","datePublished":"2018-07-14T13:17:37+00:00","dateModified":"2018-07-14T13:18:09+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/"},"wordCount":134,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["export collection magento 2","export filtered collection magento 2","export grid collection maento 2"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/export-grid-data-magento2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/","url":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/","name":"How To Export Filtered Collection From Ui Grid Magento 2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2018-07-14T13:17:37+00:00","dateModified":"2018-07-14T13:18:09+00:00","description":"How To Export Filtered Collection From Ui Grid Magento 2, export data, magento 2 export collection data, export filtered data from grid magento 2, export magento 2 grid collection","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/export-grid-data-magento2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/export-grid-data-magento2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Export Filtered Collection From Ui Grid Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3c4771ea9c127b5c6e7d1ff8b58ec70a","name":"Narendra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/303d2e21e5f58ef4ebc1e13fa3c2ef91c7e27b33a9add5728a40545b6de1d269?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/303d2e21e5f58ef4ebc1e13fa3c2ef91c7e27b33a9add5728a40545b6de1d269?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Narendra"},"url":"https:\/\/webkul.com\/blog\/author\/narendra962\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/133567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/92"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=133567"}],"version-history":[{"count":2,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/133567\/revisions"}],"predecessor-version":[{"id":133579,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/133567\/revisions\/133579"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=133567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=133567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=133567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}