I have a script file like getproducts.php & have placed it under script/getproducts.php. I want to get products collection in my script file.
code in my file:
<?php require_once('../app/Mage.php'); umask(0); Mage::app('admin'); Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID); $productCollection = Mage::getModel('catalog/product')->getCollection(); echo "Product Count ".$productCollection->getSize();
After executing my getproducts.php through command line
html/demosite/script$ php getproducts.php
I am getting error on prompt:
PHP Fatal error: Uncaught exception 'Mage_Core_Exception' with message 'Invalid entity_type specified: catalog_product' in /var/www/html/demosite/app/Mage.php:595
Note : However it's working when trying to hit directly by Url: