0

我已经为制造商覆盖了代码,以便在控制器和类中拥有额外的字段,还创建了数据库列,并且所有信息都被毫无问题地存储,当我试图将信息拉回来时,问题就出现了。我添加了 4 个变量,但我只能从中提取 2 个 /** @var string Region */ public $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

您可以看到网站和魁北克存在,但没有多语言元素,有人知道为什么会发生这种情况?

谢谢

4

1 回答 1

0

我找到了您必须在 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 存储的地方.. 所以这就是其他 2 个在那里的原因......

于 2014-04-17T14:54:39.440 回答