madowen Posted June 3, 2013 Share Posted June 3, 2013 Hi, I'm trying to create a module that adds some input fields (setted by the user when is buying an item, like the quantity field that already exists ) and output fields (setted by the admin at the admin CP at products tab), both has to be shown at the product template, and when the user changes the input fields the price has to be updated taking into account the values of the new fields. And obviously when the user press the submit button, it has to add to the cart with the new fields. For now what I have achieved, has been to change the productController to show my own product template overriding the productController.php, copying the initContent() function and changing the template setted, and calling the initContent from the FrontControllerCore, is the only way that I found to do it... <?php class ProductController extends ProductControllerCore { public function initContent(){ // parent::initContent(); FrontControllerCore::initContent(); if (!$this->errors) {...} $this->context->smarty->assign('errors', $this->errors); $this->setTemplate(_PS_MODULE_DIR_.'mymodule/product.tpl'); } } Now I guess that I have to: Add the new fields to my product Add them to the admin form to be modified Add the input fields to the user template Modify the submit action from the button I need help with this points. I've been looking for some days trying to learn how exactly add the new fields, but everything is a little confusing... I create an override product class, just trying to add a single field, but when I load a product page there's appear some senseless warnings... <?php class Product extends ProductCore { public $delivery; public function __construct($id_product = null){ self::$definition['fields']['delivery'] = array('type' => ObjectModel::TYPE_STRING,'validate' => 'isString'); parent::__construct($id_product); } } http://img33.imagesh...8/dibujohzc.jpg Do I have to add to the sql product table a new attribute for this field, or its just added automatically? I hope that someone can help me... Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now