当用户点击订单详情链接时,我需要在订单详情页面中显示产品图片。
我在order-detail.tpl中编辑了以下代码,但它没有显示产品图片,只显示了一些虚拟图像
<td>
<a href="{$link->getProductLink($product.product_id, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|escape:'htmlall':'UTF-8'}">
<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small_default')}" alt="{$product.name|escape:'htmlall':'UTF-8'}" {if isset($smallSize)}width="{$smallSize.width}" height="{$smallSize.height}" {/if} /></a>
</td>
答案 0 :(得分:1)
我想在PS 1.3版本中这样做,我也有问题:/当我显示{$ product.image | var_dump}变量时我得到NULL
函数getImageLink($ product.link_rewrite,$ product.id_image,'small_default')运行良好,但问题是从变量$ product.link_rewrite和$ product.id_image获取值,但遗憾的是我不知道如何
现在它们是空的,因此链接到图像是不正确的
答案 1 :(得分:0)
如果该页面可以查看$ product附带的变量。像这样。
{$product|var_dump}
你会注意到$ product有一个数组值图像,它是一个对象
所以现在就去吧。
{$product.image|var_dump}
您将查看所有这些值。
object(Image)#490 (26) { ["id"]=> int(1) ["id_image"]=> string(1) "1" ["id_product"]=> string(1) "3" ["position"]=> string(1) "1" ["cover"]=> string(1) "1" ["image_format"]=> string(3) "jpg" ["source_index"]=> string(52) "/Applications/MAMP/htdocs/prestashop/img/p/index.php" ["folder":protected]=> NULL ["existing_path":protected]=> NULL ["id_lang":protected]=> NULL ["id_shop":protected]=> int(1) ["id_shop_list"]=> NULL ["get_shop_from_context":protected]=> bool(true) ["table":protected]=> string(5) "image" ["identifier":protected]=> string(8) "id_image" ["fieldsRequired":protected]=> array(1) { [0]=> string(10) "id_product" } ["fieldsSize":protected]=> array(0) { } ["fieldsValidate":protected]=> array(3) { ["id_product"]=> string(12) "isUnsignedId" ["position"]=> string(13) "isUnsignedInt" ["cover"]=> string(6) "isBool" } ["fieldsRequiredLang":protected]=> array(0) { } ["fieldsSizeLang":protected]=> array(0) { } ["fieldsValidateLang":protected]=> array(0) { } ["tables":protected]=> array(0) { } ["webserviceParameters":protected]=> array(0) { } ["image_dir":protected]=> string(43) "/Applications/MAMP/htdocs/prestashop/img/p/" ["def":protected]=> array(6) { ["table"]=> string(5) "image" ["primary"]=> string(8) "id_image" ["multilang"]=> bool(true) ["fields"]=> array(3) { ["id_product"]=> array(3) { ["type"]=> int(1) ["validate"]=> string(12) "isUnsignedId" ["required"]=> bool(true) } ["position"]=> array(2) { ["type"]=> int(1) ["validate"]=> string(13) "isUnsignedInt" } ["cover"]=> array(3) { ["type"]=> int(2) ["validate"]=> string(6) "isBool" ["shop"]=> bool(true) } } ["classname"]=> string(5) "Image" ["associations"]=> array(1) { ["l"]=> array(3) { ["type"]=> int(2) ["field"]=> string(8) "id_image" ["foreign_field"]=> string(8) "id_image" } } } ["update_fields":protected]=> NULL }
You will notice that there is not value of link_rewrite. So you need to pass that from the controller.