We need to use search by virtuemart_product_id in the admin area a lot, but using 'product_id' in Available Search Fields is not a best method, because searching for ID should return an exact match, not a substring match.
I checkhed core Joomla3 code how it works with core components and based on that I put this code in VirtueMartModelProduct.sortSearchListQuery right before it creates $whereString
if (stripos($this->keyword, 'id:') === 0)
{
$where = ['`p`.virtuemart_product_id='.(int) substr($this->keyword, 3)];
}
It does work, it helps me a lot and I'm sure it's a useful and easy-to-implement function for other users as well.
I'm not sure what keyword should we use here
- id: short, universal, uses Joomla-logic
- product_id: semi-short, view-specific, can be used as product_id, category_id, media_id etc. This is how VM shows it when lists the available search fields
- virtuemart_product_id: exact field name, VM-specific, can be used as virtuemart_product_id, virtuemart_category_id, etc
Could you please consider implementing this?