dqyitt2954 2017-01-10 02:26
浏览 60
已采纳

如何从Prestashop导入跳过损坏的图像URL?

I'm importing a catalog of products into the Prestashop store, but there is a problem with the image url broken, because the product is show with a default image with interrogation sign.

My idea is to skip those url and don't use the default unknown image. Any idea for this??

This is the default image used when image url is broken

enter image description here

This is a product with some images by default because of lost images

enter image description here

  • 写回答

2条回答 默认 最新

  • douzhaiya3968 2017-01-10 19:48
    关注

    Thanks for contributing with your help. I could do that script but that solution wont be useful because I import the catalog each hour.

    I figured out a solution and it was adding some changes to the Import module, so now the module before import an url it checks file_exists() and instead of throw a new exception will do unset() for that image url so with that is enough for my solution. Thanks all.

    THis is the code:

    // Get images real path, and check exists
        foreach ($images as $key => $img) {
            /*if (preg_match('/:\/\//', $images[$key]->value)) {
                continue;
            }*/
    
            $url = $images[$key]->value;
    
            $filename = explode('=',$url)[1];
    
            $images[$key]->value = _PS_ROOT_DIR_.'/testimg/'.$filename.'.jpg';
    
            if (!file_exists($images[$key]->value))
            {
                unset($images[$key]);
                //throw new Exception("File {$images[$key]->value} not found.");
            }
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置