Hi and thanks in advance for any help. I am building a website that only has one product (a service).
When a client clicks on the category link in the top menu bar I want it to go straight to that product.
I did search the forums but the only found a solution from 2011, which doesn't work on the 2.0.1.1 script I'm using (results in a php redirect error).
It involved changing catalog/controller/product/category.php from:
foreach ($results as $result) {
if ($result['image']) {
to this:
foreach ($results as $result) {
if($product_total == 1){
$this->redirect($this->url->link('product/product', 'product_id='.$result['product_id']));
}
if ($result['image']) {
I have made a work around using .htaccess, but would ultimately prefer to change the code directly, as the url looks a bit messy.
I changed opencart to seo friendly urls, and put this at the bottom of my .htaccess:
Redirect 301 /old-category-name /the-product
It took a lot of mucking around and trial and error, because everywhere I looked online it wanted the full http for the url it was being redirected to, but this ended up in a loop. It also didn't work putting a ? or /? at the end (in fact, it repeated itself adlib and created a server error as the url was over 3000 odd characters long!!
)
Now it redirects ok, but the url repeats itself (old-category-name-the-product_route=old-category-name-the-product), so not sure how google will like that.
Just putting it in case anyone finds the .htaccess thing handy one day.
However I would really appreciate it if someone could tell me where to change the code in category.php for a proper redirect.

I changed opencart to seo friendly urls, and put this at the bottom of my .htaccess:
Redirect 301 /old-category-name /the-product
It took a lot of mucking around and trial and error, because everywhere I looked online it wanted the full http for the url it was being redirected to, but this ended up in a loop. It also didn't work putting a ? or /? at the end (in fact, it repeated itself adlib and created a server error as the url was over 3000 odd characters long!!

Now it redirects ok, but the url repeats itself (old-category-name-the-product_route=old-category-name-the-product), so not sure how google will like that.
Just putting it in case anyone finds the .htaccess thing handy one day.



Who is online
Users browsing this forum: No registered users and 6 guests