2011-09-26 17 views
0

我試圖Magento中獲得的所有可用的產品系列&過濾該集合如何addAttributeToFilter?

這裏是我的代碼:

$searcher = Mage::getModel('catalog/product')->getCollection(); 
$searcher->addAttributeToSelect('name'); 
echo count($searcher); 
$searcher->addAttributeToFilter('name',array('like' => 'paper')); 
$searcher->load(); 
echo count($searcher); 

現在第一次給數745(適用於所有產品),但過濾後仍然顯示745.

回答

1

編輯:這對我的作品:

$searcher = Mage::getModel('catalog/product')->getCollection() 
      ->addAttributeToSelect('name') 
      ->addAttributeToFilter('name',array('eq' => 'paper')); 
$searcher->load(); 
echo count($searcher); 
+0

好肯尼我正在嘗試這個&給你答案。非常感謝您的快速回復。 – Kaushal

+0

請查看此鏈接「http://eagle.arvixe.com/~houselav/index.php/catalogsearch/advanced/result/?name=paper&description=&short_description=&sku=&price[from]=&price[to]=」。 – Kaushal

+0

在所有標籤下有745745.第一個745在過濾之前,然後在過濾之後。 – Kaushal

相關問題