【问题标题】:Magento limit the number of products shown with in the new products blockMagento 限制新产品块中显示的产品数量
【发布时间】:2014-09-30 19:22:44
【问题描述】:

如何限制新产品块中显示的产品数量? 通过 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 不起作用,

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

【问题讨论】:

    标签: xml magento limit product


    【解决方案1】:

    试试

     <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

    【讨论】:

    • 你是对的!我在全新安装的 magento 上对此进行了测试,它确实有效。我发现有一个使用保留命名空间的覆盖模块。这就是为什么它对我不起作用。
    【解决方案2】:

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

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

    也许它可以帮助你。示例:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多