从prestashop 1.6中的数据库中获取变量


get variable from database in prestashop 1.6

我为制造商重写了代码,使其在控制器和类中具有额外的字段,还创建了数据库列,所有信息都被存储,没有任何问题,当我试图取回信息时,问题就出现了。我添加了4个变量,但我只能从其中的2个变量中提取/**@var字符串区域*/公开$laregion;

/** @var string address */
public $ladireccion;
/** @var string website */
public $website;
/** @var string Is from quebec? */
public $quebec;

我在那里定义了变量,并将数组设置如下:

    public static $definition = array(
    'table' => 'manufacturer',
    'primary' => 'id_manufacturer',
    'multilang' => true,
    'fields' => array(
    'name' => array('type' => self::TYPE_STRING, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64),
        'website' =>            array('type' => self::TYPE_STRING, 'validate' => 'isUrl', 'required' => true, 'size' => 64),
        'quebec' =>             array('type' => self::TYPE_BOOL),
        'active' =>             array('type' => self::TYPE_BOOL),
        'date_add' =>           array('type' => self::TYPE_DATE),
        'date_upd' =>           array('type' => self::TYPE_DATE),
        // Lang fields
        'laregion' =>           array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 255),
        'ladireccion' =>        array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 255),
        'description' =>        array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
        'short_description' =>  array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
        'meta_title' =>         array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
        'meta_description' =>   array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
        'meta_keywords' =>      array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'),
    ),
);

但当我想从laregion或ladireccion获得信息时,我得到的东西甚至都不在调试中,但其他2个都在。。

    >value = Array (1)
0 => Array (12)
id_manufacturer => "5"
name => "test test"
date_add => "2014-04-16 15:20:04"
date_upd => "2014-04-16 16:19:36"
active => "1"
website => "website.com"
quebec => "0"
description => "<p>test french</p>"
short_description => "<p>test french</p>"
nb_products => "0"
link_rewrite => 0
image => "fr-default"
->nocache = false

你可以看到网站和魁北克有,但没有多种语言的元素,有些人有一个想法,为什么会发生这种情况?

感谢

我找到了必须在getmanufacturers 上设置变量的解决方案

public static function getManufacturers($get_nb_products = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_group = false)
{
    if (!$id_lang)
        $id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
    if (!Group::isFeatureActive())
        $all_group = true;
    $manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
    SELECT m.*, ml.`description`, ml.`short_description`, ml.`laregion`,ml.`ladireccion`
    FROM `'._DB_PREFIX_.'manufacturer` m
    '.Shop::addSqlAssociation('manufacturer', 'm').'
    INNER JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer` AND ml.`id_lang` = '.(int)$id_lang.')
    '.($active ? 'WHERE m.`active` = 1' : '').'
    ORDER BY m.`name` ASC
    '.($p ? ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n : ''));
    if ($manufacturers === false)
        return false;
    if ($get_nb_products)
    {
        $sql_groups = '';
        if (!$all_group)
        {
            $groups = FrontController::getCurrentCustomerGroups();
            $sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
        }
        foreach ($manufacturers as $key => $manufacturer)
        {
            $manufacturers[$key]['nb_products'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
            SELECT COUNT(DISTINCT p.`id_product`)
            FROM `'._DB_PREFIX_.'product` p
            '.Shop::addSqlAssociation('product', 'p').'
            WHERE p.`id_manufacturer` = '.(int)$manufacturer['id_manufacturer'].'
            AND product_shop.`visibility` NOT IN ("none")
            '.($active ? ' AND product_shop.`active` = 1 ' : '').'
            '.($all_group ? '' : ' AND p.`id_product` IN (
                SELECT cp.`id_product`
                FROM `'._DB_PREFIX_.'category_group` cg
                LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                WHERE cg.`id_group` '.$sql_groups.'
            )'));
        }
    }
    $total_manufacturers = count($manufacturers);
    $rewrite_settings = (int)Configuration::get('PS_REWRITING_SETTINGS');
    for ($i = 0; $i < $total_manufacturers; $i++)
        $manufacturers[$i]['link_rewrite'] = ($rewrite_settings ? Tools::link_rewrite($manufacturers[$i]['name']) : 0);
    return $manufacturers;
}

你可以看到它对m上的所有内容都进行了选择。ml上的细节是存储所有Manufacturers_Lang的地方。。所以这就是为什么其他两个在那里。。。