选项值在OpenCart 1.5.3.1中自动删除

时间:2012-12-17 09:36:15

标签: .net mysql c#-4.0 opencart

我已经为网站解析创建了一个抓取工具。它从网站获取信息并将其存储在OpenCart数据库中。会发生什么是我无法在opencart中的产品描述页面中查看某些选项。但在管理面板中,我编辑并保存这些选项而不更改任何内容。然后我可以在产品描述页面中查看这些选项。

还有另一个问题。在执行上述步骤后,某些选项值会随机从数据库中删除,并且无法在与该选项关联的产品说明页面中查看选项值。

我正在使用OpenCart版本1.5.3.1 我在C#.NET 4.0中创建了这个解析器,后端数据库是MYSQL。

这是一个错误吗?

我在这里发布了一张图片。

http://s11.postimage.org/lab58b4ip/Option_Value_Bug.jpg

2 个答案:

答案 0 :(得分:1)

如果您没有任何库存商品,则选项可能看起来不存在。我认为这是故意隐藏不可用的选项。检查您是否在产品编辑器的“选项”选项卡中为每个选项设置了库存值

答案 1 :(得分:1)

这会奏效。由OC人员确定.. :)

https://github.com/opencart/opencart/commit/7ba1837c93645994063a6df67638924d86b0c672

或者您也可以编辑: “上传/管理/模型/目录/ 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'] . "'");