dreamerArt Posted November 26, 2014 Share Posted November 26, 2014 Hi all, I have a little question here: i need a product position in my delivery-slip pdf, this means every product with a sorted number like: POSITION | PRODUCT -------------------------------- 1 | Product x -------------------------------- 2 | Product y -------------------------------- 3 | Product z -------------------------------- 4 | Product w My question is, where is the file who is generate sql query like SELECT statement which will generate a pdf? i appreciate your help. Best regards, dreamerArt Link to comment Share on other sites More sharing options...
musicmaster Posted November 26, 2014 Share Posted November 26, 2014 I don't exactly where the query is. But I can give some directions how to find it: You start in the function getcontent() in the file HTMLTemplateInvoice.php in the classes/pdf directory. There you find a call to $this->order_invoice->getProducts() That function can be found in the file OrderInvoice.php in the classes/order directory. Link to comment Share on other sites More sharing options...
dreamerArt Posted November 26, 2014 Author Share Posted November 26, 2014 Thank you for your fast reply. I will try that now and i'll let you ocurrente. Thanks again Link to comment Share on other sites More sharing options...
dreamerArt Posted November 26, 2014 Author Share Posted November 26, 2014 I think I'm in the wrong direction In the function getProducts() i made some changes creating a new variable called $tmpCount as I show below: public function getProducts() { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT *, osd.product_quantity FROM `'._DB_PREFIX_.'order_slip_detail` osd INNER JOIN `'._DB_PREFIX_.'order_detail` od ON osd.id_order_detail = od.id_order_detail WHERE osd.`id_order_slip` = '.(int)$this->id); $order = new Order($this->id_order); $products = array(); $tmpCount = 1; foreach ($result as $row) { $order->setProductPrices($row); $products[] = $row; } return $products ; $tmpCount ++; } on the other hand in delivery-slip.tpl i try to call this variable like {$order_detail.tmpCount} even {$tmpCount} but unsuccessfully nothing happens. in another site all made by me, I could do this fast and easy. Appreciate some help. Best regards, dreamerArt Link to comment Share on other sites More sharing options...
musicmaster Posted November 26, 2014 Share Posted November 26, 2014 Oops, my comment was on the invoice, not the delivery slip. The delivery slip starts with a function getcontent() in HTMLTemplateDeliverySlip.php but then arrives in the same getproducts function. So in the end it shouldn't make a difference. However, there are two things wrong with your code: - you declare "$tmpcount++" after your "return" statement. So it will never be called. - In your template you will find only those variables that have been explicitly made visible to Smarty. You can see at the bottom of the getcontent() function how that is done. Link to comment Share on other sites More sharing options...
tuk66 Posted November 27, 2014 Share Posted November 27, 2014 I would just edit the/pdf/invoice.tpl template. See Smarty iteration at http://www.smarty.net/docsv2/en/language.function.foreach.tpl to get positions. Link to comment Share on other sites More sharing options...
dreamerArt Posted November 28, 2014 Author Share Posted November 28, 2014 "Like a glove" Thank you so much!! Here is the solution (so easy): In delivery-slip.tpl i declared {counter start=0 skip=1} before {foreach} and inside i called the counter {counter} in the right table column. So, i have a table out like: POSITION | PRODUCT -------------------------------- 1 | Product x -------------------------------- 2 | Product y -------------------------------- 3 | Product z -------------------------------- 4 | Product w Thanks again. Best regards, dreamerArt Link to comment Share on other sites More sharing options...
Recommended Posts