1
는
나는 PrestaShop 버전의 새로운 해요 : 나는 TPL 파일에 내 쿼리의 결과를 표시하기 위해 노력하고있어, 나는이 오류가 :PrestaShop 버전 : 공지 사항 : 정의되지 않은 인덱스 : PRODUITS
Notice: Undefined index: produits
이것은 내 컨트롤러 코드 :
class AdminStatproduitController extends ModuleAdminController
{
public function init() {
parent::init();
}
public function initContent()
{
parent::initContent();
$products = Db::getInstance()->ExecuteS('SELECT pp.id_product, ppl.name, pps.quantity
FROM `'._DB_PREFIX_.'product` pp
LEFT JOIN '._DB_PREFIX_.'product_sale pps ON pps.id_product = pp.id_product
LEFT JOIN '._DB_PREFIX_.'product_lang ppl ON ppl.id_product = pp.id_product
WHERE pp.cache_is_pack =0
ORDER BY pps.quantity ASC
LIMIT 3');
$pack = Db::getInstance()->ExecuteS('SELECT pp.id_product, ppl.name, pps.quantity
FROM `'._DB_PREFIX_.'product` pp
LEFT JOIN '._DB_PREFIX_.'product_sale pps ON pps.id_product = pp.id_product
LEFT JOIN '._DB_PREFIX_.'product_lang ppl ON ppl.id_product = pp.id_product
WHERE pp.cache_is_pack =1
ORDER BY pps.quantity DESC
LIMIT 3');
$smarty = $this->context->smarty;
$content = $smarty->fetch(_PS_MODULE_DIR_ . 'statproduit/views/templates/admin/statproduit.tpl');
$this->context->smarty->assign(array('produits'=>$products,
'pack'=> $pack,
'content' => $this->content . $content));
}
이 내 TPL 코드
<section>
<div id="formAddPaymentPanel" class="bootstrap panel">
<form id="formAddPayment" method="post">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th><span class="title_box ">Id Produit</span></th>
<th><span class="title_box ">Nom Produit </span></th>
<th><span class="title_box ">Quantité Produit</span></th>
<th><span class="title_box ">Pack Choisie</span></th>
<th></th>
</tr>
</thead>
<tbody>
{foreach from=$produits item=produit}
<tr>
<td>{produit} </td>
<td>product.name</td>
<td>product.quantity</td>
<td>delete</td>
</tr>
</tr>
{/foreach}
</tbody>
</table>
</div>
</form>
</div>
</section>
어떤 제안입니까 ??
감사
먼저 smarty assign을 수행 한 다음 smarty fetch를 수행하십시오. "."예기치 않은 - 라인 (20)에 템플릿 구문 오류 "/projet/PrestaShop/modules/statproduit/views/templates/admin/statproduit.tpl" "
는이 오류를 발생 , 다음 중 하나가 예상 됨 : "}" –