musicmaster Posted September 20, 2012 Share Posted September 20, 2012 I adapted the mailalerts module so that the productnames on my "new order" alerts are clickable. As I don't use product numbers and some of my products are very similar that speeds up my processing of the orders. So I changed the function hookNewOrder() in the mailalerts.php file in the following way: global $cookie; /* at top */ /* new */ $cata = Db::getInstance()->getRow("SELECT id_category,name FROM "._DB_PREFIX_."product p, "._DB_PREFIX_."category_lang l WHERE l.id_category=p.id_category_default AND id_lang='".(int)($cookie->id_lang)."' AND p.id_product='".$product['product_id']."'"); /* new */ $mycategory = strtolower(preg_replace("/[\r\n ]/","", $cata['name'])); /* changed */ $itemsTable .= '<tr style="background-color:'.($key % 2 ? '#DDE2E6' : '#EBECEE').';"> <td style="padding:0.6em 0.4em;">'.$product['product_id'].'</td> <td style="padding:0.6em 0.4em;"><a href="'._PS_BASE_URL_.__PS_BASE_URI__.$mycategory.'/'.$product['product_id'].'-abcde.html"><strong>'.$product['product_name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').(!empty($customizationText) ? '<br />'.$customizationText : '').'</strong></a></td> <td style="padding:0.6em 0.4em; text-align:right;">'.Tools::displayPrice($unit_price, $currency, false).'</td> <td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['product_quantity']).'</td> <td style="padding:0.6em 0.4em; text-align:right;">'.Tools::displayPrice(($unit_price * $product['product_quantity']), $currency, false).'</td> </tr>'; It works with about half the orders. In the other half "mycategory" is empty for all products and instead I get links like "www.myshop.com//123-abcde.html" (note the double slash!). Clicking such links does work but I am mystified why the category is sometimes empty and what causes this random behavior. Link to comment Share on other sites More sharing options...
math_php Posted September 20, 2012 Share Posted September 20, 2012 Hi Does removing (int)($cookie->id_lang) And replacing by $id_lang // defined above : $id_lang = (int)Configuration::get('PS_LANG_DEFAULT'); solves the problem ? 1 Link to comment Share on other sites More sharing options...
Burhan BVK Posted September 20, 2012 Share Posted September 20, 2012 Apart from the $id_lang, you should also get the link_rewrite instead: $mycategory = Db::getInstance()->getValue("SELECT link_rewrite FROM "._DB_PREFIX_."product p, "._DB_PREFIX_."category_lang l WHERE l.id_category=p.id_category_default AND id_lang='".(int)($id_lang)."' AND p.id_product='".$product['product_id']."'"); 1 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