我正在研究 Magento 的高级搜索。
我搜索 4 个属性。现在,当我选择其中一个属性时,我需要重新加载其他属性以禁用不适合所选属性的属性。有可能以某种简单的方式吗?
我正在研究 Magento 的高级搜索。
我搜索 4 个属性。现在,当我选择其中一个属性时,我需要重新加载其他属性以禁用不适合所选属性的属性。有可能以某种简单的方式吗?
你可以这样过滤:
$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'),
));