Skip to content

Instantly share code, notes, and snippets.

@aj-justo
Created May 31, 2011 18:35
Show Gist options
  • Save aj-justo/1001033 to your computer and use it in GitHub Desktop.
Save aj-justo/1001033 to your computer and use it in GitHub Desktop.
Zen cart: override init_db_config_read.php to allow use of MAX_DISPLAY_SEARCH_RESULTS value for search results listings
<?php
/**
* read the configuration settings from the db
*
* see {@link http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem wikitutorials} for more details.
*
* @package initSystem
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: init_db_config_read.php 2753 2005-12-31 19:17:17Z wilt $
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
$use_cache = (isset($_GET['nocache']) ? false : true ) ;
$configuration = $db->Execute('select configuration_key as cfgkey, configuration_value as cfgvalue
from ' . TABLE_CONFIGURATION, '', $use_cache, 150);
while (!$configuration->EOF) {
/**
* dynamic define based on info read from DB
*/
/* ajweb.eu modification to allow use of MAX_DISPLAY_SEARCH_RESULTS value for search results listings */
if( strstr($_SERVER['REQUEST_URI'], 'search_result') &&
strtoupper($configuration->fields['cfgkey'])=='MAX_DISPLAY_PRODUCTS_LISTING') {
$result = $db->Execute('select configuration_value from ' . TABLE_CONFIGURATION . ' WHERE configuration_key=\'MAX_DISPLAY_SEARCH_RESULTS\'');
$value = $result->fields['configuration_value'];
define('MAX_DISPLAY_PRODUCTS_LISTING',$value);
}
else {
define(strtoupper($configuration->fields['cfgkey']), $configuration->fields['cfgvalue']);
}
/* end of ajwe.eu modification */
$configuration->MoveNext();
}
$configuration = $db->Execute('select configuration_key as cfgkey, configuration_value as cfgvalue
from ' . TABLE_PRODUCT_TYPE_LAYOUT);
while (!$configuration->EOF) {
/**
* dynamic define based on info read from DB
* @ignore
*/
define(strtoupper($configuration->fields['cfgkey']), $configuration->fields['cfgvalue']);
$configuration->movenext();
}
if (file_exists(DIR_WS_CLASSES . 'db/' . DB_TYPE . '/define_queries.php')) {
/**
* Load the database dependant query defines
*/
include(DIR_WS_CLASSES . 'db/' . DB_TYPE . '/define_queries.php');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment