Prestashop模型不从lang表加载数据

问题描述 投票:1回答:1

我在prestashop模块中制作一个简单的模型,我不能让它从表格中加载数据。

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]

当我从数据库加载一行时,如新的Type(1);我有标记字段但不是标题和内容。我错过了什么?

model prestashop lang
1个回答
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
© www.soinside.com 2019 - 2024. All rights reserved.