It works beautifully if I'm trying to get collection but it won't for single product by SKU. for example:
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_sku); echo $test = $product->getSelect()->__toString(); How can I get sql for a single product can I? or I must get collection with filter by sku then getSelect()....
... after a quick research ...
$products = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED)) ->addAttributeToFilter('sku',$_sku); it does the job.