{"id":70723,"date":"2017-01-06T12:58:28","date_gmt":"2017-01-06T12:58:28","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=70723"},"modified":"2017-01-06T13:10:16","modified_gmt":"2017-01-06T13:10:16","slug":"export-data-csv-file-prestashop","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/","title":{"rendered":"How to export data in csv file in Prestashop"},"content":{"rendered":"<p>CSV file is &#8220;Comma Separated Value&#8221; file in which you can store data in tabular format. CSV file is used to import and export data. You can import and export data on different system by CSV file.<\/p>\n<p>In Prestashop we can export data in the form of CSV file by following way:<\/p>\n<pre class=\"brush:php\">&lt;?php\r\nclass TestModuleFrontController extends ModuleFrontController \r\n{\r\n\tpublic function initContent() \r\n\t{\r\n\t\t$this-&gt;display_header = false;\r\n        $this-&gt;display_footer = false;\r\n        parent::initContent();\r\n\r\n\t\t$customerList = array(\r\n\t\t\tarray(\r\n\t\t\t\t'Id Customer',\r\n\t\t\t\t'Name'\r\n\t\t\t),\r\n\t\t\tarray(\r\n\t\t\t\t'1',\r\n\t\t\t\t'John'\r\n\t\t\t),\r\n\t\t\tarray(\r\n\t\t\t\t'2',\r\n\t\t\t\t'Bob'\r\n\t\t\t)\r\n\t\t);\r\n\r\n\t\theader('Content-Type: text\/csv');\r\n\t\theader('Content-Type: application\/force-download; charset=UTF-8');\r\n\t\theader('Cache-Control: no-store, no-cache');\r\n\t\theader('Content-Disposition: attachment; filename=\"customer.csv\"');\r\n\r\n\t\t$file = fopen('php:\/\/output', 'w');\r\n\t\tforeach ($customerList as $customer) {\r\n\t\t    fputcsv($file, $customer);\r\n\t\t}\r\n\t\tfclose($file);\r\n\t}\r\n}\r\n<\/pre>\n<p>You must assign false in display_header and display_footer variable because if you do not assign false in above variable then Prestashop will add default header in you CSV file.<\/p>\n<p>You can export data in CSV file from database, just assign data in $customerList variable which is fetched from database.<\/p>\n<p>So in this way you can export data in CSV file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSV file is &#8220;Comma Separated Value&#8221; file in which you can store data in tabular format. CSV file is used to import and export data. You can import and export data on different system by CSV file. In Prestashop we can export data in the form of CSV file by following way: &lt;?php class TestModuleFrontController <a href=\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":38,"featured_media":69431,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,209],"tags":[],"class_list":["post-70723","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-prestashop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Export data in csv file from database in Prestashop<\/title>\n<meta name=\"description\" content=\"CSV file is Comma Separated Value file in which data stored in tabular format. By following way you can Export data from database in CSV file in Prestashop.\" \/>\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-data-csv-file-prestashop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Export data in csv file from database in Prestashop\" \/>\n<meta property=\"og:description\" content=\"CSV file is Comma Separated Value file in which data stored in tabular format. By following way you can Export data from database in CSV file in Prestashop.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/\" \/>\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=\"2017-01-06T12:58:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-01-06T13:10:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ambe Pratap\" \/>\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=\"Ambe Pratap\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/\"},\"author\":{\"name\":\"Ambe Pratap\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/0f13af86e9f176a026ed0cdd97bccad4\"},\"headline\":\"How to export data in csv file in Prestashop\",\"datePublished\":\"2017-01-06T12:58:28+00:00\",\"dateModified\":\"2017-01-06T13:10:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/\"},\"wordCount\":123,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png\",\"articleSection\":[\"php\",\"prestashop\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/\",\"url\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/\",\"name\":\"Export data in csv file from database in Prestashop\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png\",\"datePublished\":\"2017-01-06T12:58:28+00:00\",\"dateModified\":\"2017-01-06T13:10:16+00:00\",\"description\":\"CSV file is Comma Separated Value file in which data stored in tabular format. By following way you can Export data from database in CSV file in Prestashop.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to export data in csv file in Prestashop\"}]},{\"@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\/0f13af86e9f176a026ed0cdd97bccad4\",\"name\":\"Ambe Pratap\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c84bc44d76e9ce3ad0a5cde4d7e31c49024127de6144166df0eb5a4d2d9f66cc?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\/c84bc44d76e9ce3ad0a5cde4d7e31c49024127de6144166df0eb5a4d2d9f66cc?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ambe Pratap\"},\"sameAs\":[\"https:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/ambe063\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Export data in csv file from database in Prestashop","description":"CSV file is Comma Separated Value file in which data stored in tabular format. By following way you can Export data from database in CSV file in Prestashop.","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-data-csv-file-prestashop\/","og_locale":"en_US","og_type":"article","og_title":"Export data in csv file from database in Prestashop","og_description":"CSV file is Comma Separated Value file in which data stored in tabular format. By following way you can Export data from database in CSV file in Prestashop.","og_url":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2017-01-06T12:58:28+00:00","article_modified_time":"2017-01-06T13:10:16+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png","type":"image\/png"}],"author":"Ambe Pratap","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ambe Pratap","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/"},"author":{"name":"Ambe Pratap","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/0f13af86e9f176a026ed0cdd97bccad4"},"headline":"How to export data in csv file in Prestashop","datePublished":"2017-01-06T12:58:28+00:00","dateModified":"2017-01-06T13:10:16+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/"},"wordCount":123,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png","articleSection":["php","prestashop"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/","url":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/","name":"Export data in csv file from database in Prestashop","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png","datePublished":"2017-01-06T12:58:28+00:00","dateModified":"2017-01-06T13:10:16+00:00","description":"CSV file is Comma Separated Value file in which data stored in tabular format. By following way you can Export data from database in CSV file in Prestashop.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/12\/Prestashop-Code-Snippet-1.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/export-data-csv-file-prestashop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to export data in csv file in Prestashop"}]},{"@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\/0f13af86e9f176a026ed0cdd97bccad4","name":"Ambe Pratap","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c84bc44d76e9ce3ad0a5cde4d7e31c49024127de6144166df0eb5a4d2d9f66cc?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\/c84bc44d76e9ce3ad0a5cde4d7e31c49024127de6144166df0eb5a4d2d9f66cc?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ambe Pratap"},"sameAs":["https:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/ambe063\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/70723","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\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=70723"}],"version-history":[{"count":7,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/70723\/revisions"}],"predecessor-version":[{"id":70752,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/70723\/revisions\/70752"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/69431"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=70723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=70723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=70723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}