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

时间:2021-12-03 09:07:46

How to limit the number of products shown with in the new products block? via cms/pages/design/Layout update XML

如何限制新产品块中显示的产品数量?通过cms / pages / design / Layout更新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 does not work, nor does

setLimit不起作用,也不起作用

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

or:

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

or:

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

or:

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

or:

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

2 个解决方案

#1


5  

Try

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

See /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;
}

Read more @ http://www.magentocommerce.com/wiki/groups/248/display_products_on_home_page

阅读更多@ http://www.magentocommerce.com/wiki/groups/248/display_products_on_home_page

#2


0  

Don't try it randomly. You're trying to call an action on a block/product_new. So go into the class Mage_Catalog_Block_Product_Abstract and see what function could do the job (double Ctrl+O in eclipse)

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

Here i see a Mage_Catalog_Block_Product_Abstract::addColumnCountLayoutDepend($pageLayout, $columnCount) function.

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

Maybe it can help you. Example:

也许它可以帮到你。例:

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

#1


5  

Try

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

See /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;
}

Read more @ http://www.magentocommerce.com/wiki/groups/248/display_products_on_home_page

阅读更多@ http://www.magentocommerce.com/wiki/groups/248/display_products_on_home_page

#2


0  

Don't try it randomly. You're trying to call an action on a block/product_new. So go into the class Mage_Catalog_Block_Product_Abstract and see what function could do the job (double Ctrl+O in eclipse)

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

Here i see a Mage_Catalog_Block_Product_Abstract::addColumnCountLayoutDepend($pageLayout, $columnCount) function.

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

Maybe it can help you. Example:

也许它可以帮到你。例:

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