News:

Support the VirtueMart project and become a member

Main Menu

Feature request: Customfields should searchable

Started by be, December 23, 2012, 16:14:33 PM

Previous topic - Next topic

user_fra

Thank you again jjk, the greek site you suggested me is wonderful, I had already seen it the post in the forum. So one week ago (maybe more) I wrote to the web agency that made the site, I told them I was ready to pay just to have some advices for my bookstore, but I had no reply yet. I also searched bookstore and bookshop in the forum, now I don't remember very well all of them, but I think I did not see the solution.
This morning I sent a private message also to Milbo, it seems he knows very well how to manege the search in custom fields, I begged him to write the explanation in this post.
Thank you for the time you have dedicated to this issue.

Francesco

jjk

#16
Milbo iis here: http://extensions.virtuemart.net/certifications/certification-of-virtuemart-2-detail this week, so he might not read it. By the way, for a bookshop you could create some Joomla language file overrides, which replace the word 'Manufacturer' with 'Author'. So your customers can at least search for authors. Some examples:

COM_VIRTUEMART_MANUFACTURER_DETAILS="Author:"
COM_VIRTUEMART_MF_NAME="Author Name"
COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL="Author: "
COM_VIRTUEMART_SEARCH_ORDER_MF_NAME="Author Name"
COM_VIRTUEMART_SEARCH_SELECT_ALL_MANUFACTURER="All Authors"
COM_VIRTUEMART_SEARCH_SELECT_MANUFACTURER="Select Author"
COM_VIRTUEMART_SEF_MANUFACTURER="author"
COM_VIRTUEMART_SEF_MANUFACTURERS="authors"

Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

user_fra

Thanks for the suggestion jjk, I traslated and used the field manufacturer for publishers and it works very well because every book can have only one publisher. The authors can be more than one. I'm not in a hurry, I can wait until the end of August, let's see if in the meantime somebody else will completely clarify the situation.

Many thanks for your help jjk.

Francesco

be

Hi,
here is a actualized /administrator/components/com_virtuemart/models/product.php in this work the customfield search.
I paid a programmer to fix this. It is for the Vmart version 2.0.20b.

In this it is necessary to hardcode the customfield IDs on line269.

Greetz

[attachment cleanup by admin]

user_fra

Thank you very much BE. I read your code, but I prefer to wait for the authors of Virtuemart, hoping they'll make an implementation to the code giving us the opportunity to research a word in the custom fields using the standard search field.

Thank you in any case.

Francesco

Milbo

#20
Thank you Be for sharing this code.

Searching in customfields work. It is just atm so that the user sees this dropdown after the first search. Our idea was to show a template how it works and that they just remove the whole code for it, or the if condition to show it directly.

The idea is that we either prefer in the search the products OR the customfields for a good performance.

=> Enter something in the normal search field => searches all products
or => choose a customfield and search there, means find all products with that customfield which contain the search string.

The code of Be is done in an old model... the difference is that it searches always in customfields hardcoded there. We could solve that with an option later

around line 293 after the foreach loop and before

if (!empty($filter_search)) {


paste this


// if no custom fields where defined to filter for use these hardcoded ones
if(empty($this->searchcustoms)){
          // 4 Herausgeber
          // 6 ISBN
          // 13 Buchreihe
          // 17 Autor
     $custom_ids=array(4,6,13,17);
     $this->searchcustoms=array_fill_keys($custom_ids, $this->keyword);
}
       
// add custom fields to filter array to get an OR condition in sql request
if (!empty($this->searchcustoms)) {
$joinCustom = TRUE;
foreach ($this->searchcustoms as $key => $searchcustom) {
$filter_search[] = '(pf.`virtuemart_custom_id`="' . (int)$key . '" and pf.`custom_value` like "%' . $this->_db->getEscaped ($searchcustom, TRUE) . '%")';
}


Around line 306 search for

if (!empty($this->searchcustoms)) {


and disable the whole if case. For a proper implementation into the core we need some options.

1. display customfield dropdown
a) always
b) like now
c) never

2. search options customfields
a) select customfields to search in
b) search always in customfields with OR or AND link
c) search only in customfields if dropdown is used with OR or AND link
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Adam Bazaroff

Sorry about wakeup this topic. But this is a big problem. Anybody have new code or plugin for this kind of search?
/Adam'B ... Poor english mode [ON] ;D