0
$this->_productCollection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('manufacturer',array(
    "eq",'43') 
                                           )
                      );

这会根据属性的 id(一个数字)获取某个制造商的产品。

如何修改它以获取某个制造商(或属性)的产品,但使用属性的值,而不是 id?

4

2 回答 2

1

你可以试试这个,->addFieldToFilter(array(array('attribute'=>'manufacturer','eq'=>'ABC')

于 2012-10-06T17:02:11.820 回答
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); 
于 2012-10-06T16:38:09.133 回答