Magento产品画廊

时间:2010-09-21 13:26:45

标签: php collections magento

我不知道我的头衔是否合适,但我想做的事情就像一个画廊或至少我的客户这样称呼它...大声笑......我正在努力做一些像搜索结果页面但没有搜索条件的东西,没有过滤器,只需点击一个链接,查看产品列表,具有相同的功能,更改视图模式(网格,列表),选择产品数量到show和一个寻呼机,我需要一些帮助,到目前为止我所做的是,我创建了一个只有一个操作的新控制器,就像

一样
public function listAction(){
    $this->loadLayout();
    $this->renderLayout();
}

在我的xml布局中

<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>

它与catalogsearch.xml中的catalogsearch_result_index块几乎完全相同,当我试图转到我的新页面时它向我显示没有产品,该集合为空,因此,我在app \ code中更改了funcion _getProductCollection()的内容\ core \ Mage \ Catalog \ Block \ Product \ List.php for this

if (is_null($this->_productCollection)) {
        $category = Mage::getModel('catalog/category')->load(5);
        $productCollection = $category->getProductCollection();
        Mage::getModel('catalog/layer')->prepareProductCollection($productCollection);
        $this->_productCollection = $productCollection->load();
    }
    return $this->_productCollection;

我不喜欢更改核心代码,但现在我正在尝试使其工作,所以,当我刷新页面它向我展示产品时,我可以更改视图模式,我可以看到金额但是,传感器无法正常工作,当我改变我所展示的产品数量时,它什么都不做,只需更改第8项第8项的标签8项,并且不对其进行分组,如果我选择5,它应该只显示5个项目,但我可以看到我的数据库中有8个,所以,

我的代码有什么问题?,如何让寻呼机工作? 感谢

1 个答案:

答案 0 :(得分:0)

我要回答自己。

我在XML布局中做了一些错误的步骤。我改变了

<reference name="left">
    <block type="catalogsearch/layer" name="catalogsearch.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>

<reference name="left">
    <block type="catalog/layer" name="catalogsearch.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>

我将此行更改为默认值

<block type="catalog/product_uhmalist" name="search_result_list" template="catalog/product/list.phtml">

<block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml">

现在一切正常,甚至是寻呼机。无论如何,感谢所有阅读我帖子的人