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??