News:

Support the VirtueMart project and become a member

Main Menu

Is it possible to store searches to database?

Started by T.A. Garrison, LLC, January 04, 2024, 03:10:06 AM

Previous topic - Next topic

T.A. Garrison, LLC

If a visitor searches and is met with a response something like "No Results", is it possible that the item searched can be saved to the database in order for admin to review and consider if this item "can" be located?

I have a large E-Commerce client selling keys - for cars, trucks, boats, planes and motorcycles...in addition to other products.
But if a visitor searches for a key (or something) and has no results (due to the fact that the product is not even in the database), we'd like to know what someone searched when they got the "No results" response.

Does anybody know of an extension, or, someone willing to write the code for one that can save the searches "and" (most importantly) be an easy to review list of searches not found?
T.A. Garrison, LLC
3150 Orleans St. # 28261
Bellingham, WA 98228

hazael

#1
You shouldn't tie this to the database - an aggressive web crawler could quickly fill up your database and RAM.
All you need to do is create a simple PHP script that will collect logs into a text file - it will be safer.

https://stackoverflow.com/questions/3718307/php-script-to-log-the-raw-data-of-a-post
https://itecnote.com/tecnote/php-script-to-log-the-raw-data-of-post/

Another very simple way to collect data from search phrases on your website is GA4 - Google Analytics. Just integrate your form field with Analytics and you'll have a full history of your most frequently used keywords.
You just need to add the appropriate query parameters for your search engine in the Analytics administrative settings for the "site search" option.
In the events category, just unlock the view_search_results
If you want to check what keywords users have entered, you need to register the search_term parameter in your custom definitions.

If you want to separate only unfound products for a searched keyword, you can also apply rules that will display another parameter related to the searched keyword - you can also use a Google tag manager that activates the rule depending on the content on the page.


T.A. Garrison, LLC

Thanks, hazael.

I like the idea of just collecting the results in a txt file. I'm going to look into that.

Using GA4 is getting too complicated and there are more search boxes than just 1 form. There are different searches in various parts of the site.

Quite frankly, I was seriously considering, and the site owner was in agreement, to simply edit the search results where it says, "No results", so that there is more of a message. Something like, "Your search is not a product we typically stock. But if you use this link (Contact Us) and include the (whatever information the owner wants) information, then we will research and notify you of our results."

But I do see merit in just collecting the txt file. Great idea! Thanks!
T.A. Garrison, LLC
3150 Orleans St. # 28261
Bellingham, WA 98228

T.A. Garrison, LLC

Hazael,

You were kind enough to respond with some good information, so I'm hoping you can answer this.

I've successfully created the pages to log the search, but before combining that with the current search in VM, I thought I'd see if I can do something more simple.

If I can get the path to the current search file (VirtueMart 4.2.4 10922), I'm going to add a link to a page that is already set up for visitors to provide information about what they were searching when they saw no results.
I have a plan for the "No results" search response, but I'm unable to find where the search file is in this version of VM.
More specifically, what file (the path and name) is used to display the "No results"?
T.A. Garrison, LLC
3150 Orleans St. # 28261
Bellingham, WA 98228

GJC Web Design

just at the bottom of your components\com_virtuemart\views\category\tmpl\default.php or your template over ride

} elseif ($this->keyword !== false) {
echo vmText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : (' . $this->keyword . ')' : '');
}
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