Nikhil_K_R
Nikhil_K_R

Reputation: 2373

how to do filtering work by drop down of admin module in magento ?(e.g status----> enabled)

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.

Upvotes: 1

Views: 1632

Answers (2)

Nikhil_K_R
Nikhil_K_R

Reputation: 2373

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(), ));

Upvotes: 1

Guerra
Guerra

Reputation: 2790

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

Upvotes: 0

Related Questions