Prestashop 模型不从 lang table 加载数据
Prestashop model does not load data from lang table
我正在 prestashop 模块中制作一个简单模型,但我无法让它从 table 语言加载数据。
class Type extends ObjectModel
{
/** @var int */
public $id_type;
/** @var varchar */
public $titre;
/** @var text */
public $content;
/** @var varchar */
public $tags;
public static $definition = array(
'table' => 'type',
'primary' => 'id_type',
'fields' => array(
'titre' => array('type' => self::TYPE_STRING, 'required' => true, 'lang' => true),
'content' => array('type' => self::TYPE_STRING, 'required' => true, 'lang' => true),
'tags' => array('type' => self::TYPE_STRING, 'required' => true),
),
);
}
database :
ps_type [id_type, id_shop_group, id_shop, tags]
ps_type_lang [id_type, id_lang, titre, content]
当我像 new Type(1); 这样从数据库中加载一行时;我有标签字段,但没有标题和内容。
我错过了什么吗?
您必须添加 "multilang"
public static $definition = array(
'table' => 'type',
'primary' => 'id_type',
'multilang' => true,
'fields' => array(
'titre' => array('type' => self::TYPE_STRING, 'required' => true, 'lang' => true),
'content' => array('type' => self::TYPE_STRING, 'required' => true, 'lang' => true),
'tags' => array('type' => self::TYPE_STRING, 'required' => true),
),
);
$type = new Type(1, 2); // 2 is your language id
我正在 prestashop 模块中制作一个简单模型,但我无法让它从 table 语言加载数据。
class Type extends ObjectModel
{
/** @var int */
public $id_type;
/** @var varchar */
public $titre;
/** @var text */
public $content;
/** @var varchar */
public $tags;
public static $definition = array(
'table' => 'type',
'primary' => 'id_type',
'fields' => array(
'titre' => array('type' => self::TYPE_STRING, 'required' => true, 'lang' => true),
'content' => array('type' => self::TYPE_STRING, 'required' => true, 'lang' => true),
'tags' => array('type' => self::TYPE_STRING, 'required' => true),
),
);
}
database :
ps_type [id_type, id_shop_group, id_shop, tags]
ps_type_lang [id_type, id_lang, titre, content]
当我像 new Type(1); 这样从数据库中加载一行时;我有标签字段,但没有标题和内容。 我错过了什么吗?
您必须添加 "multilang"
public static $definition = array(
'table' => 'type',
'primary' => 'id_type',
'multilang' => true,
'fields' => array(
'titre' => array('type' => self::TYPE_STRING, 'required' => true, 'lang' => true),
'content' => array('type' => self::TYPE_STRING, 'required' => true, 'lang' => true),
'tags' => array('type' => self::TYPE_STRING, 'required' => true),
),
);
$type = new Type(1, 2); // 2 is your language id