Page 1 of 1

Exception when having text box value field in admin

Posted: Thu Aug 29, 2019 5:45 pm
by fredJ
OpenCart 3

There will be an exception when trying to save a product that has a value field that is a textbox.
Sorry if I can't explain it, my store is in Swedish. I mean this:
Image

So what I did was to add this hack in admin/model/catalog/product.php
line 194

Code: Select all

				try {
					$this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_option_id = '" . (int)$product_option['product_option_id'] . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', value = '" . $this->db->escape($product_option['value']) . "', required = '" . (int)$product_option['required'] . "'");
				}
				catch (Exception $e) {
					$this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_option_id = '" . (int)$product_option['product_option_id'] . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id']  . "', required = '" . (int)$product_option['required'] . "'");
				}
Because the problem is that "value" can't be saved when we have a textbox, so if we get an exception, we try again without the value.

Maybe it helps someone.

Re: Exception when having text box value field in admin

Posted: Fri Aug 30, 2019 1:00 am
by developer@avi
Can you share admin details so I can help you to solve this