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!
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.