0

I have a php script for my magento page which fixes texterrors. It worked fine when I had like 10 products in my shop. Now I do have over 3000 and if I try to run the script, it takes about 3 seconds and then an empty page is shown.

<?php
include_once "app/Mage.php";
Mage::init();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$yourstring = array( 'ä', 'ö' , 'Ã' , 'ü' , '°' , '<short_description>' , '</short_description>    <full_description>' , '</full_description>' , '</weight>');
$newstring =  array( 'ä' , 'ö'  , 'ø'    , 'ü'  , '°'  , 'SHORT_DESCRIPTION'   , 'SHORT_DESCRIPTION'                          , 'DELETE'              , 'DELETE');

$_productCollection = Mage::getModel('catalog/product')
                    ->getCollection()
                    ->addAttributeToSelect('*')
                    ->load();

echo 'RUNNING SCRIPT...<br /><br /><br /><br />';               
for ($i = 0; $i <= 8; $i++) {
  echo 'Letter to fix: '.$newstring[$i].'<br />';
  foreach($_productCollection as $_product) {

    if (strpos($_product->getDescription(),$yourstring[$i]) !== false) {

      $newdescription = str_replace($yourstring[$i],$newstring[$i],$_product->getDescription());
      $_product->setDescription($newdescription);
      $_product->save();

      echo 'Updated product: '.$_product->getName().'<br />';
    }

  }
  echo '<br /><br />';
}
?>

It should at least display the "RUNNING SCRIPT" message but it doesn't. I'm really confused.

Thank you!

9
  • What is script timeout set to? Commented Jul 29, 2015 at 6:38
  • where can i find that out? Commented Jul 29, 2015 at 6:43
  • 1
    did you check the error logs? or turn on error reporting / display errors. The white page of death. Commented Jul 29, 2015 at 6:57
  • the blank page suggests that you have an error somewhere. as suggested by @ArtisiticPhoenix, you should turn on error reporting, and/or check the error logs. Commented Jul 29, 2015 at 6:58
  • where can i turn that on? I'm just confused because the script worked fine and i did not change anything Commented Jul 29, 2015 at 7:03

1 Answer 1

1

At the beginning of the script (right before include) add error_reporting(E_ALL ^ E_NOTICE);. Thanks to that errors will be visible at the screen and you will be able to correct them.

If there is no errors and script will still behave as you described try change allowed execution time. For more information look here.

Sign up to request clarification or add additional context in comments.

4 Comments

thank you, but the script didn't show any errors and adding a longer execution time with the function set_time_limit did not help :(
Add ini_set("display_errors", 1);, ini_set("track_errors", 1); and ini_set("html_errors", 1); before error_reporting() function and check if errors will apear.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /var/customers/webs/Ihnken/lib/Zend/Db/Statement/Pdo.php on line 291
Well it's (just like @bksi said) memory overflow problem. You should select only attributes you want to modify and try to do it in smaller chunks. If I'm right that you use Zend Framework I'm sure that this information can be found somewhere in it's documentation.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.