Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search by Product Tag Bug
#1
In frontend product displaying page ver. 1.11.0. 
I have a tag with four words, let's say:
word1 word2 word3 word4. When I click on the tag I goto search page with this URL part:
index.php?route=product/search&search=word1%20word2%20word3%20word4&tag=word1%20word2%20word3%20word4

because of the search term: 
&search=word1%20word2%20word3%20word4 
I get 15 results - for any product that contains even one of the 4 words.
If i manually change the URL and make it:
index.php?route=product/search&tag=word1%20word2%20word3%20word4
I get the right results - the 2 products that are using this tag.

I had a look in file:
catalog\controller\product\product.php
and I saw that in line 859 has an if statement:
if ($product_info['tag']) {
inside the if statement the right link call is written. Line 867:
'href' => $this->url->link('product/search', 'search=' . $tag . '&tag=' . $tag, 'SSL')
but something make it not appear (or change it later) in the actual link reference at the frontend.
Reply
#2
(06-13-2018, 09:09 PM)Sp1ke Wrote: In frontend product displaying page ver. 1.11.0. 
I have a tag with four words, let's say:
word1 word2 word3 word4. When I click on the tag I goto search page with this URL part:
index.php?route=product/search&search=word1%20word2%20word3%20word4&tag=word1%20word2%20word3%20word4

because of the search term: 
&search=word1%20word2%20word3%20word4 
I get 15 results - for any product that contains even one of the 4 words.
If i manually change the URL and make it:
index.php?route=product/search&tag=word1%20word2%20word3%20word4
I get the right results - the 2 products that are using this tag.

I had a look in file:
catalog\controller\product\product.php
and I saw that in line 859 has an if statement:
if ($product_info['tag']) {
inside the if statement the right link call is written. Line 867:
'href' => $this->url->link('product/search', 'search=' . $tag . '&tag=' . $tag, 'SSL')
but something make it not appear (or change it later) in the actual link reference at the frontend.

I made a vqmod file solving this. This works both for the Tags module and for the tags link(s) in product page. You may download and use this one for free. Note that this is tested only in ver. 1.11.0
Two points:
1. It returns the right results BUT is not showing the tags in the search input box ("Search for" input shows nothing).
2. Remarks or questions are welcome but please keep in mind that I am not a professional programmer...just helping a friend with her company website.


Attached Files
.zip   tagssearchlink.zip (Size: 561 bytes / Downloads: 2)
Reply
#3
@villagedefrance Could this somehow be integrated into the core?
I mean it would be nice to be able to refine the search using multiple keywords.
Reply
#4
For display the tag search word(s) in the search page heading (like "Search - tag words") a modification is needed to the file: "catalog/controller/product/search.php".

At line 77 the code:

Code:
if (isset($this->request->get['search'])) {
$this->document->setTitle($this->language->get('heading_title') . ' - ' . $this->request->get['search']);
} else {
$this->document->setTitle($this->language->get('heading_title'));
}
 Must be changed to:

Code:
// Modification to display tag to search page heading
if (isset($this->request->get['search'])) {
$this->data['heading_title'] = $this->language->get('heading_title') . ' - ' . $this->request->get['search'];
} else {
if (isset($this->request->get['tag'])) {
$this->data['heading_title'] = $this->language->get('heading_title') . ' - ' . $this->request->get['tag'];
} else {
$this->data['heading_title'] = $this->language->get('heading_title');
}
}
// Modification end

And also at line 141 the code:

Code:
if (isset($this->request->get['search'])) {
$this->data['heading_title'] = $this->language->get('heading_title') . ' - ' . $this->request->get['search'];
} else {
$this->data['heading_title'] = $this->language->get('heading_title');
}
 Must be changed to:

Code:
// Modification to display tag to search page heading
if (isset($this->request->get['search'])) {
$this->data['heading_title'] = $this->language->get('heading_title') . ' - ' . $this->request->get['search'];
} else {
if (isset($this->request->get['tag'])) {
$this->data['heading_title'] = $this->language->get('heading_title') . ' - ' . $this->request->get['tag'];
} else {
$this->data['heading_title'] = $this->language->get('heading_title');
}
}
// Modification end

I am including the modified file as zip so it can be downloaded. After unzip must be copied (and override) this file:
"catalog/controller/product/search.php"
For everything working fine after the above changes the vqmod file also must be installed.


Attached Files
.zip   search.zip (Size: 4.36 KB / Downloads: 2)
Reply
#5
Done!

I have just committed an updated Controller/Search.php file at Github.

Thank you for the suggestion and the bit of code.
OpenCart Overclocked Edition Lead developer
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)