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 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi