在您的代码中,您有:
$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
对应于:
/**
* Return current category products
*
* @param integer $id_lang Language ID
* @param integer $p Page number
* @param integer $n Number of products per page
* @param boolean $get_total return the number of results instead of the results themself
* @param boolean $active return only active products
* @param boolean $random active a random filter for returned products
* @param int $random_number_products number of products to return if random is activated
* @param boolean $check_access set to false to return all products (even if customer hasn't access)
* @return mixed Products or number of products
*/
public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null)
所以你要求页面1
和$nb
或10
元素。尝试在该行之前添加$nb = 10000;
以显示多达 10k 种产品(如果您的类别有超过 10k 种产品,请随意增加它)
所以它应该是这样的:
$category = new Category(Context::getContext()->shop->getCategory(),(int)Context::getContext()->language->id);
$nb = 10000;
$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
$this->smarty->assign(array(
'myproducts' => $products,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
));
更新:查看您的问题我发现在您的模板中您正在迭代$products
变量,但将其分配为myproducts
. 我猜 smarty$products
只分配了第一页和$myproducts
您获得的变量。
尝试将您的模板更新为:
{foreach from=$myproducts item=product name=myproducts}