1

Hi i have this form on backend with select input.

 $fieldset->addField('product_id', 'select', array(
                        'label'     => Mage::helper('banermanager')->__('Product ID'),
                        'values'   => Iv_BanerManager_Block_Adminhtml_Banermanager_Grid::getValueArray3(),
                        'name' => 'product_id',
                        ));     

What do i have to change on 'values' to get list of all products on shop with their id's ?

  • I think the easiest would be to implement your own source model for values, instantiate this and call getAllOptions(). Just search for this method inside of magento to get an idea how to implement it and what you need to return – Fabian Blechschmidt Apr 9 '14 at 13:31
1

You can make your field config look like this:

//I'm not sure which one is correct, but I has 2 be one of the 2 - try them both
$products = Mage::getResourceModel('catalog/product_collection')->toOptionArray();
//or
//$products = Mage::getResourceModel('catalog/product_collection')->toOptionHash();


$fieldset->addField('product_id', 'select', array(
       'label'     => Mage::helper('banermanager')->__('Product ID'),
       'values'   => $products,
       'name' => 'product_id',
));   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.