0

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: http://localhost/demosite/script/getproducts.php

0

Try This :-

require_once('app/Mage.php');
umask(0);
Mage::app();


ini_set("memory_limit","1024M");
$productCollection = Mage::getModel('catalog/product')->getCollection();

echo "Product Count ".$productCollection->getSize();
  • Tried. It's not working. same issue. – Mr. Nanhe May 28 at 5:26

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.