Viktor
May 10, 2012, 12:11 PM
Hello All,
After run cron jobs exist some problem with count listings on categories it may be (-1) or other you may solve it from admin panel >> Controls and click recount button. But if you have many listings and you see this problem sometimes you may apply fix for cron job file.
Please go to ftp>>cron open file index.php
after this code:
/* prefere email templates */
at line ~48
add:
$reefless -> loadClass('Actions');
then after:
$rlMail -> send( $admin_email, $config['notifications_email'] );
}
unset($listings, $update, $account_info, $update_link, $details_link);
}
at line ~214
add this code:
/* get all categories */
$rlDb -> setTable('categories');
$categories = $rlDb -> fetch( array('ID', 'Parent_ID'), array('Status' => 'active'), "ORDER BY `Parent_ID`" );
$rlDb -> resetTable();
foreach ($categories as $key => $value)
{
$sql = "SELECT COUNT(`T1`.`ID`) AS `Count` FROM `" . RL_DBPREFIX . "listings` AS `T1` ";
$sql .= "LEFT JOIN `" . RL_DBPREFIX . "listing_plans` AS `T2` ON `T1`.`Plan_ID` = `T2`.`ID` ";
$sql .= "WHERE (`T1`.`Category_ID` = '{$categories[$key]['ID']}' OR FIND_IN_SET('{$categories[$key]['ID']}', `Crossed`) > 0) AND `T1`.`Status` = 'active' ";
$sql .= "AND (UNIX_TIMESTAMP(DATE_ADD(`T1`.`Pay_date`, INTERVAL `T2`.`Listing_period` DAY)) > UNIX_TIMESTAMP(NOW()) OR `T2`.`Listing_period` = 0) ";
$cat_listings = $rlDb -> getRow( $sql );
$update = array(
'fields' => array(
'Count' => $cat_listings['Count']
),
'where' => array(
'ID' => $categories[$key]['ID']
)
);
$GLOBALS['rlActions'] -> updateOne($update, 'categories');
if ( $categories[$key]['Parent_ID'] > 0 )
{
recountListings($categories[$key]['Parent_ID'], $cat_listings['Count']);
}
}
$rlCache -> updateCategories();
$rlCache -> updateListingStatistics();
/**
* recount listings number for parent category | recursive method
*
* @param int $parent_id - parent category ID
* @param int $current_count - current category listing number
*
**/
function recountListings( $parent_id, $current_number )
{
global $rlDb;
$update = "UPDATE `" . RL_DBPREFIX . "categories` SET `Count` = `Count` + '{$current_number}' WHERE `ID` = '{$parent_id}'";
$rlDb -> query($update);
$category = $rlDb -> fetch(array('ID', 'Parent_ID'), array('ID' => $parent_id, 'Status' => 'active'), null, 1, 'categories', 'row');
if ( $category['Parent_ID'] > 0 )
{
recountListings( $category['Parent_ID'], $current_number );
}
}
and save this file.
If you want you may run your cron job file manually: http://site_name.com/cron/index.php but at first you should rename .htaccess file.
After run cron jobs exist some problem with count listings on categories it may be (-1) or other you may solve it from admin panel >> Controls and click recount button. But if you have many listings and you see this problem sometimes you may apply fix for cron job file.
Please go to ftp>>cron open file index.php
after this code:
/* prefere email templates */
at line ~48
add:
$reefless -> loadClass('Actions');
then after:
$rlMail -> send( $admin_email, $config['notifications_email'] );
}
unset($listings, $update, $account_info, $update_link, $details_link);
}
at line ~214
add this code:
/* get all categories */
$rlDb -> setTable('categories');
$categories = $rlDb -> fetch( array('ID', 'Parent_ID'), array('Status' => 'active'), "ORDER BY `Parent_ID`" );
$rlDb -> resetTable();
foreach ($categories as $key => $value)
{
$sql = "SELECT COUNT(`T1`.`ID`) AS `Count` FROM `" . RL_DBPREFIX . "listings` AS `T1` ";
$sql .= "LEFT JOIN `" . RL_DBPREFIX . "listing_plans` AS `T2` ON `T1`.`Plan_ID` = `T2`.`ID` ";
$sql .= "WHERE (`T1`.`Category_ID` = '{$categories[$key]['ID']}' OR FIND_IN_SET('{$categories[$key]['ID']}', `Crossed`) > 0) AND `T1`.`Status` = 'active' ";
$sql .= "AND (UNIX_TIMESTAMP(DATE_ADD(`T1`.`Pay_date`, INTERVAL `T2`.`Listing_period` DAY)) > UNIX_TIMESTAMP(NOW()) OR `T2`.`Listing_period` = 0) ";
$cat_listings = $rlDb -> getRow( $sql );
$update = array(
'fields' => array(
'Count' => $cat_listings['Count']
),
'where' => array(
'ID' => $categories[$key]['ID']
)
);
$GLOBALS['rlActions'] -> updateOne($update, 'categories');
if ( $categories[$key]['Parent_ID'] > 0 )
{
recountListings($categories[$key]['Parent_ID'], $cat_listings['Count']);
}
}
$rlCache -> updateCategories();
$rlCache -> updateListingStatistics();
/**
* recount listings number for parent category | recursive method
*
* @param int $parent_id - parent category ID
* @param int $current_count - current category listing number
*
**/
function recountListings( $parent_id, $current_number )
{
global $rlDb;
$update = "UPDATE `" . RL_DBPREFIX . "categories` SET `Count` = `Count` + '{$current_number}' WHERE `ID` = '{$parent_id}'";
$rlDb -> query($update);
$category = $rlDb -> fetch(array('ID', 'Parent_ID'), array('ID' => $parent_id, 'Status' => 'active'), null, 1, 'categories', 'row');
if ( $category['Parent_ID'] > 0 )
{
recountListings( $category['Parent_ID'], $current_number );
}
}
and save this file.
If you want you may run your cron job file manually: http://site_name.com/cron/index.php but at first you should rename .htaccess file.