Index: branches/5.2.x/units/shipping_quote_engines/shipping_quote_engine.php =================================================================== --- branches/5.2.x/units/shipping_quote_engines/shipping_quote_engine.php +++ branches/5.2.x/units/shipping_quote_engines/shipping_quote_engine.php @@ -187,23 +187,40 @@ /** * Loads properties of shipping quote engine * + * @return void */ - function initProperties() + protected function initProperties() { - $sql = 'SELECT Properties, FlatSurcharge, PercentSurcharge - FROM ' . $this->Application->getUnitOption('sqe', 'TableName') . ' - WHERE LOWER(ClassName) = ' . $this->Conn->qstr( strtolower( get_class($this) ) ); - $data = $this->Conn->GetRow($sql); - - if (is_array($data)) { - $properties = $data['Properties'] ? unserialize($data['Properties']) : Array (); - $properties['FlatSurcharge'] = $data['FlatSurcharge']; - $properties['PercentSurcharge'] = $data['PercentSurcharge']; + $cache_key = 'shipping_quote_engines_data[%SqeSerial%]'; + $cache_value = $this->Application->getCache($cache_key); - $this->properties = $properties; + if ( $cache_value === false ) { + $this->Conn->nextQueryCachable = true; + $sql = 'SELECT Properties, FlatSurcharge, PercentSurcharge, LOWER(ClassName) AS SQEKey + FROM ' . $this->Application->getUnitOption('sqe', 'TableName') . ' + WHERE Status = ' . STATUS_ACTIVE; + $cache_value = $this->Conn->Query($sql, 'SQEKey'); + + foreach ( $cache_value as $sqe_key => $sqe_data ) { + $properties = $sqe_data['Properties'] ? unserialize($sqe_data['Properties']) : array(); + $properties['FlatSurcharge'] = $sqe_data['FlatSurcharge']; + $properties['PercentSurcharge'] = $sqe_data['PercentSurcharge']; + + $cache_value[$sqe_key]['Properties'] = $properties; + unset($cache_value[$sqe_key]['FlatSurcharge'], $cache_value[$sqe_key]['PercentSurcharge']); + } + + $this->Application->setCache($cache_key, $cache_value); + } + + $sqe_key = strtolower(get_class($this)); + + if ( array_key_exists($sqe_key, $cache_value) ) { + $this->properties = $cache_value[$sqe_key]['Properties']; } else { - $this->properties = Array (); + $this->properties = array(); } } -} \ No newline at end of file + +}