If there are many customers (>10k) admin/store_credit.php starts to run sloooowly and it eats up a lot of resources. To address that, change admin/store_credit.php:
PHP Code:
function store_pending_rewards() {
global $db;
$customers = $db->Execute("SELECT customers_id FROM " . TABLE_CUSTOMERS . " ORDER BY customers_id ASC");
while (!$customers->EOF) {
$customers_id = $customers->fields['customers_id'];
$pending_rewards = $this->get_pending_rewards($customers_id);
if($pending_rewards == 0.0) { $customers->MoveNext(); continue; }
$db->Execute("UPDATE " . TABLE_STORE_CREDIT . "
SET pending = " . $pending_rewards . "
WHERE customers_id = " . $customers_id . "
LIMIT 1");
$customers->MoveNext();
}
}
to
PHP Code:
function store_pending_rewards() {
global $db;
$customers = $db->Execute("SELECT DISTINCT customers_id FROM " . TABLE_SC_REWARD_POINT_LOGS . " ORDER BY customers_id ASC");
while (!$customers->EOF) {
$customers_id = $customers->fields['customers_id'];
$pending_rewards = $this->get_pending_rewards($customers_id);
if($pending_rewards == 0.0) { $customers->MoveNext(); continue; }
$db->Execute("UPDATE " . TABLE_STORE_CREDIT . "
SET pending = " . $pending_rewards . "
WHERE customers_id = " . $customers_id . "
LIMIT 1");
$customers->MoveNext();
}
}
Bookmarks