2013-05-31 2 views
1

prestashop에 카테고리 페이지 용 모듈을 구축 중입니다. Prestashop은 페이지 매김없이 모든 제품 양식 카테고리를 표시합니다.

은 기본적으로 내 module.php에이 코드를 가지고 :

mymodule.tpl에서 다음
$category = new Category(Context::getContext()->shop->getCategory(),(int)Context::getContext()->language->id); 
    $nb = (int)(Configuration::get('MOD_NBR')); 
    $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')), 
    )); 

나는이 있습니다

{foreach from=$products item=product name=myproducts} 

+ other stuff 
문제는 내가 내부의 모든 제품을 얻을 필요가있다

카테고리이지만 첫 번째 페이지에만 제품을 표시합니다. 페이지 페이지에 다른 제품이 필요하기 때문에 페이지 매김을 완전히 삭제하거나 수정할 수는 없지만 모듈에서 한 번에 모든 제품을 가져오고 싶습니다 (일부만 보여주기 위해 필터를 적용한 후에) .

$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10)); 

해당 : 당신은 내가 가지도 필사적 잃었지만,하고 볼 수 있습니다으로

, 나는 당신이 어떤지도 :

덕분에 당신의 코드에서

답변

4

을 주셔서 감사합니다 로 : 그래서

/** 
    * 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 요구하고있다 d $nb 또는 10 요소 그 라인 $nb = 10000; 전에 추가 봅니다 10K 제품 표시 (당신의 범주 이상 10,000 제품이있는 경우를 증가 주시기)

을 그래서해야 할 뭔가 같은 :

$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')), 
)); 

UPDATE : 귀하의 질문을 검토 한 결과 나는 템플릿에서 $products 변수를 반복하고 있지만 myproducts으로 할당하고 있음을 발견했습니다. 나는 smarty가 할당 된 변수가 $products이고 첫 번째 페이지 만 가지고 있고 $myproducts은 획득 한 변수와 같다고 추측합니다. 나는 그것을 시도 답장을

{foreach from=$myproducts item=product name=myproducts} 
+0

감사합니다,하지만 작동하지 않았다 :

는 당신의 템플릿을 업데이트하십시오. 나는 그것이 범주 페이지에 삽입하고 있기 때문에 그것이 그 페이지 구성을 유지하기 때문에 그것이라고 생각합니다. 다른 생각이 있습니까? 감사! – lilymz

+0

질문을 다시 읽은 것으로 대답을 업데이트했습니다. 작동한다면 시도해 볼 수 있습니까? 작동하는 경우 첫 번째 제안 된 수정없이 업데이트 된 부품을 사용해 볼 수 있습니까? – ipeiro

관련 문제