Page 1 of 1

get hierarchical categories of product in for breadcrumb?

Posted: 12 Dec 2017, 15:44
by Ahmad
for example:
i have categories home > cat-1 > cat-2 > cat-3
i set cat-3 for my product category
i want 2 thing?
1- show my product even when i was in cat-2 or cat-1 or home in catalog/list page because these categories are parents of cat-3 and when product is in cat-3 so it falls into the category of the parent?
2- when i was in product detail page (catalog/detail), i want to show hierarchical categories of product for breadcrumb, so my breadcrumb gets like this: Home > Cat-1 > Cat-2 > Cat-3

How can I do those?

Re: get hierarchical categories of product in for breadcrumb

Posted: 13 Dec 2017, 00:08
by aimeos
Ahmad wrote: 1- show my product even when i was in cat-2 or cat-1 or home in catalog/list page because these categories are parents of cat-3 and when product is in cat-3 so it falls into the category of the parent?
You can adapt the behavior using this config: https://aimeos.org/docs/Configuration/C ... sts/levels
Ahmad wrote: 2- when i was in product detail page (catalog/detail), i want to show hierarchical categories of product for breadcrumb, so my breadcrumb gets like this: Home > Cat-1 > Cat-2 > Cat-3
The catalog stage component renders the breadcrumb of the category you are coming from automatically.

Re: get hierarchical categories of product in for breadcrumb

Posted: 13 Dec 2017, 15:07
by Ahmad
aimeos wrote:
The catalog stage component renders the breadcrumb of the category you are coming from automatically.
ok, if i want to render the breadcrumb from the product deepest category to home without considering category that customer coming from, like this:
in product detail page: Home > cat-1 > cat-2 > cat-3 > product-name
in cat-3 page: Home > cat-1 > cat-2 > cat-3

what should I do?

Re: get hierarchical categories of product in for breadcrumb

Posted: 13 Dec 2017, 23:26
by aimeos
On the list page, this is already the case. There, the current category up to the root category is printed (You are here: Home / cat 1):
http://laravel.demo.aimeos.org/perf/en/ ... &f_catid=3

On the detail page, the category the user is coming from is used as current category for two reasons:
- The users normally want to go back to where they are coming from and not to what you think is the main category for this product
- Products can be assigend to multiple categories and then you have to choose in some way which is the "right" one

If you want to show the breadcrumb from of your main category nevertheless, you can search for the categories the product is assigned to using the catalog lists manager (using catalog.lists.refid). Choose one of them and use the getPath() method of the catalog manager to fetch the catalog items along the root line:
https://github.com/aimeos/ai-client-htm ... d.php#L457