Jump to content

How to remove SQL_NO_CACHE from ConfigurationCore


Przemysław Suszek

Recommended Posts

Hi,

 

I want to optimize my shop. How can I remove SQL_NO_CACHE from query:

SELECT SQL_NO_CACHE c.`name`, cl.`id_lang`, IF(cl.`id_lang` IS NULL, c.`value`, cl.`value`) AS value, c.id_shop_group, c.id_shop
FROM `ps_configuration` c
LEFT JOIN `ps_configuration_lang` cl ON (c.`id_configuration` = cl.`id_configuration`)

/classes/Configuration.php

/**
     * Load all configuration data
     */
    public static function loadConfiguration()
    {
        self::$_cache[self::$definition['table']] = array();

        $sql = 'SELECT c.`name`, cl.`id_lang`, IF(cl.`id_lang` IS NULL, c.`value`, cl.`value`) AS value, c.id_shop_group, c.id_shop
                FROM `'._DB_PREFIX_.bqSQL(self::$definition['table']).'` c
                LEFT JOIN `'._DB_PREFIX_.bqSQL(self::$definition['table']).'_lang` cl ON (c.`'.bqSQL(self::$definition['primary']).'` = cl.`'.bqSQL(self::$definition['primary']).'`)';
        $db = Db::getInstance();
        $result = $db->executeS($sql, false);
        while ($row = $db->nextRow($result)) {
            $lang = ($row['id_lang']) ? $row['id_lang'] : 0;
            self::$types[$row['name']] = ($lang) ? 'lang' : 'normal';
            if (!isset(self::$_cache[self::$definition['table']][$lang])) {
                self::$_cache[self::$definition['table']][$lang] = array(
                    'global' => array(),
                    'group' => array(),
                    'shop' => array(),
                );
            }

            if ($row['id_shop']) {
                self::$_cache[self::$definition['table']][$lang]['shop'][$row['id_shop']][$row['name']] = $row['value'];
            } elseif ($row['id_shop_group']) {
                self::$_cache[self::$definition['table']][$lang]['group'][$row['id_shop_group']][$row['name']] = $row['value'];
            } else {
                self::$_cache[self::$definition['table']][$lang]['global'][$row['name']] = $row['value'];
            }
        }
    }
Link to comment
Share on other sites

  • 1 year later...

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