如何在prestashop中显示订单历史记录中的产品图像
问题描述:
当用户单击订单详细信息链接时,需要在订单详细信息页面中显示产品图像。如何在prestashop中显示订单历史记录中的产品图像
我已编辑下面的代码,以便-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>
答
如果该页面可以查看变量会发生什么用$产品。喜欢这个。
{$product|var_dump}
,你会发现,$产品有一个数组值图像这是一个对象
所以现在这个去。
{$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.
答
我想这样做在PS 1.3版,我有问题太多:/当我展示{$ product.image |的var_dump}变量,我得到空
函数getImageLink($ product.link_rewrite,$ product.id_image,'small_default')工作良好,但问题是从变量$ product.link_rewrite和$ product.id_image获取值,但不幸的是我不知道如何去做。
现在他们是空的等等链接图像是不正确的
谢谢:@arifur rahman – Kennedy