Reputation:
I've created a crawler for website parsing. It gets the information from website and store it in OpenCart Database. What happens is that i can't view some options in product description page in opencart. But in admin panel when i edit and save those options without changing anything. Then i can view those options in product description page.
There is also another problem. Some option values randomly gets deleted from the database after i do the steps stated above and can't view the option values in the product description page associated with the option.
I'm using OpenCart Version 1.5.3.1.
And i've created this parser in C#.NET 4.0 and backend database is MYSQL.
Is this a bug?
I've posted an image here.
http://s11.postimage.org/lab58b4ip/Option_Value_Bug.jpg
Upvotes: 0
Views: 577
Reputation: 694
This will work. It is fixed by the OC people..:)
https://github.com/opencart/opencart/commit/7ba1837c93645994063a6df67638924d86b0c672
Or alternatively you can edit this: "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'] . "'");
Upvotes: 1
Reputation: 15151
Options can appear to not be there if you don't have any items in stock for them. I believe this was intentional to hide options that weren't available. Check that you have set the stock values for each option in your product editor's "Options" tab
Upvotes: 1