News:

Support the VirtueMart project and become a member

Main Menu

[FIXED] Bug: ps_vendor_category

Started by doorknob, May 10, 2009, 19:30:23 PM

Previous topic - Next topic

doorknob

An attempt to delete a vendor category results in an error message "Error: A value for the field "vendor_category_name" is missing." which, of course, is nonsence. The reason is because the class does not contain a validate_delete() function. As a result, the vmAbstractObject class executes the standard validation code for the type of record. A simple solution is to add a validate_delete() function that checks whether any vendors are linked to the record before allowing deletion. I added the following (note, I don't bother with language files):
/**
* Validate record before allowing deletion
*/
function validate_delete( &$d ) {
$db = new ps_DB() ;

$q = 'SELECT COUNT(*) AS num_rows FROM #__{vm}_vendor WHERE vendor_category_id='.(int)$d['vendor_category_id'];
$db->query( $q ) ;
$db->next_record();

if( $db->f("num_rows") > 0 ) {
$GLOBALS['vmLogger']->err( 'This Vendor Category has associated Vendor records.');
return false;
}
return true;
}


Regards
Phil