0

Been trying to get this to work and can't work out if it is me, the code or the installation. Basically I am trying to get a list of all the suppliers in the system. Magento 1.4.0.1 is in use. I have tried to use the code at Magento Wiki but it just returns an empty array. As is or modified to use the "suplier" attribute. I don't seem to be able to get it to return anything. Can anyone point me in the right direction as to how to get the list?

Khainestar
  • 307
  • 5
  • 11

2 Answers2

0

try this code,it may be helpful to you

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product','supplier');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option )
{
  echo $option['value'];
  echo $option['label'];
 }
Mufaddal
  • 5,398
  • 7
  • 42
  • 57
0

Looks like only one way to do this. Dump the magento bits and just hit the database.

$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');

Gets the list as a straight array. Which can then be output as I want. The attribute id of 525 is from the eav_attribute table, no idea if it is going to be the same for all systems.

Khainestar
  • 307
  • 5
  • 11