2013-02-07 15 views
0

我的問題: 我需要在員工informations.tpl的Prestashop

管理\主題僱員名單\ DEFAULT \模板\控制器\產品\ informations.tpl:

http://darkplace.pl/wp-content/uploads/2013/02/1111111111.png

所以我在粘貼代碼:

\覆蓋\類\ P roduct.php

<?php 
class Product extends ProductCore 
{ 
public static function getEmployees() 
{ 
    return Db::getInstance()->executeS(' 
    SELECT `id_employee`, `firstname`, `lastname` 
    FROM `'._DB_PREFIX_.'employee` 
    WHERE `active` = 1 
    ORDER BY `lastname` ASC 
    '); 
} 

} 
?> 

& &

管理\主題\默認\模板\控制器\產品\ informations.tpl:

<select name="id_employee_forward" style="vertical-align: middle;"> 
<option value="-1">{l s='-- Choose --'}</option> 
{foreach $employees as $employee} 
    <option value="{$employee.id_employee}"> {Tools::substr($employee.firstname, 0, 1)}. {$employee.lastname}</option> 
{/foreach} 
<option value="0">{l s='Someone else'}</option> 
</select> 

它不工作 我認爲我需要在某處引入此代碼。

$employees = Product::getEmployees(); 

但是在我自己弄明白之前,地獄會凍結。所以它就是這樣。任務4最好。 請幫幫我!

回答

0

你需要使用Smarty的,從你的截圖看起來分配的數據,如您需要這樣做在位於/控制器/管理文件AdminProductsController.php/

你會用下面的代碼實現這一點。

$this->context->smarty->assign("employees", Product::getEmployees());

我會將此代碼放在功能renderForm()

+0

謝謝各位高手programator。它像一個魅力。你很棒哦! – user2049994