如何从 Prestashop 中的 .tpl 文件中的数据库获取更多数据

How to get more datas from database in a .tpl file in Prestashop

我正在开发 prestashop 1.7。 我在 specific_price table 中添加了一个字段。 我想在 cart-detailed-product-line.tpl

中使用该字段中的数据

我应该怎么做? 我需要连接到 Cart.php class 中的 price_specific table 吗? 如果是,如何?

提前致谢!

是的,鉴于您的情况,最简单的方法是创建覆盖 Link.php,并在其中调用您的 table 以获取您的信息。

在tpl中你只需要输入{$link->nameoffunction(parametre)}

此致

非常感谢ethercreation!! 我输入 Link.php :

public static function getSpecificPriceRatioAjout($id_product_attribute)
{
    $unit_price_ratio_ajout = Db::getInstance()->executeS(
        'SELECT unit_price_ratio_ajout FROM '._DB_PREFIX_.'specific_price WHERE id_product_attribute = '.$id_product_attribute
    );
    var_dump($unit_price_ratio_ajout);
    return $unit_price_ratio_ajout;
}

在我的 .tpl 中:

{$link->getSpecificPriceRatioAjout({$product.id_product_attribute})}

响应:htmlspecialchars() 期望参数 1 为字符串,给定的数组

你知道我做错了什么吗?