Back Office Order Comments

message-in-a-bottle-wallpaper-1920x1200re

In the latest versions of prestashop we have the problem that do not appear in the backoffice comments dorders information.
We will try to solve it by making a series of changes in some files in the installation of prestashop version 1.5.6.2

– Open CustomerThread.php file from classes folder and add following function just after function getNextThread.

public static function getCustomerMessagesByOrderId($id_order)
{
  $sql = 'SELECT ct.*,cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname
   FROM '._DB_PREFIX_.'customer_thread ct
   LEFT JOIN '._DB_PREFIX_.'customer_message cm
    ON ct.id_customer_thread = cm.id_customer_thread
   LEFT JOIN `'._DB_PREFIX_.'customer` c
    ON ct.`id_customer` = c.`id_customer`
   LEFT JOIN '._DB_PREFIX_.'employee e
    ON cm.id_employee = e.id_employee
   WHERE id_order = '.(int)$id_order.' ORDER BY cm.id_customer_message DESC';

  return Db::getInstance()->executeS($sql);
}

 

– Open AdminOrdersController.php file from controllers/admin folder and replace this line

'messages' => Message::getMessagesByOrderId($order->id, true),

with this

'messages' => CustomerThread::getCustomerMessagesByOrderId($order->id, true),

To show date and time in messages Both view.tpl from yourAdmin open file / themes / default / template / controllers / orders / helpers / view folder and Change This line

{l s='At'} <i>{dateFormat date=$message['date_add']}

with this

{l s='At'} <i>{$message['date_add']}

– If making these changes does not show us the messages we have to also make a change to the file classes / Messages.php

Replacing this code

public static function getMessagesByOrderId($id_order, $private = false, Context $context = null)
{
if (!Validate::isBool($private))
die(Tools::displayError());

if (!$context)
$context = Context::getContext();

return Db::getInstance()->executeS('
SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname,
(COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me
FROM `'._DB_PREFIX_.'message` m
LEFT JOIN `'._DB_PREFIX_.'customer` c ON m.`id_customer` = c.`id_customer`
LEFT JOIN `'._DB_PREFIX_.'message_readed` mr
ON mr.`id_message` = m.`id_message`
AND mr.`id_employee` = '.(isset($context->employee) ? (int)$context->employee->id : '\'\'').'
LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
WHERE id_order = '.(int)$id_order.'
'.(!$private ? ' AND m.`private` = 0' : '').'
GROUP BY m.id_message
ORDER BY m.date_add DESC
');
}

 

with this

 

public static function getMessagesByOrderId($id_order, $private = false, Context $context = null)
{
if (!Validate::isBool($private))
die(Tools::displayError());
if (!$context)
$context = Context::getContext();
$m = Db::getInstance()->executeS('
SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname,
(COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me
FROM `'._DB_PREFIX_.'message` m
LEFT JOIN `'._DB_PREFIX_.'customer` c ON m.`id_customer` = c.`id_customer`
LEFT JOIN `'._DB_PREFIX_.'message_readed` mr
ON mr.`id_message` = m.`id_message`
AND mr.`id_employee` = '.(isset($context->employee) ? (int)$context->employee->id : '\'\'').'
LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
WHERE m.`id_order` = '.(int)$id_order.'
'.(!$private ? ' AND m.`private` = 0' : '').'
GROUP BY m.id_message
ORDER BY m.date_add DESC
');

$o = Db::getInstance()->executeS('
SELECT ct.*, m.*, e.`firstname` AS efirstname, e.`lastname` AS elastname
FROM `'._DB_PREFIX_.'customer_thread` ct
LEFT JOIN `'._DB_PREFIX_.'customer_message` m ON m.`id_customer_thread` = ct.`id_customer_thread`
LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
WHERE ct.`id_order` = '.(int)$id_order.'
ORDER BY ct.`date_add` DESC'
);

return array_merge($o,$m);

}

 

 

 

 

 

 

Posted on 09/03/2014 in Prestashop

Share the Story

About the Author

Responses (3)

  1. Rudy
    09/03/2014 at 12:24 pm · Responder

    great work. Thanks

  2. Robin
    15/03/2014 at 6:07 pm · Responder

    Hi mate,
    Already done the last part still didn’t work
    I have posted in your prestashop forums.
    Here is the link : http://www.prestashop.com/forums/topic/203620-back-office-order-comments-no-longer-in-order-page/page-6

    • Antonio Ventura
      16/03/2014 at 9:00 am · Responder

      review your folder / overrride. If you have any file to overwrite the installation. Also empty the folder / cache / smarty / compile

Leave a reply

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Back to Top