Jump to content

CartRule runs 10'000 times


Chill_user

Recommended Posts

Stopwatch SQL - 17911 queries

I noticed few queries is repeating but this one is repeating most times:

  1. SELECT SQL_NO_CACHE *
    FROM uhep_cart_rule_product_rule pr
    LEFT JOIN uhep_cart_rule_product_rule_value prv ON pr.id_product_rule = prv.id_product_rule
    WHERE pr.id_product_rule_group = 224

    Path: /classes/CartRule.php:606, here is the function in CartRule.php:

    public function getProductRules($id_product_rule_group)
        {
            if (!Validate::isLoadedObject($this) || $this->product_restriction == 0) {
                return array();
            }
    
            $productRules = array();
            $results = Db::getInstance()->executeS('
    		SELECT *
    		FROM ' . _DB_PREFIX_ . 'cart_rule_product_rule pr
    		LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule_product_rule_value prv ON pr.id_product_rule = prv.id_product_rule
    		WHERE pr.id_product_rule_group = ' . (int) $id_product_rule_group);
            foreach ($results as $row) {
                if (!isset($productRules[$row['id_product_rule']])) {
                    $productRules[$row['id_product_rule']] = array('type' => $row['type'], 'values' => array());
                }
                $productRules[$row['id_product_rule']]['values'][] = $row['id_item'];
            }
    
            return $productRules;
        }

    I really dont understand why this function is repeating but: IF I delete all cart rules, it runs about 3000 queries instead of 10'000-15'000 queries

Edited by Amantha Bill (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...