代码之家  ›  专栏  ›  技术社区  ›  Castro Roy

Magento产品库

  •  0
  • Castro Roy  · 技术社区  · 14 年前

    我不知道我的标题是否合适,但我想做的是像画廊或者至少是我的客户这样称呼它……哈哈……我正在尝试执行类似seach结果页面的操作,但是没有搜索条件,也没有过滤器,只需单击一个链接并查看具有相同功能的产品列表,更改视图模式(网格、列表),选择要显示的产品数量和寻呼机,我需要一些帮助,到目前为止,我所做的是,创建一个新的控制器一个简单的动作

    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\core\mage\catalog\block\product\list.php中funcion _getProductCollection()的内容。

    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个项目中项目1-8的标签8个项目,并且不发牢骚。p如果我选择5,它应该只显示5个项目,但是我可以在数据库中看到8个项目,所以,

    我的代码有什么问题?我怎样才能让传呼机工作??
    谢谢

    1 回复  |  直到 8 年前
        1
  •  0
  •   ragingasiancoder Shivam    8 年前

    我要自己回答。

    我在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">
    

    现在一切都正常了,即使是寻呼机。不管怎样,感谢所有读过我文章的人