Php 使用其他属性筛选magento的产品属性

Php 使用其他属性筛选magento的产品属性,php,magento,advanced-search,Php,Magento,Advanced Search,我正在研究Magento的高级serach。 我通过4个属性进行搜索。现在,当我选择其中一个属性时,我需要重新加载其他属性以禁用与所选属性不匹配的属性。以某种简单的方式是可能的?rzeka 你可以这样做过滤 $collection = Mage::getModel('catalog/product')->getCollection(); $collection->addAttributeToSelect('name'); $collection->addAttributeT

我正在研究Magento的高级serach。 我通过4个属性进行搜索。现在,当我选择其中一个属性时,我需要重新加载其他属性以禁用与所选属性不匹配的属性。以某种简单的方式是可能的?

rzeka

你可以这样做过滤

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('name');  
$collection->addAttributeToSelect('orig_price');    

//filter for products whose orig_price is greater than (gt) 100
$collection->addFieldToFilter(array(
    array('attribute'=>'orig_price','gt'=>'100'),
)); 

//AND filter for products whose orig_price is less than (lt) 130
$collection->addFieldToFilter(array(
    array('attribute'=>'orig_price','lt'=>'130'),
));
While this will filter by a name that equals one thing OR another.

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('name');  
$collection->addAttributeToSelect('orig_price');    

//filter for products who name is equal (eq) to Widget A, or equal (eq) to Widget B
$collection->addFieldToFilter(array(
    array('attribute'=>'name','eq'=>'Widget A'),
    array('attribute'=>'name','eq'=>'Widget B'),        
));