dongyuying1507 2015-07-29 06:30
浏览 58
已采纳

运行PHP脚本不起作用

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!

  • 写回答

1条回答 默认 最新

  • dongzhiyong8577 2015-07-29 07:36
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料