How to print product collection query in magento

Let you have write a product collection with some attribute to select some product, but you are not getting proper result then you must need to print the sql query to see whether you have write the correct syntax in magento default collection. then write the below code to get the sql query .

$productcollection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('bestseller', array('eq' => 1))
echo $productcollection->getSelect()->assemble();

No comments:

Post a Comment