example.com/index.php?route=product/search&search=blue%20ball
NOW redirect that to: example.com/blueball
~ OC 3.0.3.2 and OCmods only ~
Edit this file:
Code: Select all
catalog\controller\product\search.php
Code: Select all
if (isset($this->request->get['tag'])) {
Code: Select all
if ($search == 'blue ball') {
$this->response->redirect($this->url->link('product/product', 'product_id=42'));
}
Code: Select all
if ($search == 'blue ball') {
$this->response->redirect($this->url->link('product/product', 'product_id=42'));
}
Code: Select all
header("Location: http://example.com/");
~ OC 3.0.3.2 and OCmods only ~
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Why would you hardcode it rather than make it dynamic?DigitCart wrote: ↑Sat Jan 25, 2020 9:02 pmHi
Edit this file:Find:Code: Select all
catalog\controller\product\search.php
Add before it:Code: Select all
if (isset($this->request->get['tag'])) {
42 is an example of product ID.Code: Select all
if ($search == 'blue ball') { $this->response->redirect($this->url->link('product/product', 'product_id=42')); }
And why would you edit core files rather than add this to .htaccess?
Pretty poor code above, I don't suggest anyone does that.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Hipaulfeakins wrote: ↑Mon Jan 27, 2020 6:33 pmWhy would you hardcode it rather than make it dynamic?
And why would you edit core files rather than add this to .htaccess?
Pretty poor code above, I don't suggest anyone does that.
Yes, But I only showed the way.
I was not going to explain writing a dynamic extension.
Ok but usually if you provide some hacky code it's best to say so and then at least anyone reading will not think this is a good or recommended way to do it
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
~ OC 3.0.3.2 and OCmods only ~
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Hey paulfeakins how exactly would I use htaccess to redirect a search query to a URL?paulfeakins wrote: ↑Mon Jan 27, 2020 6:33 pmAnd why would you edit core files rather than add this to .htaccess?
Pretty poor code above, I don't suggest anyone does that.
Say I want to send search query "mints" to mysite.com/mints, this below works but it isn't perfect.
Code: Select all
RewriteCond %{QUERY_STRING} ^route=product/search&search=mints
RewriteRule ^index\.php$ "/mints" [R=301,L]
~ OC 3.0.3.2 and OCmods only ~
Users browsing this forum: nonnedelectari and 402 guests