Magento 产品库
我不知道我的标题是否合适,但我想做的是类似画廊的东西,或者至少我的客户这样称呼它......哈哈.....我正在尝试做类似的事情搜索结果页面,但没有搜索条件,没有过滤器,只需单击链接即可查看产品列表,具有相同的功能,更改查看模式(网格,列表),选择要显示的产品数量和寻呼机,我在这里需要一些帮助,到目前为止我所做的是,我创建一个新的控制器,只需一个操作,就像
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 项,并且不会将其分组,如果我选择 5,它应该只显示 5 个项目,但我可以看到数据库中的 8 个项目,那么,
我的代码有什么问题?我怎样才能使寻呼机工作?
谢谢
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();
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??
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己来回答一下。
我在 XML 布局中执行了一些错误的步骤。我更改
为
并将此行更改为默认值
现在
一切正常,甚至寻呼机。不管怎样,感谢所有阅读我文章的人
I'm going to answer myself.
I was doing some wrong steps in the XML layout. I changed
to
and I changed this line to the default value
to
Now everything is working, even the pager. Anyway, thanks to everyone who read my post