Jump to content

Urgent! Can not open Cart Rules


Recommended Posts

Hi,

 

I'm using PrestaShop 1.5.6.1

 

 

When trying to edit any of the existing cart rules, I can not open them - I get Internal Server Error.

I called my hosting provider and he told me that the problem occurs when performing SQL query, it simply takes too long, it seems like it waits for something, e.g.:

 

 

2014-03-18, 14:26:01 -- Time = 168, Database = gori01_pretzel, User = gori01_pretzel
2014-03-18, 14:26:01 -- Time = 139, Database = gori01_pretzel, User = gori01_pretzel
 
SELECT cr.*, crl.*, 1 as selected
  FROM ps_cart_rule cr
  LEFT JOIN ps_cart_rule_lang crl ON (cr.id_cart_rule = crl.id_cart_rule AND crl.id_lang = 1)
  WHERE cr.id_cart_rule != 193
  AND (
   cr.cart_rule_restriction = 0
   OR cr.id_cart_rule IN (
    SELECT IF(id_cart_rule_1 = 193, id_cart_rule_2, id_cart_rule_1)
    FROM ps_cart_rule_combination
    WHERE 193 = id_cart_rule_1
    OR 193 = id_cart_rule_2
   )
  )
 
 
SELECT cr.*, crl.*, 1 as selected
  FROM ps_cart_rule cr
  LEFT JOIN ps_cart_rule_lang crl ON (cr.id_cart_rule = crl.id_cart_rule AND crl.id_lang = 2)
  WHERE cr.id_cart_rule != 1381
  AND (
   cr.cart_rule_restriction = 0
   OR cr.id_cart_rule IN (
    SELECT IF(id_cart_rule_1 = 1381, id_cart_rule_2, id_cart_rule_1)
    FROM ps_cart_rule_combination
    WHERE 1381 = id_cart_rule_1
    OR 1381 = id_cart_rule_2
   )
  )
 
However, when he kills the process, the page opens successfully! also, it worked until half an hour ago and I didn't make any changes...
 
Can anybody help? Who can I turn to?
 
Cheers,
 
 
 
 

 

Link to comment
Share on other sites

Dear all,

 

I haven't found a solution to the problem described above. Can anybody point me somewhere, where I could discuss about the solution?

 

I am using Cart rules for vouchers, which I import from .csv. After the problem that occurred and is explained above, I have imported new vouchers and I can open them without any problem. the old ones can not be opened and the issue described above still exists.

 

Cheers,

Link to comment
Share on other sites

  • 4 weeks later...

if you have a lot of discounts it can happen. There is a solution wich makes a change into the sql queries to dont make mysql work too much. The solution is to create a .php file in overrides/classes called CartRule.php, paste there that code:

 

<?php

class CartRule extends CartRuleCore {

    protected function getCartRuleCombinations()
    {
        $array = array();
        $array['selected'] = Db::getInstance()->executeS('
        SELECT cr.*, crl.*, 1 as selected
        FROM '._DB_PREFIX_.'cart_rule cr
        LEFT JOIN '._DB_PREFIX_.'cart_rule_lang crl ON (cr.id_cart_rule = crl.id_cart_rule AND crl.id_lang = '.(int)Context::getContext()->language->id.')
        WHERE cr.id_cart_rule != '.(int)$this->id.'
        AND (
            cr.cart_rule_restriction = 0
            OR cr.id_cart_rule IN (
            SELECT id_cart_rule_1 AS id_cart_rule FROM '._DB_PREFIX_.'cart_rule_combination WHERE '.(int)$this->id.' = id_cart_rule_2
            UNION
            SELECT id_cart_rule_2 AS id_cart_rule FROM '._DB_PREFIX_.'cart_rule_combination WHERE '.(int)$this->id.' = id_cart_rule_1
            )
        )');
        $array['unselected'] = Db::getInstance()->executeS('
        SELECT cr.*, crl.*, 1 as selected
        FROM '._DB_PREFIX_.'cart_rule cr
        LEFT JOIN '._DB_PREFIX_.'cart_rule_lang crl ON (cr.id_cart_rule = crl.id_cart_rule AND crl.id_lang = '.(int)Context::getContext()->language->id.')
        WHERE cr.cart_rule_restriction = 1
        AND cr.id_cart_rule != '.(int)$this->id.'
        AND cr.id_cart_rule NOT IN (
            SELECT id_cart_rule_1 AS id_cart_rule FROM '._DB_PREFIX_.'cart_rule_combination WHERE '.(int)$this->id.' = id_cart_rule_2
            UNION
            SELECT id_cart_rule_2 AS id_cart_rule FROM '._DB_PREFIX_.'cart_rule_combination WHERE '.(int)$this->id.' = id_cart_rule_1
        )');
        return $array;

    }

}

 

after doing that, you need to delete the file /cache/class_index.php to refresh the list of overrides

Manel

 

www.Hostienda.com

Edited by manel10_12 (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...