ajnglagla Posted April 6, 2014 Share Posted April 6, 2014 (edited) I want to change a database field value by clicking in back-office product list. (0 or 1) The field which i want to change is "bigimage" (tinyint) in my ps_image database. "bigimage" inside have just "1" or "0". I know how to add column and pull data to show in product list (in AdminProductsConroller.php) but I dont know how to add a "checked button" and change a data in database. Can someone help me how to do that please? Edited April 7, 2014 by ajnglagla (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted April 6, 2014 Share Posted April 6, 2014 hello in field list definition $this->fields_list['bigimage'] = array( 'title' => $this->l('Big Image'), 'active' => 'status', 'filter_key' => 'SQL FIELD NAME', 'align' => 'text-center', 'type' => 'bool', 'class' => 'fixed-width-sm', 'orderby' => false ); change SQL FIELD NAME with name of your field you want to change 1 Link to comment Share on other sites More sharing options...
ajnglagla Posted April 6, 2014 Author Share Posted April 6, 2014 (edited) hello in field list definition $this->fields_list['bigimage'] = array( 'title' => $this->l('Big Image'), 'active' => 'status', 'filter_key' => 'SQL FIELD NAME', 'align' => 'text-center', 'type' => 'bool', 'class' => 'fixed-width-sm', 'orderby' => false ); change SQL FIELD NAME with name of your field you want to change Thanks soooo much. Its showing right. But there is a small problem. When i click on "bigmage" checked button , "status" checked button is changing to "X". I am using this SQL code. am i missing something? $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'image` bigi ON (bigi.`id_image` = i.`id_image` AND bigi.`cover` = 1 AND bigi.`id_product` = a.`id_product`)'; $this->fields_list['bigimage'] = array( 'title' => $this->l('Big Image'), 'active' => 'status', 'filter_key' => 'bigi!bigimage', 'align' => 'text-center', 'type' => 'bool', 'class' => 'fixed-width-sm', 'orderby' => false ); Screenshot: Edited April 6, 2014 by ajnglagla (see edit history) Link to comment Share on other sites More sharing options...
ajnglagla Posted April 7, 2014 Author Share Posted April 7, 2014 Seems 'active' => 'status', area is trying to change "products" status. But i want to change PS_image table "bigimage" field. is there a way to change this data? Link to comment Share on other sites More sharing options...
vekia Posted April 7, 2014 Share Posted April 7, 2014 what is "durum" ? Link to comment Share on other sites More sharing options...
ajnglagla Posted April 7, 2014 Author Share Posted April 7, 2014 what is "durum" ? Means "status" Link to comment Share on other sites More sharing options...
ajnglagla Posted April 7, 2014 Author Share Posted April 7, 2014 Pulling data is ok, but inserting / changing data is painful for my limited skills. I have tried this, (i hoped that code could work for me) but i am not sure how to say this code if (product_id = product_id AND image_cover = 1 ) you change the data. $this->fields_list['bigimage'] = array( 'title' => $this->l('Büyük Foto'), 'width' => 70, 'active' => 'isBigimage', 'filter_key' => 'bigi!bigimage', 'align' => 'center', 'type' => 'bool', 'orderby' => false ); public function postProcess() { if (isset($_GET['isBigimage'.$this->table])) { $this-> processBigimage(); } } public function processBigimage() { $image = new Image($this->id_object); if (!Validate::isLoadedObject($image)) $this->errors[] = Tools::displayError('An error occurred while updating bigimage information.'); $image->bigimage = $image->bigimage ? 0 : 1; if (!$image->update()) $this->errors[] = Tools::displayError('An error occurred while updating bigimage information.'); Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token); } But i took this error [PrestaShopException] Property Image->id_product is empty at line 837 in file classes/ObjectModel.php Link to comment Share on other sites More sharing options...
ajnglagla Posted April 8, 2014 Author Share Posted April 8, 2014 any idea? Link to comment Share on other sites More sharing options...
koshkalama Posted May 7, 2014 Share Posted May 7, 2014 I'm trying to do the same thing with the backoffice feature list. Is it possible to do that for features? Link to comment Share on other sites More sharing options...
ajnglagla Posted May 7, 2014 Author Share Posted May 7, 2014 I have tried, but no result @koshkalama 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