//Load product model collecttion filtered by attribute set id
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*');
//process your product collection as per your bussiness logic
$productsName = array();
$products_sku = array();
foreach($products as $p)
{
$productsName[$p->getId()]=$p->getName();
$products_sku[$p->getId()]=$p->getSku();
}
$this->addColumn('product_N', array('header' => Mage::helper('deals')->__('Product name'),
'align' =>'left',
'index' => 'product_N',
'type' => 'options',
'option' => $productsName,
));
$this->addColumn('product_sku', array('header' => Mage::helper('deals')->__('Product SKU'),
'align' =>'left',
'index' => 'product_sku',
'type' => 'options',
'option' => $products_sku,
));
我错过了一些内容,因为下拉列表中没有显示任何值,而在foreach循环中每个变量print_r()
时,它都会显示array()
个值。
答案 0 :(得分:0)
foreach($products as $p)
{
$productsName[$p['value']] = $p->getName();
$products_sku[$p['value']] = $p->getSku();
}
也许?