News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Search by id

Started by sandomatyas, March 10, 2022, 09:06:01 AM

Previous topic - Next topic

sandomatyas

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?

GJC Web Design

#1
+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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jörgen

Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

sandomatyas

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

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/