VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Quality & Testing VirtueMart 1.1.x => Virtuemart 1.1 Development (Archiv) => Q&T Resolved => Topic started by: doorknob on May 10, 2009, 19:30:23 PM

Title: [FIXED] Bug: ps_vendor_category
Post by: doorknob on May 10, 2009, 19:30:23 PM
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
Title: Re: Bug: ps_vendor_category
Post by: aravot on May 10, 2009, 22:41:43 PM
Fixed in 1.1.4