{"id":3497,"date":"2014-03-27T04:50:41","date_gmt":"2014-03-27T04:50:41","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/27\/cannot-create-order-history-csv-download-for-customers-in-prestashop-collection-of-common-programming-errors\/"},"modified":"2014-03-27T04:50:41","modified_gmt":"2014-03-27T04:50:41","slug":"cannot-create-order-history-csv-download-for-customers-in-prestashop-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/27\/cannot-create-order-history-csv-download-for-customers-in-prestashop-collection-of-common-programming-errors\/","title":{"rendered":"Cannot create Order History CSV download for customers in Prestashop-Collection of common programming errors"},"content":{"rendered":"<p>Have been stuck with this issue since the last 4 days and checked everywhere but I cannot find a solution.<\/p>\n<p>In Prestashop, I need to offer customers (for a b2b site) csv downloads for each of their order histories. This is what I have done:<\/p>\n<p>1- Overridden <em>OrderDetailController.php<\/em> and written the following code under <em>initContent()<\/em>:<\/p>\n<pre><code>if ( !array_key_exists('csv_download', $_GET) ) {\n    parent::initContent();\n} else if ( array_key_exists('csv_download', $_GET) ) {\n    header('Content-type: text\/csv');\n    header('Content-Type: application\/force-download; charset=UTF-8');\n    header('Cache-Control: no-store, no-cache');\n    header('Content-disposition: attachment; filename=\"'.'abc'.'_'.date('Y-m-d_His').'.csv\"');\n    $this-&gt;context-&gt;smarty-&gt;display(_PS_THEME_DIR_.'order-detail-csv.tpl');\n}\n<\/code><\/pre>\n<p>The order-detail-csv.tpl is:<\/p>\n<pre><code>col1, col2, col3, col4\n1,2,3,4\n5,6,7,8\n<\/code><\/pre>\n<p>(I&#8217;ve have hardcoded values in the template for testing purposes)<\/p>\n<p>The problem is, when the link is clicked to access this, the following is appended at the bottom of the CSV:<\/p>\n<pre><code>col1, col2, col3, col4\n1,2,3,4\n5,6,7,8\n\n\n<br class=\"title_block\" \/>Information<br \/><br \/>\n<\/code><\/pre>\n<ul>\n<b>Notice<\/b>: Undefined index: PS_CATALOG_MODE in <b>D:\\Program_Files\\xampp\\htdocs \\prestashop\\cache\\smarty\\compile\\66\\40\\fc\\6640fcf250c9a844925d45d85c39618c4233b46e.file.blockcms.tpl.php<\/b>on line <b>93<\/b><\/p>\n<p><b>Notice<\/b>: Trying to get property of non-object in <b>D:\\Program_Files\\xampp\\htdocs\\prestashop\\cache\\smarty\\compile\\66\\40\\fc\\6640fcf250c9a844925d45d85c39618c4233b46e.file.blockcms.tpl.php<\/b>on line <b>93<\/b><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Have been stuck with this issue since the last 4 days and checked everywhere but I cannot find a solution. In Prestashop, I need to offer customers (for a b2b site) csv downloads for each of their order histories. This is what I have done: 1- Overridden OrderDetailController.php and written the following code under initContent(): [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3497","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3497"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3497\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}