Petar Posted September 13, 2022 Share Posted September 13, 2022 Hello, Im trying to transform the generated invoice- witch is pdf to be an excel file. I need this for faster import to other program. I know there are a lot of addons but they all export all orders and i need them to be separaded and exported order by order with specific filters. I have this function working in older version of prestashop - 1.4.0 and im trying to implement it to the 1.7.* So when you click on the invoice it automaticly transforms the invoice in excel. I have the code and im gonna share it here but i cant get it to work on the 1.7 i thing im missing something? This is the pdf.php . Do I have to edit the template of the invoice? - I know that there are a lot of changes from 1.4 to 1.7 but this is super simple solution that actualy works without unnesessry moduls. function generateInvoicePDF() { if (!isset($_GET['id_order'])) die (Tools::displayError('order ID is missing')); $order = new Order((int)($_GET['id_order'])); if (!Validate::isLoadedObject($order)) die(Tools::displayError('cannot find order in database')); //PDF::invoice($order); if (isset($order->products) AND sizeof($order->products)) $products = $order->products; else $products = $order->getProducts(); require '../php-excel.class.php'; $data = array(); $item = array(); $item[] = 'Продукт'; $item[] = 'Номер'; $item[] = 'Количество'; $item[] = 'Ед. Цена'; $item[] = 'Обща Цена'; $data[] = $item; foreach($products as $product){ $item = array(); $item[] = $product['product_name']; $item[] = $product['product_reference']; $item[] = $product['product_quantity']; $item[] = number_format($product['product_price'], 3); $item[] = number_format($product['product_quantity']*$product['product_price'],3); $data[] = $item; } $xls = new Excel_XML('UTF-8', false, 'Order'); $xls->addArray($data); $xls->generateXML('order'); } Anyone have any sugestions?? Link to comment Share on other sites More sharing options...
Prestachamps Posted September 13, 2022 Share Posted September 13, 2022 Hello, We need more information to assist you, so please send a screen shot of the error. Have a nice day. Kind regards, Leo Link to comment Share on other sites More sharing options...
Petar Posted September 14, 2022 Author Share Posted September 14, 2022 18 hours ago, Prestachamps said: Hello, We need more information to assist you, so please send a screen shot of the error. Have a nice day. Kind regards, Leo I want to implement that script from 1.4 prestashop to 1.7 but im not sure how exacly to do it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now