stefanmcnett Posted April 16, 2014 Share Posted April 16, 2014 (edited) Hello, i'm looking in to that for quiet a while but i can't find a solution, maybe you guys can help me. I'm trying to put the product short description in to the order confirmation mail. In "mailalerts.php" i added "$product['description_short']" in Line 314, but that dosen't work. $items_table .=' <tr style="background-color:'.($key % 2 ? '#DDE2E6' : '#EBECEE').';"> <td style="padding:0.6em 0.4em;">'.$product['product_reference'].'</td> <td style="padding:0.6em 0.4em;"><strong>'.$product['product_name'].$product['description_short'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').(!empty($customization_text) ? '<br />'.$customization_text : '').'</strong></td> I think that the variable "$product['description_short']" is not defined in the System. Can somebody tell me where i can define the variable oder where i can get the product short description data from the SQL Database. Prestashop Version 1.5.3.1 Thanks a lot. Cu Stefan Edited April 16, 2014 by stefanmcnett (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted April 16, 2014 Share Posted April 16, 2014 You have to grab it in public function getProductsDetail() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop) WHERE od.`id_order` = '.(int)($this->id)); } Order class Link to comment Share on other sites More sharing options...
stefanmcnett Posted April 16, 2014 Author Share Posted April 16, 2014 Thanks Nemo, I added the following line to /classes/order/Order.php LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product AND pl.`id_lang` = 3) I hardcoded the lang code id, i guess thats fine for now. I tested my SQL query and it works, and the Product short description shows up in the mail that the store owner gets on an new order, but i should also appear in the customers oder confirmation. So that means I'm editing the wrong File, maybe mailalerts.php is the wrong source ? Thanks for your help. Cu Stefan Link to comment Share on other sites More sharing options...
NemoPS Posted April 16, 2014 Share Posted April 16, 2014 ah, that email is sent by the paymentModule class, validateOrder method Link to comment Share on other sites More sharing options...
stefanmcnett Posted April 16, 2014 Author Share Posted April 16, 2014 Thanks a lot, that was the hint i needed, now it works. Thanks again.. Link to comment Share on other sites More sharing options...
dgv2012 Posted May 19, 2014 Share Posted May 19, 2014 Hello, I'm getting some problems trying to follow these instructions. Can you help me, please? I'm not an expert with code so I need a step by step explanation. At least, am I doing ok the first step? Step 1.- Add LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product AND pl.`id_lang` = 3) to /classes/order/Order.php public function getProductsDetail() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id) LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop) WHERE od.`id_order` = '.(int)($this->id)); } Thanks! Link to comment Share on other sites More sharing options...
NemoPS Posted May 21, 2014 Share Posted May 21, 2014 Yes, place it inbetween the two joins that are there already. Link to comment Share on other sites More sharing options...
dgv2012 Posted May 21, 2014 Share Posted May 21, 2014 Ok, so step 1 done. If I want to show the description in the customers order confirmation the next step would be modify the paymentModule class, validateOrder method as you said before? If that's correct, please tell me what code I have to add/replace and where. Thanks for your time! Link to comment Share on other sites More sharing options...
dgv2012 Posted May 22, 2014 Share Posted May 22, 2014 Anyone can help me to add the description variable of the product in the validateOrder method of paymentModule class? I don't know where I have to declare the variable. Thanks! Link to comment Share on other sites More sharing options...
NemoPS Posted May 23, 2014 Share Posted May 23, 2014 Try from line 365 onwards foreach ($order->product_list as $key => $product) { Inside this foreach, I guess you can use $product['description_short'] at this point. The table that follows is the one printed in the email 1 Link to comment Share on other sites More sharing options...
dgv2012 Posted May 23, 2014 Share Posted May 23, 2014 Try from line 365 onwards foreach ($order->product_list as $key => $product) { Inside this foreach, I guess you can use $product['description_short'] at this point. The table that follows is the one printed in the email Thanks Nemo1, it works perfect! But I tried the same with $product['description'] and I don't get any result. The variable for the normal description of the product isn't $product['description']? Link to comment Share on other sites More sharing options...
NemoPS Posted May 24, 2014 Share Posted May 24, 2014 hm try with description_short Link to comment Share on other sites More sharing options...
dgv2012 Posted May 24, 2014 Share Posted May 24, 2014 hm try with description_short Hi Nemo1, sorry maybe I didn't explain myself before. $product['description_short'] is working fine for short product description. But I also want to include the regular product description, which is called description in the database. As I told you before I tried with $product['description'] but it doesn't work as $product['description_short'] does. There is no need to make proves with description_short because it works with your previous solution. Link to comment Share on other sites More sharing options...
NemoPS Posted May 26, 2014 Share Posted May 26, 2014 Hm... I see. Try var_dump($product); See if description is assigned as key, it should, it's weird, as you used * and joined the product_lang table Link to comment Share on other sites More sharing options...
dgv2012 Posted May 26, 2014 Share Posted May 26, 2014 Hm... I see. Try var_dump($product); See if description is assigned as key, it should, it's weird, as you used * and joined the product_lang table I did it and description is not assigned as key. How can I assign it? Link to comment Share on other sites More sharing options...
NemoPS Posted May 28, 2014 Share Posted May 28, 2014 You must climb up the code and find the original array of products, then see which method is used to grab them, and modify if so pl.description is added Link to comment Share on other sites More sharing options...
dgv2012 Posted May 28, 2014 Share Posted May 28, 2014 You must climb up the code and find the original array of products, then see which method is used to grab them, and modify if so pl.description is added Yes, it's me again, don't hate me. Google is not helping me to find the original array and his method. In paymentModule.php there is: foreach ($order->product_list as $key => $product) So the original array is $order->product_list? But before that, we have: foreach ($package_list as $id_address => $packageByAddress) foreach ($packageByAddress as $id_package => $package) { $order = new Order(); $order->product_list = $package['product_list']; I'm totally lost. Which is the original array and how I can know the method used to get it? Link to comment Share on other sites More sharing options...
NemoPS Posted May 29, 2014 Share Posted May 29, 2014 I hate you! Yes, it's quite complex, I struggled with it myself. Try editing cart::getProducts() and add it there 1 Link to comment Share on other sites More sharing options...
dgv2012 Posted May 29, 2014 Share Posted May 29, 2014 I hate you! Yes, it's quite complex, I struggled with it myself. Try editing cart::getProducts() and add it there Yesss!! Great work Nemo1, now it's working perfect. Thanks for your effort and specially for your patience! Link to comment Share on other sites More sharing options...
killerkhan Posted September 30, 2014 Share Posted September 30, 2014 I hate you! Yes, it's quite complex, I struggled with it myself. Try editing cart::getProducts() and add it there Hello, After making those changes i can add the description_short in the order confirmation mail sent to the customer. But i need the same to the admin email as well. Not been able to trace cart::getProducts(). Which file is it. Please help me where i am missing to add the variable. Thanks, Link to comment Share on other sites More sharing options...
NemoPS Posted October 1, 2014 Share Posted October 1, 2014 The admin email is sent from the mailalerts module, so you have to assign the variable there (mailalerts.php) Link to comment Share on other sites More sharing options...
Recommended Posts