Advertisement:

Author Topic: expired ads in admin panel  (Read 7618 times)

tabuausada

  • Jr. Member
  • **
  • Posts: 77
Re: expired ads in admin panel
« Reply #15 on: April 17, 2014, 10:41:00 pm »
Hi serjuc11111,

i'm not 100% sure that is working, but you can try this

add this code at the end of function.php in your theme folder (just before the closing php ?> )

Code: [Select]
if( !function_exists('Mark_Expired_Item_cron')) {
function Mark_Expired_Item_cron()
{
$todayDate = date('Y-m-j');
$conn = getConnection();
$conn->osc_dbExec("UPDATE %st_item SET b_active = 0 WHERE dt_expiration < '$todayDate' && b_premium = 0", DB_TABLE_PREFIX); 
}
osc_add_hook('cron_daily', 'Mark_Expired_Item_cron');
}

this should mark the expired ads as inactive (if is not premium), then you can filter from admin panel.

For me is working, but i have made the changes in a plugin, not in function.php but should work the same.

I don't have any programming skills, but i manage (trying, making mistake and trying again) to do what i need.

I hope this will help

Anyone tried to automatically set expired ads to inactive using this solution? I've included this function in bender theme functions.php but is not producing any results... Alternative solutions are very welcome please!
« Last Edit: April 17, 2014, 10:42:53 pm by tabuausada »

jedemonte

  • Newbie
  • *
  • Posts: 2
Re: expired ads in admin panel
« Reply #16 on: August 02, 2014, 07:00:17 pm »
Hi
I have tried this idea but no working
change fonction.php in /oc-content/themes/bender_black


digitalsense

  • Jr. Member
  • **
  • Posts: 94
  • Hello there!
Re: expired ads in admin panel
« Reply #17 on: July 02, 2018, 10:50:51 am »
I have made this function I have checked and it worked fine


function make_item_inactive_expired()
{
$todayDate = date('Y-m-j');
   
  Item::newInstance()->dao->query(sprintf("UPDATE %st_item SET b_active = 0 WHERE dt_expiration < '$todayDate' && b_premium = 0", DB_TABLE_PREFIX)); 

}

osc_add_hook('cron_daily', 'make_item_inactive_expired'); //to run it daily
osc_add_hook('cron_hourly', 'make_item_inactive_expired'); //to run it hourly