0

一直试图让它工作,如果是我,代码或安装都无法解决。基本上,我正在尝试获取系统中所有供应商的列表。Magento 1.4.0.1 正在使用中。我曾尝试使用Magento Wiki上的代码,但它只返回一个空数组。按原样或修改为使用“供应商”属性。我似乎无法让它返回任何东西。谁能指出我如何获取列表的正确方向?

4

2 回答 2

0

试试这个代码,它可能对你有帮助

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product','supplier');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option )
{
  echo $option['value'];
  echo $option['label'];
 }
于 2012-04-24T12:52:57.933 回答
0

看起来只有一种方法可以做到这一点。转储 magento 位,然后访问数据库。

$magentoDb = Mage::getSingleton( 'core/resource' )->getConnection( 'core_write' );

$results = $magentoDb->fetchAll('SELECT DISTINCT(`value`) AS supplierName FROM `catalog_product_entity_varchar` WHERE `attribute_id` = 525 ORDER BY supplierName');

将列表作为一个直数组获取。然后可以根据需要输出。525 的属性 id 来自 eav_attribute 表,不知道它是否对所有系统都相同。

于 2012-04-25T11:05:08.950 回答