Magento:从数据库中获取制造商/品牌 [英] Magento: fetching manufacturer/brand from database

查看:147
本文介绍了Magento:从数据库中获取制造商/品牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Mukesh Chapagain获得了以下代码:在此处链接

I have this code from Mukesh Chapagain: link here

$_product = Mage::getModel('catalog/product')->load(PRODUCT_ID);
$manufacturerName = $_product->getAttributeText('manufacturer');
$manufacturerId = $_product->getManufacturer();

即使我将它们作为属性,这似乎也无法吸引制造商.是因为制造商字段是一个下拉列表吗?

This seems not to pick up the manufacturers even though I have them as attributes. Is it due to the fact that the manufacturer field is a drop-down?

在获得制造商属性方面的任何帮助将不胜感激

any help in getting manufacturer attribute will be appreciated

推荐答案

要检索所有商品

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');

foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
     $attributeArray[$option['value']] = $option['label'];
     }  

foreach($attributeArray as $key=>$val){
echo $val;

}

从制造商那里获取产品

    $collection = Mage::getModel('catalog/product')->getCollection();
    $collection->addAttributeToSelect('manufacturer');
    $collection->addFieldToFilter(array(
        array('attribute' => 'manufacturer', 'eq' =>$designer_id),
    ));

让选定的制造商生产产品

 $_productCollection=$this->getLoadedProductCollection();
 foreach ($_productCollection as $_product):
  echo $_product->getAttributeText('manufacturer');
 endforeach;

这篇关于Magento:从数据库中获取制造商/品牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