The following piece of code provided by SuperDicq Remove products from all categories when price is zero) gives me a HTTP 500 error, anyone knows what's wrong?

I changed the name of htaccess, put memory limit on 1024mb. I have other scripts which are causing no problems. Also when I add this one below they start giving errors as well.

  require_once 'app/Mage.php';
$products = Mage::getModel('catalog/product')->getCollection()
            array('attribute'=>'price', 'eq'=>'0'),
            array('attribute'=>'price', 'isnull'=>true),
$category_id = 863; // "Old models" category ID.
foreach($products as $product) {
  • 1
    Is this script on your magento root ?
    – user55548
    Commented Mar 14, 2019 at 9:52
  • 1
    Isn't there anything in your log files? 500 server errors could also imply errors on your webserver (httpd/nginx), so it would make sense to check those as well besides your Magento log files. Commented Mar 14, 2019 at 10:02
  • Yes it's in the root. Can't find any error in the logs when I turn error reporting on
    – Dahaan
    Commented Mar 14, 2019 at 10:05

2 Answers 2


HTTP 500 Error can occur due to the file permission also..i have the same issue today..

check that the file have proper file permission..

php file need a 644 permission..

please try this..

  • Thanks for your reply, unfortunately it's already on 644 :(
    – Dahaan
    Commented Mar 14, 2019 at 12:10

I had the same issue and found out that, in my case it was due to large sets of data.

Ended up adding:

->setPageSize(X) ->setCurPage(1);

To the collection. I simply started by adding a small number to setPageSize() eg. X = 100 and then slowlyg worked my way up till I found a higher number, that didn't cause error 500.

It might be some settings that needs to be changed, but for now this can resolve the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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