0

使用此页面上的本教程向 Prestashop 产品的后台添加新选项卡和字段,我能够为我的 Prestashop 中的产品的作者添加一个新字段。我还可以通过将 Product.php 添加到 override/classes/ 并在下面插入此代码来在产品页面上显示它:

class Product extends ProductCore
{
/** @var string Custom Product Field */
    public $custom_field;
}

然后我将 {$product->custom_field} 添加到 product.tpl 以显示新字段。我的挑战是相同的代码在添加到 product-list.tpl 和 homefeatured.tpl 模块文件时不起作用。谁能解释如何实现这一目标?我不是专家,但如果我有教程,我可以找到自己的方法。谢谢!

4

2 回答 2

0

找到 Homefeatured 模块用于获取产品的函数并在此函数中编辑 SQL 请求以添加新字段。

您无法显示您的新属性,因为 SQL 请求没有得到它。

于 2013-11-05T15:37:56.887 回答
0

利用 。而不是->

在 product-list.tpl & homefeatured.tpl $procuct 是数组而不是对象。

并且不要错过 Product 类中的 getFields() 方法:

public function getFields()
{
    $fields = parent::getFields();
    $fields['custom_field'] = $this->custom_field;
    return $fields;
}
于 2013-11-05T16:09:58.150 回答