我是PS的新手,我需要一些帮助。 我正在关注:Prestashop 1.6 - Add custom field to category和http://nemops.com/extending-prestashop-objects/#.WejLOhNSyRs,以便能够向管理类别添加新的自定义字段。
我设法: - 将新字段添加到类别UI - 将新值添加到DB - 该字段使用DB(手动输入)
中的值填充但: - 我无法从UI插入/更新值(我的自定义字段称为:altname)
我可以看到POST正在将值发送回 AdminCategoriesControllerCore->后处理()
Array ( [id_category] => 154 [name_1] => laci_uj_nev [name_2] => laci_uj_nev22
[altname_1] => Nove alternative meno [altname_2] => Nove alternative meno22
但它接缝这个值永远不会到达应该将其插入数据库的模型。 有人能告诉我/指出正确的方向: - 如何将新值发送到将值插入DB的模型 - 什么是PS中的信息流,哪些函数被调用以进行更新和插入?
更新 我已经确定在AdminController.php文件中有一个postProcess()方法,它有像actionAdminSaveBefore这样的钩子:
Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
但是这样的钩子不存在,我检查了所有模块,类,控制器文件,DB中的钩子表,所有可用的钩子都通过免费模块调用:hooksmanager但什么都没找到。有人能指出我正确的方向找到这个钩子的代码,我可以检查它的作用吗?
谢谢!
答案 0 :(得分:0)
解决方案
public $altname;
public static $definition = array(
'table' => 'category',
'primary' => 'id_category',
'multilang' => true,
'multilang_shop' => true,
'fields' => array(
'nleft' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'nright' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'level_depth' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_shop_default' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'is_root_category' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'position' => array('type' => self::TYPE_INT),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
// Lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
'altname' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
'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', 'size' => 255),
),
);
}