Prestashop 1.6 在邮件模板中添加产品的制造商名称

Prestashop 1.6 add product's manufacturer name in mail template

我想在新的订单电子邮件中添加产品的制造商名称。客户方和管理方。

所以,我尝试编辑 /mails/fr/order_conf_product_list.tpl 文件以添加一个新单元格

{$product['manufacturer_name']}

但没有机会。

我已经尝试过论坛中的一些提示,如下所示,但单元格仍然是空的...

https://www.prestash...turer-reference

任何帮助将不胜感激。

非常感谢。

要实现这个操作,需要在变量manufacturer之前添加

对于您的测试,您可以编辑文件 [your_shop]/classes/PaymentModule.php(但更好的解决方案是使用覆盖):

1 - 保留制造商对象

2 - 在 product_var_tpl

中添加制造商对象
foreach ($order->product_list as $product) {
 $manufacturer = new Manufacturer((int)$product['id_manufacturer']);
 ****
  $product_var_tpl = array(
'manufacturer' => $manufacturer,
'reference' => $product['reference'],
'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
'quantity' => $product['quantity'],
'customization' => array()
                        );

}

并且在你的文件中 /mails/fr/order_conf_product_list.tpl

你可以使用对象'manufacturer'

{$product['manufacturer']->name}

如@timactive 所写,在客户邮件中获取制造商名称的解决方案是编辑 PaymentModule.php。

因此,要在客户邮件中获取制造商名称:

PaymentModule.php :

             foreach ($order->product_list as $product) {

                $manufacturer = new Manufacturer((int)$product['id_manufacturer']);

                $product_var_tpl = array(
                    'reference' => $product['reference'],
                    'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
                    'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
                    'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
                    'quantity' => $product['quantity'],
                    'customization' => array(),
                    'manufacturer' => $manufacturer->name
                );

与 order_conf_product_list.html 相比,这样调用产品对象:

            {$product['manufacturer']}

这是解决方案的一部分,因为我也想在管理员新订单邮件中添加制造商名称。

在管理员新订单邮件中添加制造商名称:

为了完成这个,我必须像这样编辑 MailAlert 模块:

在mailalert.php中,在函数"hookActionValidateOrder"中:

foreach ($products as $key => $product)
    {
        $manufacturer = new Manufacturer($product['id_manufacturer'], $id_lang);
        $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;">'.$manufacturer->name.'</td>
                <td style="padding:0.6em 0.4em;">
                    <strong><a href="'.$url.'">'.$product['product_name'].'</a>'
                        .(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '')
                        .(!empty($customization_text) ? '<br />'.$customization_text : '')
                    .'</strong>
                </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>';

现在,要创建单元格,请转至 mailalert/mails/fr/new-order.html 并在第 114 行周围添加此行:

                <th style="border:1px solid #D6D4D4;background-color:#fbfbfb;font-family:Arial;color:#333;font-size:13px;padding:10px">Marque</th>