2

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';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
Mage::app();
$products = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToFilter(
        array(
            array('attribute'=>'price', 'eq'=>'0'),
            array('attribute'=>'price', 'isnull'=>true),
        )
);
$category_id = 863; // "Old models" category ID.
foreach($products as $product) {
    $product->setCategoryIds($category_id);
    $product->save();
}
  • 1
    Is this script on your magento root ? – user55548 Mar 14 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. – Giel Berkers Mar 14 at 10:02
  • Yes it's in the root. Can't find any error in the logs when I turn error reporting on – Dahaan Mar 14 at 10:05
1

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 Mar 14 at 12:10

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.