How to skip broken Images URL from Prestashop Import?

时间:2017-01-10 02:26:37

标签: php prestashop importerror prestashop-1.6

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 个答案:

答案 0 :(得分:0)

产品的图片列在ps_image表格中。您应该执行一个脚本,删除/img/p/文件夹中不存在的表的所有图像。

你可以在backffoffice图像选项菜单中调整图像大小,但我不确定这个干净的数据库是否正确。

祝你好运。

答案 1 :(得分:0)

感谢您的帮助。我可以做那个脚本,但是这个解决方案不会有用,因为我每小时导入一次目录。

我找到了一个解决方案,它正在对Import模块添加一些更改,所以现在模块在导入url之前检查file_exists()而不是为该图像do unset()抛出新的异常url所以这对我的解决方案来说已经足够了。谢谢大家。

这是代码:

// 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.");
        }
    }