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?
+1 -- would be very useful ...
A lot of VM troubleshooting etc requires quick finding of pids
I like this one: id: short, universal, uses Joomla-logic
+1 From me to
Jörgen
I forgot: sure, my solution is a quick one, it's better not to evaluate all of the other fields when you search for an id so maybe an if/else could cut the unneccessary ones
Hello Sandomatyas, good news, this was implemented by RuposTel and is part of the vm4 core! Check the news https://virtuemart.net/news/506-virtuemart-4
:-) I am really happy that we could implement it in the last week before the release. And it just started, we can extend it.