2014-02-26 45 views
0

我想在搜索结果中的产品数量和标签页 此代码的工作类别页面上,但不是在搜索结果和标签Magento的 - 获得搜索结果页面的产品数量

$this->getLoadedProductCollection()->count(); 

我还检查该代码和所有

$this->getCollection()->count(); 

没有结果,我想用它在list.phtml文件

回答

1

对于搜索结果页面尝试下面的代码:

<?php echo $this->helper('catalogsearch')->__('<strong>%d item(s)</strong>', $this->getResultCount()); ?> 

要获得对下面的代码目录/产品/ list.phtml页面使用的产品总数:

<?php $_productCollection = $this->getLoadedProductCollection(); 
$count = $_productCollection->getSize(); 
echo $count; ?> 
+0

谢谢,但不工作,返回0个项目,但有38个项目:( –

+0

您尝试此代码? – Slimshadddyyy

+0

list.phtml,应该在别的地方使用吗?我需要它只是在list.phtml –

2

你好检查该文件

应用程序/设计/前端/基/默认/模板/ catalogsearch/result.phtml

<?php echo $this->getResultCount(); ?> 

希望这有助于你...

+0

真棒,正在寻找这个,谢谢! –