Hi, i have some thousand products and want to find all products without image. I tried to search for (no image) in the admin products grid, but no result. How to make an SQL query that desables all these products?
I wrote up a blog article a little while back with a sql query to find missing images. It doesn't disable products, but it's a start at least: http://prattski.com/2010/06/29/magento-sql-to-find-missing-images/. Should be pretty easy to do from this point. You may have to change the attribute ID if yours doesn't happen to match mine.
Stop thinking in terms of SQL. Start thinking in terms of Magento's Models. Magento's models just happen to use SQL as a backend. Querying for things via raw SQL is possible, but is going to vary from version to version of the Magento, and may differ depending on the backend you're using.
Run the following from a test controller action, or somewhere else you can execute Magento code from. It queries the model for products with no image
//this builds a collection that's analagous to
//select * from products where image = 'no_selection'
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('image', 'no_selection');
foreach($products as $product)
{
echo $product->getSku() . " has no image \n<br />\n";
//var_dump($product->getData()); //uncomment to see all product attributes
//remove ->addAttributeToFilter('image', 'no_selection');
//from above to see all images and get an idea of
//the things you may query for
}