2012-12-31 31 views
0

我使用這個tutorial並在多個類別的基礎上顯示產品,但現在我遇到的問題是,尋呼機工具欄無法正常工作。 我的塊的代碼是:傳呼機工具欄在magento的自定義模塊中

<reference name="content"> 
    <block name="mymodule" type="mymodule/product_listcategories" template="catalog/product/list.phtml"> 
     <action method="setCategories"> 
      <ids>2,3,4</ids> 
     </action> 
    </block> 
</reference> 

我也與上述

<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml"> 
    <block type="page/html_pager" name="product_list_toolbar_pager"/> 
    </block> 
    <action method="setToolbarBlockName"><name>product_list_toolbar</name></action> 
</block> 

它顯示的工具欄添加此代碼,但工具欄不工作(限,排序依據)。 我的區號是

class Mymodule_Block_Product_Listcategories extends Mage_Catalog_Block_Product_List 
{ 
    protected function _getProductCollection() 
    { 

     $this->_productCollection = Mage::getModel('catalog/product')->getCollection(); 
     $this->_productCollection->addAttributeToSelect('*'); 

     if($this->getCategories()!="") 
      $this->_productCollection->addCategoriesFilter($this->getCategories()); 

      return $this->_productCollection; 
     } 
    } 
} 

有沒有人知道問題在哪裏?我想我錯過了尋呼機的一些代碼?在此先感謝

回答

0

搜索這麼多,我得到了經過solution.I不知道是否正確或錯誤的方式,但它解決了我的problem.On我的塊我創建的 $cpBlock = $this->getLayout()->getBlockSingleton('Mage_Catalog_Block_Product_List_Toolbar'); intance和訪問尋呼機核心功能像$this->_itemPerPage = $cpBlock->getLimit();。在上面的代碼中,itemperpage是要在列表頁面上顯示的項目總數。如果您創建自定義模塊並將其從列表塊中擴展出來,則此代碼工作。感謝