我想做的是显示类别图像而不是产品图像。我为有效的类别产品列表所做的就是这样。
这只适用于您查看某个类别中的所有产品,但不适用于搜索产品?
<a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}">
<img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'large_default')}" style="width:140px!important;" alt="{$product.legend|escape:'htmlall':'UTF-8'}" />
</a>
我想知道如何让它在整个网站上运行?如何让它拉出类别图像?就像上面的那样,但是对于整个网站?
最佳答案
您可以执行多个操作来创建这样的图像, 首先,您在产品页面中调用 $category 类,因此 $category 未定义。
最好的解决方案是在覆盖目录中的productController中为$category创建一个分配。
class ProductController extends ProductControllerCore
{
public function initContent()
{
parent::initContent();
$category = new Category($this->product->id_category_default);
$this->context->smarty->assign('category', $category);
}
}
关于php - 在 Prestashop 中创建产品图片链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22918068/