In a standard VM2 installation, there are two rows in the virtuemart_customs table, representing the type "R" (related products) and "Z" (related categories) that are two standard custom fields for products.
When migrating to VM from another e-commerce system (e.g. Prestashop) using a migration service (e.g. Cart2Cart), the _customs table can not be guaranteed to have these two lines present. When this is the case, trying to add a related product (or category) by the AJAX search box give unexpected and unpredictable behaviour.
This is because setRelatedHtml function at the end of the view.json.php file has the line:
"$customs = $this->db->loadObject(); " and $customs is then used as a parameter in another function call, without testing to see if it exists.
There should be a test on the value of $customs to see if it exists (with an error message if not) before then going on to use it.