$this->_productCollection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('manufacturer',array(
"eq",'43')
)
);
根据属性的id(即数字)获取某个制造商的产品。
如何修改此产品以获取某个制造商(或属性)的产品,但具有属性的值,而不是ID?
答案 0 :(得分:1)
你可以试试这个, - > addFieldToFilter(阵列( 阵列( '属性'=> '制造商', '当量'=> 'ABC')
答案 1 :(得分:0)
尝试
$manufacturer_name = 'xyz';
$product = NULL;
$manufacturer_id = NULL;
$manufacturers = Mage::getModel('eav/config')->getAttribute('catalog_product','manufacturer')->getSource()->getAllOptions(false,true);
foreach($manufacturers as $m){
if(strtolower($m['label']) == strtolower($manufacturer_name)){
$manufacturer_id = $m['value'];
continue;
}
}
if($manufacturer_id){
$product = Mage::getModel('catalog/product')->loadByAttribute('manufacturer', $manufacturer_id);
}
print_r($product);