i don't know if my title is ok, but what i'm trying to do is something like a gallery or at least my client call it this way...lol..... i'm trying to do something like the seach result page but without a search criteria, without a filter, just click in a link and see a list of products, with the same funcionality, change the view mode(Grid, List), select the amount of products to show and a pager, i need some help here, what I've done so far is, i create a new controller with just one action as simple as
public function listAction(){
$this->loadLayout();
$this->renderLayout();
}
in my xml layout
<catalog_products_list>
<reference name="root">
<action method="setTemplate"><template>page/1columns.phtml</template></action>
</reference>
<reference name="left">
<block type="catalogsearch/layer" name="catalogsearch.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>
<reference name="content">
<block type="catalog/product_uhmalist" name="search_result_list" template="catalog/product/list.phtml">
<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>
<block type="core/text_list" name="additional">
<block type='enterprise_search/suggestions' name='search_suggestions' template="search/suggestions.phtml"></block>
<block type='enterprise_search/recommendations' name='search_recommendations' template="search/recommendations.phtml"></block>
</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
<action method="setPageLayout"><layout>three_columns</layout></action>
</block>
<action method="setListOrders"/>
<action method="setListModes"/>
<action method="setListCollection"/>
</reference>
</catalog_products_list>
it is almost identical to catalogsearch_result_index block in catalogsearch.xml, when i tried to go to my new page it show me no products, the collection was empty, so, i change the content of funcion _getProductCollection() in app\code\core\Mage\Catalog\Block\Product\List.php for this
if (is_null($this->_productCollection)) {
$category = Mage::getModel('catalog/category')->load(5);
$productCollection = $category->getProductCollection();
开发者_JAVA技巧 Mage::getModel('catalog/layer')->prepareProductCollection($productCollection);
$this->_productCollection = $productCollection->load();
}
return $this->_productCollection;
i don't like to change the core code, but now i'm trying to make it work, so, when i refresh the page it show me the products, i can change the view mode, i can see the amount of products, but, the pager don't work, when i change the amount of product i whanna show, it do nothing, just change the label 8 Item(s) for Item 1-8 of 8, and doesn't group it, if i pick 5, it should show just 5 items, but i can see the 8 i have in my db, so,
what is wrong with my code?, how can i make the pager work??
thanksI'm going to answer myself.
I was doing some wrong steps in the XML layout. I changed
<reference name="left">
<block type="catalogsearch/layer" name="catalogsearch.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>
to
<reference name="left">
<block type="catalog/layer" name="catalogsearch.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>
and I changed this line to the default value
<block type="catalog/product_uhmalist" name="search_result_list" template="catalog/product/list.phtml">
to
<block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml">
Now everything is working, even the pager. Anyway, thanks to everyone who read my post
精彩评论