0

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

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

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

这是一个错误吗?

我在这里张贴了一张图片。

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

4

2 回答 2

1

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

于 2012-12-17T19:06:53.983 回答
1

这将起作用。它是由 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'] . "'");
于 2012-12-18T05:51:53.707 回答