Magento限制新产品块中显示的产品数量

时间:2012-10-24 13:44:06

标签: xml magento limit product

如何限制新产品块中显示的产品数量? 通过cms / pages / design / Layout update XML

<block type="catalog/product_new" name="home.catalog.product.new" template="catalog/product/new.phtml" >
   <action method="setColumnCount"><count>5</count></action> 
   <action method="setLimit"><limit>5</limit></action>
</block>

setLimit不起作用,也不起作用

<action method="setDefaultGridPerPage"><limit>5</limit></action>

或:

<action method="setData"><key>limit</key><value>3</value></action>

或:

<action method="setProductLimit"><count>5</count></action> 

或:

<action method="setProductsLimit"><count>5</count></action> 

或:

<action method="setProductsCount"><count>5</count></action>

2 个答案:

答案 0 :(得分:5)

尝试

 <action method="setProductsCount"><count>5</count></action>

请参阅/app/code/core/Mage/Catalog/Block/Product/New.php

/**
 * Set how much product should be displayed at once.
 *
 * @param $count
 * @return Mage_Catalog_Block_Product_New
 */
public function setProductsCount($count)
{
    $this->_productsCount = $count;
    return $this;
}

了解更多@ http://www.magentocommerce.com/wiki/groups/248/display_products_on_home_page

答案 1 :(得分:0)

不要随意尝试。您正尝试在block/product_new上调用操作。所以进入类Mage_Catalog_Block_Product_Abstract,看看哪个函数可以完成这项工作(在eclipse中双重Ctrl + O)

我在这里看到Mage_Catalog_Block_Product_Abstract::addColumnCountLayoutDepend($pageLayout, $columnCount)函数。

也许它可以帮到你。例如:

$this->addColumnCountLayoutDepend('one_column', 5)