prestashop获得类别产品

时间:2018-03-30 18:22:17

标签: prestashop categories product

我创建新模块

此模块是在主页上添加类别产品

代码是

public static function getproducts($id)
{
    $category = new Category($id,(int)Context::getContext()->language->id);
    $nb = 10000;
    $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));

    return $products;
}

tpl是代码

{foreach $categories as $c}
{assign var='products' value={fhomecategory::getproducts($c.id_category)}}
{include file="$tpl_dir./product-list.tpl" products=$products class='fhome' id='fhome'}

{/ foreach}的

错误 - > Click show image

1 个答案:

答案 0 :(得分:0)

使用以下代码检查:

$category = new Category($id, (int)Context::getContext()->language->id);
$nb = 10000;
$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10), 'date_upd', 'DESC', false, true, true, ($nb ? $nb : 10));

这可能会有所帮助。