Proper way to work using the real image of a product on OpenCart 2

纵然是瞬间 提交于 2019-11-28 14:35:07

With help from members of OpenCart forum, I managed to find a functional solution (using vQmod). It is thus require to create an .xml file placed in the vqmod/xml folder and containing, for example:

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <id>Recover Real Image</id>
    <version></version>
    <vqmver></vqmver>
    <author></author>
    <email></email>
    <website></website>
    <file name="catalog/controller/product/product.php">
    <operation>
        <search position="after"><![CDATA[
            $data['points'] = $product_info['points'];
        ]]></search>
        <add><![CDATA[
            $data['picture'] = HTTP_SERVER.'/image/'.$product_info['image'];
        ]]></add>
    </operation>
    </file>
</modification>

If product image can not be found and assuming a <default.jpg> is put the root of the <image> folder, the <add> element can be replaced by:

if(empty($product_info['image'])){
    $data['picture'] = HTTP_SERVER.'image/default.jpg';
}
else{
    $data['picture'] = HTTP_SERVER.'image/'.$product_info['image'];
}

Other possible suggestions, by using:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!