kentteague Posted August 8, 2012 Share Posted August 8, 2012 On the 'Admin->Catalog->Suppliers->Add new' form I have added an E-mail address field. And in the database in ps_suppliers I have added an email field ( VARCHAR(128) ). Everything works great except that I have had to hack the core in order to make it work. I would prefer to understand a more elegant override way to accomplish this. In the override\controllers\admin\AdminSuppliersController.php file (attached) is the addition which has the emails address field added to the form via the function renderForm(). This seems to be the best way to complete this portion of the necessary override. In the override\classes\Supplier.php file is the following. class Supplier extends SupplierCore { /* RKT2 */ public $email; public function __construct($id = null, $id_lang = null) { parent::__construct($id, $id_lang); } } The problem lies in the classes\Supplier.php file which is the following marked by the comments //RKT2 public static $definition = array( 'table' => 'supplier', 'primary' => 'id_supplier', 'multilang' => true, 'fields' => array( 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), //RKT2 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128), //RKT2 'active' => array('type' => self::TYPE_BOOL), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), // Lang fields 'description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'), '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), ), ); Is there a way to merge the 'email' array, which fits so nicely in the $defintion in the classes\Supplier.php, in the function __construct in the override\classes\Supplier.php file into the $definition variable so there is no hacking of the core? This may be more of a PHP question than a Prestashop question, but I have searched for an answer, and can't find a good example. Any suggestions appreciated. Thanks in advance AdminSuppliersController.php Link to comment Share on other sites More sharing options...
Recommended Posts