How can I get raw full sql query from non-loaded product collection with addAttributeToSelect() method without load collection ?
This code:
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('name');
$collection->getSelect()->assemble();
retrieve only
SELECT `e`.* FROM `catalog_product_entity` AS `e`
If it is impossible, why?
P.S. There is no problem to get the full sql code if addAttributeToFilter() method was used.
Best Answer
It is impossible (using magento methods), because magento load products (EAV entity more correct) early then load attributes for them.
I assumed that parametr
$printQuery = true
allow log EACH internal query in bulding collection process, but it does not use in both_loadEntities()
and_loadAttributes()
. I was confused by it.Edit: For non-static attributes you can use
joinType
param - in this case it is possible get sql code without collection load:So, if you want to get raw collection data as fast as possible, here the safe methods: