get hierarchical categories of product in for breadcrumb?

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Ahmad
Posts: 72
Joined: 05 Jul 2017, 15:19

get hierarchical categories of product in for breadcrumb?

Post by Ahmad » 12 Dec 2017, 15:44

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?

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: get hierarchical categories of product in for breadcrumb

Post by aimeos » 13 Dec 2017, 00:08

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Ahmad
Posts: 72
Joined: 05 Jul 2017, 15:19

Re: get hierarchical categories of product in for breadcrumb

Post by Ahmad » 13 Dec 2017, 15:07

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?

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: get hierarchical categories of product in for breadcrumb

Post by aimeos » 13 Dec 2017, 23:26

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply