Post by jkungfu » Wed Dec 01, 2010 4:34 pm

i found that when i click a products of the home page, the breadcrumbs did not display the whole path.

only like this Home > product_name

i want to it display the whole path like this Home>category1>category1_1>product_name

淄博网站建设, 淄博网站优化


Active Member

Posts

Joined
Fri Jan 01, 2010 8:03 pm


Post by JAY6390 » Wed Dec 01, 2010 6:21 pm

it can't without you going to the product via that path, it remembers which path you take to it

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by jkungfu » Thu Dec 02, 2010 10:44 am

but when i click LOGIN from home page, it displayed Home > Register Account > Login

so, where will be a method can display the whole path, when i open a link of a product.

and
http://demo.opencart.com/index.php?rout ... uct_id=100
http://demo.opencart.com/index.php?rout ... uct_id=100
http://demo.opencart.com/route=product/ ... uct_id=100
http://demo.opencart.com/product/product&product_id=100
http://demo.opencart.com/product&product_id=100
http://demo.opencart.com/p&product_id=100

these links all display a same page!!!!!!

淄博网站建设, 淄博网站优化


Active Member

Posts

Joined
Fri Jan 01, 2010 8:03 pm


Post by Nakano » Thu Dec 02, 2010 11:47 am

jkungfu's issue makes perfect sense. I'm having this problem as well and would like to see solved because it's just pathetic...

Thing is, if you look for a product by browsing through CATEGORIES, you'll eventually see the full path, which is useful to the user to go check other similar products on categories, if he so wish for.

But if you click on a product on either LATEST PRODUCTS, BESTSELLERS, or FEATURED, you'll get a very annoying "Home > [product name]", which leads to confusion to "oh, nice, and of which category is this item, of same category but not necessarily related?".

ver 1.4.9.2, so this is a core issue, clean install, no modules involved. Please advise... it IS stupid and annoying.

Newbie

Posts

Joined
Sat Sep 18, 2010 6:54 am

Post by jkungfu » Thu Dec 02, 2010 3:11 pm

yes, you described very clear. who can solve this problem?

that is, how can i get its father category url and its grandfather category url until the root category url in a product page?

淄博网站建设, 淄博网站优化


Active Member

Posts

Joined
Fri Jan 01, 2010 8:03 pm


Post by JAY6390 » Thu Dec 02, 2010 6:58 pm

While I can understand your frustration regarding this, the simple fact of the matter is this is not a design flaw, its due to the fact that a product can have multiple categories. How would you distinguish which category is shown when a product has multiple categories?

This is possible to fix to a degree, but your categories would be assigned randomly for products in multiple categories

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Nakano » Thu Dec 02, 2010 7:18 pm

JAY6390 wrote:While I can understand your frustration regarding this
As of now I'm quite frustrated with a lot of things regarding Opencart, lol... :laugh:
JAY6390 wrote:its due to the fact that a product can have multiple categories. How would you distinguish which category is shown when a product has multiple categories?

This is possible to fix to a degree, but your categories would be assigned randomly for products in multiple categories
I see your point. In this case, this would probably require additional template hacking to provide more information aside from Price, Availability, Model, Manufacturer, Average Rating, on the product details on the right side of as product's picture.

I think, from a salesman's point of view, if you can help a customer keep track of the category one's interested in, he or she might want to check out what other similar items could be interested in. Related Products is not good enough, and even if it was, you can't have "infinite" related products, don't you agree?

Newbie

Posts

Joined
Sat Sep 18, 2010 6:54 am

Post by JAY6390 » Thu Dec 02, 2010 8:40 pm

I can understand what you mean about this - I made a module called also bought (commercial) that basically upsells products most frequently bought in an order with the current product you are viewing, or the products in the basket on the checkout so that you get maximum upsell from your customers, plus you don't need to add the products, it runs off the orders :)

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Xsecrets » Thu Dec 02, 2010 9:28 pm

You're not understanding. In opencart there is a product to categories table which allows products to be assigned to multiple categories. For instance just say you have an iphone product you put it in the mobile phone category and in the mp3 category. Now when you click on that product from the homepage what category do you want it to display? I have no idea neither does the customer or the program and there's no way to determine that.

Plus over half the urls you listed above are simply where you messed around with the url manually and are not links that would ever be generated by the system or crawled by a search engine.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by jkungfu » Thu Dec 02, 2010 11:08 pm

because i have no products belong to multiple categories, and i've implemented this feature, you can visit my cheap handbags site and see the effect.

淄博网站建设, 淄博网站优化


Active Member

Posts

Joined
Fri Jan 01, 2010 8:03 pm


