1

want to do filtering of product name like status is done.(the product [Samsung,alien] these values are displayed randomly from database,i don't know where its code is written and on which logic its being rendered). please provide the answer in steps.

Thanks in advance.

Nikhil_K_R
  • 2,383
  • 5
  • 27
  • 51
  • Not sure if I understand. You're talking about the 'Manage Products' page in the Magento admin backend, correct? Where are the random product names being displayed? – 1000Nettles Oct 08 '12 at 11:56
  • Samsung,alien,HTC... which i have added in drop down... >>> P.S:- I have created admin module with module Creator... – Nikhil_K_R Oct 08 '12 at 14:16
  • i received the solution .Just added the index data with my database field name (location:/var/www/magento/app/code/local/One/First/Block/Adminhtml/First/Grid.p‌​hp) -->$this->addColumn('select_first',array( 'header' => Mage::helper('first')->__('Product Name'), 'width' => '150px', 'index' => 'proid', 'type' => 'options', 'options' => Mage::getSingleton('first/arrayf')->getProArray(), )); – Nikhil_K_R Oct 09 '12 at 12:10

2 Answers2

1

i received the solution .Just added the index data with my database field name (location:/var/www/magento/app/code/local/One/First/Block/Adminhtml/First/Grid.p‌​‌​hp)
----------->
$this->addColumn('select_first',array( 'header' => Mage::helper('first')->__('Product Name'), 'width' => '150px', 'index' => 'proid', 'type' => 'options', 'options' => Mage::getSingleton('first/arrayf')->getProArray(), ));

Nikhil_K_R
  • 2,383
  • 5
  • 27
  • 51
0
 $collection = Mage::getModel('catalog/product')->getCollection()
        ->addAttributeToSelect('sku')
        ->addAttributeToSelect('name')
        ->addAttributeToSelect('attribute_set_id')
        ->addAttributeToSelect('type_id')
        ->joinField('qty',
            'cataloginventory/stock_item',
            'qty',
            'product_id=entity_id',
            '{{table}}.stock_id=1',
            'left')
        ->joinAttribute('status', 'catalog_product/status',
                        'entity_id', null, 'inner', $store->getId());

Now you have all products and respective status on $collection, you can do filter this way:

$collection->addAttributeToFilter('status', array(
'like' => array('status'),
));
Guerra
  • 2,792
  • 1
  • 22
  • 32
  • $collection->addAttributeToFilter('status', array( 'like' => array('status'), )); where to add this part of code.... – Nikhil_K_R Oct 08 '12 at 14:19
  • Anyplace, look..... When u get the collection, you can use this instruction to filter the collection, so... use when you want filter. If you prefer you can use after get the collection. Or on the code of collection, before ; – Guerra Oct 08 '12 at 14:29
  • i received the solution .Just added the index data with my database field name (location:/var/www/magento/app/code/local/One/First/Block/Adminhtml/First/Grid.php) -->$this->addColumn('select_first',array( 'header' => Mage::helper('first')->__('Product Name'), 'width' => '150px', 'index' => 'proid', 'type' => 'options', 'options' => Mage::getSingleton('first/arrayf')->getProArray(), )); – Nikhil_K_R Oct 09 '12 at 12:05