Jump to content

new field with function with generate like generateReference


NeedZoom

Recommended Posts

i have add

ALTER TABLE `ps_customer` ADD `code` VARCHAR(9) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ;

and in customer.php:

in public static $definition:

'code' =>  array('type' => self::TYPE_STRING),

and

public static function generateCode()
    {
        
		$last_id = Db::getInstance()->getValue('
        SELECT MAX(code)
        FROM '._DB_PREFIX_.'customer');
    return str_pad((int)$last_id + 1, 8, 'CW0000000', STR_PAD_LEFT); 
    }
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...