Post by cmerry » Sat Dec 04, 2010 10:18 pm

Can you please describe, how did you make it? Thanks.


User avatar
Active Member

Posts

Joined
Sat Jul 17, 2010 8:42 pm

Post by traceofwind » Wed Mar 23, 2011 11:02 am

Was this ever fixed? I know this is an old post but it seems crazy that 'featured products' and indeed 'latest products' can't have breadcrumbs. I'd be very interested to know if anyone has managed to hack this?

New member

Posts

Joined
Fri Jul 02, 2010 6:37 am

Post by SXGuy » Wed Mar 23, 2011 4:02 pm

it doesnt seem crazy, it seems quite reasonable, as Xsecrets keeps pointing out to you all.

It is you guys who do not understand.

Sure, if you have a product and it is listed in only one category ever, and never changes, never runs out of stock, and is always there to buy, ok, maybe you can mod the breadcrumbs, but from a "out of the box" point of view, it is not possible while you have the ability to place products in multiple categories, you cant have 1 and also the other.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by Pobb » Mon Jun 20, 2011 8:13 pm

Sorry to bump an old thread but this is the problem I was having too. Now I've read this I fully understand why OC does this but I need to find a solution.

My 'Resort Wear' category and its products have a different stylesheet to make the background white/font black, whereas 'Evening Wear' utilises the default css to display a black bg/white font. This works fine until you click on a related product in 'Resort Wear' - the url misses out the parent category and so the stylesheet reverts to the default. How do I get the related product links and links from the cart to keep their parent category in the url?

I would reeeeeeeeeeeeeeeeeeeeeeeeeeeally appreciate any links or ideas that may help me solve this.

Active Member

Posts

Joined
Tue May 31, 2011 2:35 pm

Post by Pobb » Tue Jun 21, 2011 12:40 pm

anyone? ???

Active Member

Posts

Joined
Tue May 31, 2011 2:35 pm

Post by VettelS » Wed Aug 15, 2012 11:43 pm

I know this is a very old thread, but it's the only mention of the subject I've been able to find. I had also been looking for a "fix" for this issue, as I only ever assign a single category to each product. Unable to find a solution, I created one myself.

Go to catalog/controller/module/featured.php and find the

Code: Select all

foreach
look around line 28.

Copy and paste the code below inside the foreach loop, right at the beginning:

Code: Select all

//Creates path so breadcrumbs display
$cat = $this->model_catalog_product->getCategories($product_id);
if(!empty($cat))
{
	$cat_trace = array($cat[0]['category_id']);
	$i = 0; $stop = false;
	while(!$stop)
	{
		$arr = $this->model_catalog_category->getCategory($cat_trace[$i++]);
		if($arr['parent_id'] != 0)
			$cat_trace[] = $arr['parent_id'];
		else
			$stop = true;
	}

	$cat_trace = implode('_', array_reverse($cat_trace));
			    
	$link = $this->url->link('product/product', 'path=' . $cat_trace . '&product_id=' . $product_info['product_id']);
}
	else $link = $this->url->link('product/product', 'product_id=' . $product_info['product_id']);
Next, scroll down until you find

Code: Select all

$this->data['products'][] = array(
(still inside the

Code: Select all

foreach
loop). Find the

Code: Select all

href
member and change it's value to

Code: Select all

$link
, so you have

Code: Select all

'href' => $link
.

Once you've done this, links produced by the Featured Products module will include the full category path so that breadcrumbs display properly on the Product page. This should work with 1.5.x, and possibly earlier versions as well.

Email me if you have any questions: jam4online@hotmail.co.uk.

Newbie

Posts

Joined
Wed Aug 15, 2012 11:32 pm

Post by Q000 » Sun Apr 07, 2013 9:15 pm

I know are some months since the resolution was found and shared here but really need to thank you, VettelS. I addapted your solution for bestseller.php, latest.php and special.php. Everithing works great for Opencart v1.5.5.1. Nice job man, really apreciated !

Newbie

Posts

Joined
Fri Mar 08, 2013 4:53 pm

Post by icorvinus » Fri Apr 19, 2013 11:10 pm

Q000 wrote:I know are some months since the resolution was found and shared here but really need to thank you, VettelS. I addapted your solution for bestseller.php, latest.php and special.php. Everithing works great for Opencart v1.5.5.1. Nice job man, really apreciated !
Could you share your addaptation code for Opencart 1.5.5.1? Especially part in the loop where checking parent_id took part

Code: Select all

if($arr['parent_id'] != 0)
Products doesn't have parent_id field anymore in 1.5.5.1

Newbie

Posts

Joined
Fri Apr 19, 2013 11:01 pm

Post by georgexan » Fri Jul 19, 2013 4:12 pm

Hello to everyone, this is my first post :)

