Magento filter products collection get only visible

You want to retrieve all your products but only the one visible in catalog or filter ?

You may use this

 $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
 Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
 Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

But it’s depreacated and doesn’t work.
You may instead use this :

 $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
 $collection->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);