2014-02-26 47 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

真棒,正在尋找這個,謝謝! –