i was searching a solution about breadcrumb i think that i found it.. I wanted the full breadcrumb like

home->category->subcategory->product even a person was clicking from the latest - featured module of homepage

So below is the code that you need...

catalog->controller/product/product.php around 75-80 line

Code: Select all

$this->load->model('catalog/product');
		if (isset($this->request->get['product_id'])) {
			$product_id = (int)$this->request->get['product_id'];
		} else {
			$product_id = 0;
		}
		$catids = $this->model_catalog_product->getCategories($product_id);
		$cat_ids = '';
		if(isset($catids)){
			foreach ($catids as $catid) {
				$cat_ids .= $catid['category_id'].'_';
			}	
		}
		if(isset($cat_ids)) {
				$path = '';
				
				$parts = explode('_', (string)$cat_ids);
				
				$category_id = (int)array_pop($parts);
				if(isset($parts[0]))
					$par_category = $this->model_catalog_category->getParent($parts[0]);
				if(!isset($this->request->get['path'])){
					if (isset($par_category)) {			
						$url = '';
						
						if (isset($this->request->get['sort'])) {
							$url .= '&sort=' . $this->request->get['sort'];
						}	
			
						if (isset($this->request->get['order'])) {
							$url .= '&order=' . $this->request->get['order'];
						}	
						
						if (isset($this->request->get['page'])) {
							$url .= '&page=' . $this->request->get['page'];
						}
						
						if (isset($this->request->get['limit'])) {
							$url .= '&limit=' . $this->request->get['limit'];
						}
												
						$this->data['breadcrumbs'][] = array(
							'text'      => $par_category['name'],
							'href'      => $this->url->link('product/category', 'path=' . $par_category['category_id']),//$this->request->get['path']),
							'separator' => $this->language->get('text_separator')
						);
					}
				
					if(isset($parts[0]))
						$category_info = $this->model_catalog_category->getCategory($parts[0]);
					if(isset($category_info)){
						if ($category_info) {
							$this->data['breadcrumbs'][] = array(
								'text'      => $category_info['name'],
								'href'      => $this->url->link('product/category', 'path=' . $par_category['category_id'].'_'.$parts[0]),
								'separator' => $this->language->get('text_separator')
							);
						}
					}
				}
			}
and go now to catalog->model->catalog->category.php
in the last line before last '}' add this function

Code: Select all

public function getParent($subcat) {
	$parid = $this->db->query("SELECT * FROM " . DB_PREFIX . "category WHERE category_id = " . (int)$subcat);
	$query = $this->db->query($q = "SELECT DISTINCT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.category_id = '" . (int)$parid ->row['parent_id'] . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1'");

	return $query->row;
}

Newbie

Posts

Joined
Fri Jul 19, 2013 4:00 pm

Post by cheeseus » Tue Jun 23, 2015 11:24 pm

Just adding that VettelS' code also works for OpenCart 2.0.2.0 and 2.0.3.1.

The only thing you need to be careful with is placing the code NOT immediately after the foreach loop opens, but after the second line of code inside it:

Code: Select all

$product_info = $this->model_catalog_product->getProduct($product_id);
This is necessary because the code uses the $product_info['product_id'] array element which isn't declared if the line above comes after the addition, which will trigger an error.

This is how your foreach loop should look:

Code: Select all

foreach ($products as $product_id) {
	$product_info = $this->model_catalog_product->getProduct($product_id);

	// Hack to create full path in the breadcrumbs for featured products
	$cat = $this->model_catalog_product->getCategories($product_id);
	if(!empty($cat)) {
		$cat_trace = array($cat[0]['category_id']);
		$i = 0; $stop = false;
		while(!$stop) {
			$arr = $this->model_catalog_category->getCategory($cat_trace[$i++]);
			if($arr['parent_id'] != 0)
				$cat_trace[] = $arr['parent_id'];
			else
				$stop = true;
		}

		$cat_trace = implode('_', array_reverse($cat_trace));
             
		$link = $this->url->link('product/product', 'path=' . $cat_trace . '&product_id=' . $product_info['product_id']);
	}
	else {
		$link = $this->url->link('product/product', 'product_id=' . $product_info['product_id']);
	}				
	// end hack				
				
	if ($product_info) {
.......
Thank you, VettelS!

New member

Posts

Joined
Sat Apr 18, 2015 3:59 am
Who is online

Users browsing this forum: Baidu [Spider] and 62 guests