Post by stonehinged » Sun Apr 10, 2011 12:19 pm

Instead of the default message when no related products are present, I'd like to add a link to direct shoppers back to the item's parent category as the "fallback". I would just like for there to be an option to direct the customer somewhere if they have taken the time to click the tab and expect to see something. Is this possible? I'm using 1.4.7.

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US

Post by Avvici » Mon Apr 11, 2011 1:18 am

Go to catalog/view/theme/default/template/product/product.tpl

Search for this line of code:

Code: Select all

<?php echo $text_no_related; ?>
Edit the echo directly, or just replace the php with an html URL like this:

Code: Select all

<a href="Your link back to parent category">Back To Products</a>
If you want to go back to the category from whence they left then just set a session variable holding the name of the category and path. route=product/category&path=bla bla bla. You will want to set this session variable in your category.php file because that is the control for going from a category to an actual product and especially because if you are using SEO URL' it will have time to convert.

Code: Select all

<a href="<?php echo $_SESSION['parent_category'];?>">Back To Products</a>

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by stonehinged » Mon Apr 11, 2011 2:45 am

Thanks avvici, I definitely want it dynamic but unfortunately, I'm not much of a programmer. I can follow your suggestion somewhat, but not sure I can pull it off without more detail. Sad to say, perhaps the code for copy/paste ;D

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US

Post by Avvici » Mon Apr 11, 2011 2:52 am

Please look at the post below for your solution. O0
Last edited by Avvici on Mon Apr 11, 2011 3:59 am, edited 1 time in total.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by Avvici » Mon Apr 11, 2011 3:56 am

I did not hear from you so just follow these directions and you will achieve what you need to do:

Open catalog/controller/product/category.php and search for the following array:

Code: Select all

$this->data['products'][] = array(
            			'name'    => $result['name'],
						'model'   => $result['model'],
            			'rating'  => $rating,
						'stars'   => sprintf($this->language->get('text_stars'), $rating),
						'thumb'   => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),						
            			'price'   => $price,
            			'options' => $options,
						'special' => $special,
						'href'    => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&path=' . $this->request->get['path'] . '&product_id=' . $result['product_id']),
						'add'	  => $add
          			);
Right after that array insert the following code:

Code: Select all

//Begin Set Category Path Session Variable
$this->session->data['cat_path']=$this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url);
//End Set Category Path Session Variable
That will set the session variable that you need to reference on the TPL. MAKE SURE THAT YOU PLACE IT BETWEEN THE ENDING CURLEY BRACKET FROM THE ARRAY, AND THE ENDING CURLEY BRACKET FROM THE FUNCTION THE ARRAY IS IN so it total it will look like this:

Code: Select all

$this->data['products'][] = array(
            			'name'    => $result['name'],
						'model'   => $result['model'],
            			'rating'  => $rating,
						'stars'   => sprintf($this->language->get('text_stars'), $rating),
						'thumb'   => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
						
            			'price'   => $price,
            			'options' => $options,
						'special' => $special,
						'href'    => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&path=' . $this->request->get['path'] . '&product_id=' . $result['product_id']),
						'add'	  => $add
          			);
//Begin Set Category Path Session Variable
					$this->session->data['cat_path']=$this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url);
//Begin Set Category Path Session Variable
        		}

Now open the file: catalog/view/theme/default/template/product/product.tpl and find the following code:

Code: Select all

<?php echo $text_no_related; ?>
Replace that with this and you will be done:

Code: Select all

<a href="<?php echo $_SESSION['cat_path'];?>">Back To Products</a>

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by stonehinged » Mon Apr 11, 2011 11:13 am

Thanks so much avvici, I greatly appreciate your time and help. It's the community and folks like you that make using OC so great, especially us that are trying to pick up the code and knowledge as we go. I marvel at what you folks do! Thanks again!

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US

Post by Avvici » Mon Apr 11, 2011 2:28 pm

It no problem. Just giving back. Lord knows many have helped me in here too.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by BadgesOnboard » Thu Jan 25, 2018 5:37 pm

Hey there, I currently have 3 categories on the top and then 10 down the side ... I would like the 10 down the side as a drop down at the top but to also keep down the side .... if I add them to a parent category they disappear from the side ... is there anyway I can have them both at the top and down the side ?

New member

Posts

Joined
Sat Nov 18, 2017 8:43 pm
Who is online

Users browsing this forum: No registered users and 33 guests