Ajax On/Off for product tosell and tobuy

you can use this :

$object = new GenericObject($db);
if ($action == 'setStatusBuy')
  $object->setValueFrom('tobuy', $value, 'product', $id);
else if ($action == 'setStatusSell')
  $object->setValueFrom('tosell', $value, 'product', $id);

and use :

$.get( "'.DOL_URL_ROOT.'/core/ajax/productonoff.php", {
 action: \'$code\',
 value: 1,   // 1 for set and 0 for del
 id: \''.$id.'\',
 entity: \''.$entity.'\'
 },