Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option Values Deleting Automatically #284

Closed
smarthIgnitras opened this issue Dec 17, 2012 · 1 comment
Closed

Option Values Deleting Automatically #284

smarthIgnitras opened this issue Dec 17, 2012 · 1 comment

Comments

@smarthIgnitras
Copy link

Hello,
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.

Is this a bug?

OptionValueBug

hkulekci pushed a commit to hkulekci/opencart that referenced this issue Dec 17, 2012
@hkulekci
Copy link
Contributor

Maybe we can be like this

    if ( isset($product_option['product_option_value']) && count($product_option['product_option_value']) > 0  ){

        if ( $product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
                $this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', required = '" . (int)$product_option['required'] . "'");

                $product_option_id = $this->db->getLastId();

                if (isset($product_option['product_option_value']) && count($product_option['product_option_value']) > 0 ) {
                    foreach ($product_option['product_option_value'] as $product_option_value) {
                        $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']) . "'");
                    } 
                }
            } else { 
                $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'] . "'");
            }
        }

    }

But in this situation, older records not affected and older option values can not delete.

opencart pushed a commit that referenced this issue Dec 18, 2012
Option Values Deleting Automatically for #284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants