VirtueMart 1.1 Alpha Numeric search module - Joomla & VirtueMart Tips & How To's

An A to Z, 0 to 9 (Alpha-numeric) search/listing module for VirtueMart. Search for VirtueMart products by first letter or number and display the results in the standard VirtueMart search results page.

Home Joomla - VirtueMart VirtueMart A-Z search

Sat

28

Mar

An A to Z, 0 to 9 (Alpha-numeric) search/listing module for VirtueMart.


Search for VirtueMart products by first letter or number and display the results in the standard VirtueMart search results page.
If only one result is found it redirects to the product page.
You can try it here - Demo ... and download it here - Download

How it works -

It just utilises the standard Virtuemart search but filters it by product name and 1st letter or number.
It needs the installation of this module and two very small hacks in classes/ps_main.php and html/shop_browse_queries.php

The module installs as normal and publish it somewhere.
The only only parameters are pre and post text and module classes.
It's simply a list of search urls and is very simple to style differently directly in the mod_az_virtuemart.php file or with css.

VirtueMart 1.1 Alpha Numeric search module parameters

Styling

Give the module a class then style the resulting menu class
a.mainlevel-az {
padding-left:5px;
text-decoration:none;
}
... An image for each letter would be even better.

Source Changes Needed

The change needed to html/shop_browse_queries.php is to make a new $search_limiter parameter so it only searches for the 1st letter.
around line 110 insert after switch($search_limiter) {
case "az":
$sq .= "\n `#__{vm}_product`.`product_name` LIKE '$searchstring%' ";
break;
so it looks like
switch($search_limiter) {
case "az":
$sq .= "\n `#__{vm}_product`.`product_name` LIKE '$searchstring%' ";
break;
case "name":
$sq .= "\n `#__{vm}_product`.`product_name` LIKE '%$searchstring%' ";
break;
In the file classes/ps_main.php the function "vmGetCleanArrayFromKeyword" ignores the search unless there's more than 2 letters.
I change this to 1 letter to get it to work.
I tried to use a different keyword parameter e.g. keyword3 but I couldn't get it to work but this would be a "nicer" way to do it rather than hook in to the already used parameter.
Perhaps someone can achieve this?

So in classes/ps_main.php around the line 1260 change the
if( $strlen > 2 ) {
to
if( $strlen > 0 ) {

Paypal Donation

If you use this module on your site please donate a small amount.
Any donation amount appreciated.

Updates!


Version 0.2
Code re-written so that the urls are formed by php, a smaller package now (ver0.2)

Version 0.3
Fixed problem with search urls and SEF components

If you have any comments, suggestions or need any help please leave a comment below.

If you use it on a commercial site (if it's Virtuemart I guess it's got to be commercial ;) ) please leave a small donation.
Thanks.
Last Updated on Saturday, 12 December 2009 12:20
 
VirtueMart
Your Cart is currently empty.

Paypal Donation

If you use this module on your site please donate a small amount.
Any donation amount appreciated.

Latest Joomla & VirtueMart Tips

See all tips & examples

VM Live Product Search

VirtueMart A-Z Module

Use the letters C or S as there's not many products in the test shop!
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9

Letter D will return one result i.e. the product page.



VirtueMart 1.1 Alpha Numeric search module|Joomla & VirtueMart Tips & How To's



An A to Z, 0 to 9 (Alpha-numeric) search/listing module for VirtueMart. Search for VirtueMart products by first letter or number and display the results in the standard VirtueMart search results page.


search, product, php, virtuemart, module, letter, classes, like, case, main, limiter, urls, change, parameter, break, searchstring, work, needed, queries, use, leave, version, file, class, strlen, style, browse, keyword, text, number, shop, switch, commercial, download, small, line, page, results, standard, html


guru

We use cookies to improve our website and your experience when using it. Cookies used for the essential operation of the site have already been set.
To find out more about the cookies we use and how to delete them, see our privacy policy.

I accept cookies from this site.