這裏是一個超負荷的prestashop 1.4添加一個字段的示例:
添加字段到數據庫:
ALTER TABLE `ps_customer` ADD `amazonresellerid` VARCHAR(12) NOT NULL AFTER `date_upd`
創建Customer.php IN /覆寫/班/並把這個代碼:
<?php
class Customer extends CustomerCore
{
public $amazonresellerid;
protected $fieldsValidate = array(
'secure_key' => 'isMd5',
'lastname' => 'isName',
'firstname' => 'isName',
'email' => 'isEmail',
'passwd' => 'isPasswd',
'id_gender' => 'isUnsignedId',
'birthday' => 'isBirthDate',
'newsletter' => 'isBool',
'optin' => 'isBool',
'active' => 'isBool',
'note' => 'isCleanHtml',
'is_guest' => 'isBool',
'amazonresellerid' => 'isString'
);
public function getFields()
{
$fields = parent::getFields();
$fields['amazonresellerid'] = pSQL($this->amazonresellerid);
return $fields;
}
}
?>
而且在authentication.tpl添加輸入:
<p class="text">
<label for="amazonresellerid">{l s='Amazon reseller id'}</label>
<input type="text" class="text" name="amazonresellerid" id="amazonresellerid" value="{if isset($smarty.post.amazonresellerid)}{$smarty.post.amazonresellerid}{/if}" />
</p>