I'm trying to learn magento but I have to finish the project that I'm working on as fast as I can. So I'm stuck in somewhere. Then I decided to use pure sql. (I know it's really messy)

So is anynone know how can I get all products with sql? I researched database but can't find.

I need product name, thumbnail, price, rating, reviews count and attributes.


Do it clean!


require_once 'app/Mage.php';

$collection = Mage::getResourceModel('reports/product_collection')

foreach ($collection as $product) {
    // build your JSON here
| improve this answer | |
  • How can I connect database with this code? I need json data. Do I need include any file? – Ibrahim Mumcu Feb 24 '14 at 10:53
  • See edit. The file have to be placed in Magento root dir. – user487772 Feb 24 '14 at 10:58
  • echo $collection seems empty. – Ibrahim Mumcu Feb 24 '14 at 11:03
  • What about echo $collection->getSize();? – user487772 Feb 24 '14 at 11:06
  • It's return 1 (There is one product) – Ibrahim Mumcu Feb 24 '14 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.