这将起作用。它是由 OC 人修复的.. :)
https://github.com/opencart/opencart/commit/7ba1837c93645994063a6df67638924d86b0c672
或者您也可以编辑:“upload/admin/model/catalog/product.php”
@@ -38,10 +38,12 @@ public function addProduct($data) {
38 38
39 39
$product_option_id = $this->db->getLastId();
40 40
41
- if (isset($product_option['product_option_value'])) {
41
+ if (isset($product_option['product_option_value']) && count($product_option['product_option_value']) > 0 ) {
42 42
foreach ($product_option['product_option_value'] as $product_option_value) {
43 43
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value_id = '" . (int)$product_option_value['option_value_id'] . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', price_prefix = '" . $this->db->escape($product_option_value['price_prefix']) . "', points = '" . (int)$product_option_value['points'] . "', points_prefix = '" . $this->db->escape($product_option_value['points_prefix']) . "', weight = '" . (float)$product_option_value['weight'] . "', weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'");
44 44
}
45
+ }else{
46
+ $this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_option_id = '".$product_option_id."'");
45 47
}
46 48
} else {
47 49
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value = '" . $this->db->escape($product_option['option_value']) . "', required = '" . (int)$product_option['required'] . "'");
... ...
@@ -160,10 +162,12 @@ public function editProduct($product_id, $data) {
160 162
161 163
$product_option_id = $this->db->getLastId();
162 164
163
- if (isset($product_option['product_option_value'])) {
165
+ if (isset($product_option['product_option_value']) && count($product_option['product_option_value']) > 0 ) {
164 166
foreach ($product_option['product_option_value'] as $product_option_value) {
165 167
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_value_id = '" . (int)$product_option_value['product_option_value_id'] . "', product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value_id = '" . (int)$product_option_value['option_value_id'] . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', price_prefix = '" . $this->db->escape($product_option_value['price_prefix']) . "', points = '" . (int)$product_option_value['points'] . "', points_prefix = '" . $this->db->escape($product_option_value['points_prefix']) . "', weight = '" . (float)$product_option_value['weight'] . "', weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'");
166 168
}
169
+ }else{
170
+ $this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_option_id = '".$product_option_id."'");
167 171
}
168 172
} else {
169 173
$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'] . "', option_value = '" . $this->db->escape($product_option['option_value']) . "', required = '" . (int)$product_option['required'] . "'");