我为制造商提供了覆盖代码,使控制器和类中有额外的字段,还创建了数据库列,所有信息都存储没有任何问题,当我尝试将信息拉回来时问题就出现了。我添加了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
你可以看到网站和魁北克有,但没有多语言元素,有人知道为什么会发生这种情况?
谢谢
答案 0 :(得分: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的细节。 ml是存储所有Manufacturers_Lang的那个..这就是为什么其他2个存在...