heizo wrote:So I searched and did not find any resources on this, so I will type one up.
You will need MySql Knowledge and some php knowledge
Step 1.
First thing first, add your new fields to the product table in the database - this should be the easy part.
Step 2.
Open up product.php in admin/controller/catalog, you will want to copy and paste this piece of code. inside the getForm functions, (around line 707)also you will want to add the language variables like so (around line 521)Code: Select all
if (isset($this->request->post['Table Name'])) { $this->data['Table Name'] = $this->request->post['Table Name']; } elseif (isset($product_info)) { $this->data['Table Name'] = $product_info['Table Name']; } else { $this->data['Table Name'] = ''; }
I kept my post names the same as my table names so as not to confuse myself, I would suggest doing the same.Code: Select all
$this->data['entry_table name'] = $this->language->get('entry_table name');
For every field you want, copy and paste that code.
Step 3.
Open up the product_form.tpl file locate admin/view/template/catalog/.
This is pretty easy, just find a spot in the table and plug in your form fields. Look for the tab makers to tell what page you are adding to.This would be the data tab, you can figure out the names of the other ones.Code: Select all
<div id="tab-data">
I will give a couple of examples, here is a drop down
And here is just a regular input box:Code: Select all
<tr> <td><?php echo $entry_Table Name; ?></td> <td><select name="Table Name"> <?php foreach ($Table Names as $Table Name) { ?> // This is just looping over an array I built in the previouse page (step 2) and now loops here <?php if ($Table Name['Table Name_id'] == $Table Name) { ?> <option value="<?php echo $Table Name['Table Name_id']; ?>" selected="selected"><?php echo $Table Name['name']; ?></option> <?php } else { ?> <option value="<?php echo $Table Name['Table Name_id']; ?>"><?php echo $Table Name['name']; ?></option> <?php } ?> <?php } ?> </select></td> </tr>
Step 4.Code: Select all
<tr> <td><?php echo $entry_Table name; ?></td> <td><input type="text" name="Table name" value="<?php echo $Table name; ?>" /></td> </td> </tr>
Now open up the product.php in admin/language/english/catalog/
Add an entry
Step 5.Code: Select all
$_['entry_Table Name'] = 'Descripton of field:';
Here is the tricky part, you will have to edit 2 queries in admin/model/catalog/product.php.
You want to edit in 2 places:
Code: Select all
public function addProduct($data) { $this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', artist = '" . $this->db->escape($data['artist']) . "', bioLink = '" . $this->db->escape($data['bioLink']) . "', relatedCategory = '" . $this->db->escape($data['relatedCategory']) . "', upc = '" . $this->db->escape($data['upc']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW()");
and here:
Code: Select all
public function editProduct($product_id, $data) { $this->db->query("UPDATE " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', sku = '" . $this->db->escape($data['sku']) . "', artist = '" . $this->db->escape($data['artist']) . "', bioLink = '" . $this->db->escape($data['bioLink']) . "', relatedCategory = '" . $this->db->escape($data['relatedCategory']) . "', upc = '" . $this->db->escape($data['upc']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'");
Now that the admin side is done, we have to get this information on the other side... the user side.
Step 1.
Open up product.php in catalog/controller/product.
Add your language lines like so (around line 139)
Next add in your variable names containing the data (line 186ish)Code: Select all
$this->data['entry_table name'] = $this->language->get('entry_table name');
Step 2.Code: Select all
$this->data['table name'] = $product_info['table name'];
Open Up product.php in catalog/language/english/product/
Add your new names
Code: Select all
$_['text_table name'] = 'table name';
Step 3.
Open product.php in catalog/model/catalog/
Update the getProduct function, the mysql statement on line 14. Your prefix for your table names will be p.table name
Then add your entries to the array on line 18
Step 4.Code: Select all
'table name' => $query->row['table name'],
Add your fields to the product page in your template.
Finished
Cheers
I have no idea why this is not in the default opencart. This is like a must have stuff for a store.
This kicks ass, thanks!!!!!!!!!!!!!!!!!!!!!!!!!
I also figured out how to make your new property a ckeditor wysiwyg editor field
in product_form.tpl
CKEDITOR.replace('THE ID OF YOUR CUSTOM FIELD', {
filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
});
I also figured out how to make your new property a ckeditor wysiwyg editor field
in product_form.tpl
CKEDITOR.replace('THE ID OF YOUR CUSTOM FIELD', {
filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
});
Hello,
I have tried tutorial but no luck in OC 1.5.6. Looking for help to fix it because its urgent. I have modified everything like in tutorial but not showing up custom field.
That's only error in log. Looking really help with this. Appreciated!
Regards,
Kaur
I have tried tutorial but no luck in OC 1.5.6. Looking for help to fix it because its urgent. I have modified everything like in tutorial but not showing up custom field.
Code: Select all
PHP Notice: Undefined index: warranty in /www/apache/domains/www.digitaltrade.eu/htdocs/vqmod/vqcache/vq2-catalog_controller_product_product.php on line 277
Regards,
Kaur
GoGoNano is passionate about creating eco-friendly bio cleaners and waterproofing sprays that people feel safe to use within their home and around their family.
https://www.gogonano.com
Code: Select all
$this->data['warranty'] = $product_info['warranty'];
Regards,
Kaur
GoGoNano is passionate about creating eco-friendly bio cleaners and waterproofing sprays that people feel safe to use within their home and around their family.
https://www.gogonano.com
Yeah, tough to say without seeing your database and model files. The mistake is likely somewhere in there.
Make sure the database fields exist and make sure the model file contains the line:
'warranty' => $query->row['warranty'],
in the proper place.
If it's still not working pm me and I can try to help.
Make sure the database fields exist and make sure the model file contains the line:
'warranty' => $query->row['warranty'],
in the proper place.
If it's still not working pm me and I can try to help.
Hello friend,
Please give me a favour,,
I want to enter an certificate image field in product table . How can i achieved it in opencart
Please give me a favour,,
I want to enter an certificate image field in product table . How can i achieved it in opencart
I have add the custom field in opencart product table,,,,,,,,,,, but when i m going to edit a product in edit form then custom field shows nothing,,,,,,how could i show value in edit form,,,,,,,,,,,, the value are present in database but it does not show in edit form
please gve me the solution if u no.....
thanks in advance for ur help
please gve me the solution if u no.....
thanks in advance for ur help
I'm need to add new custom field using a drop down menu:
You example is clear but of course menu is white, how to add options? (something like, IT,EN,DE,JP etc)
Code: Select all
<tr>
<td><?php echo $entry_Table Name; ?></td>
<td><select name="Table Name">
<?php foreach ($Table Names as $Table Name) { ?> // This is just looping over an array I built in the previouse page (step 2) and now loops here
<?php if ($Table Name['Table Name_id'] == $Table Name) { ?>
<option value="<?php echo $Table Name['Table Name_id']; ?>" selected="selected"><?php echo $Table Name['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $Table Name['Table Name_id']; ?>"><?php echo $Table Name['name']; ?></option>
<?php } ?>
<?php } ?>
</select></td>
</tr>
You example is clear but of course menu is white, how to add options? (something like, IT,EN,DE,JP etc)
Thax fot the tutorial. I think it works on 1.5.6 version. But im getting eror:
"Notice: Undefined variable: text_position in .../catalog/view/theme/..."
My field called "position" could enibody please help me understand where did i lost this variable.
"Notice: Undefined variable: text_position in .../catalog/view/theme/..."
My field called "position" could enibody please help me understand where did i lost this variable.
i uploaded the files as per the instruction.
problem : admin - product - "size field" when i add values it does not save.
what am i doing wrong?
yes i did add the value in the database
problem : admin - product - "size field" when i add values it does not save.
what am i doing wrong?
yes i did add the value in the database
Who is online
Users browsing this forum: No registered users and 8 guests