How to display breadcrumb for the current product category ?

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!
PiotrH
Posts: 4
Joined: 18 Jul 2023, 07:40

How to display breadcrumb for the current product category ?

Post by PiotrH » 18 Jul 2023, 07:56

Laravel v9.52.10 aimeos 2023.07 php 8.1.20 Linux

Hi

How to display breadcrumb for the current product category ? It always displaying "Back" link,on single product page, instead of the category link the product belongs.

[img]http://piotrh.net/aimeos.png[/img]

Many Thanks,

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

Re: How to display breadcrumb for the current product category ?

Post by aimeos » 20 Jul 2023, 09:01

If you hand over the category ID as f_catId=..., then the breadcrumb for that category will be shown. You can add the parameter in your own template which you've copied to your project-specific extension:
https://github.com/aimeos/ai-client-htm ... s.php#L158

To get the category ID use:

Code: Select all

$productItem->getRefItems( 'catalog' )->getId()->first()
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

PiotrH
Posts: 4
Joined: 18 Jul 2023, 07:40

Re: How to display breadcrumb for the current product category ?

Post by PiotrH » 20 Jul 2023, 10:10

Hi

Thank you for your reply.

I have changed the code as suggested:

$params = array_diff_key([
'd_name' => $productItem->getName('url'),
'd_prodid' => $productItem->getId(),
'd_pos' => $position !== null ? $position++ : '',
'f_catid' => $productItem->getRefItems( 'catalog' )->getId()->first()
], $detailFilter);

and my url looks like this: /pl/shop/shirt-cap/1?f_catid=1

Breadcrumbs have appeared, but also now an error appears instead of a catalog page menu with message: "A NON-RECOVERABLE ERROR OCCURED"

[img]http://piotrh.net/menu_error.png[/img]

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

Re: How to display breadcrumb for the current product category ?

Post by aimeos » 22 Jul 2023, 07:17

Please have a look into the Log panel of the admin backend for error details.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

PiotrH
Posts: 4
Joined: 18 Jul 2023, 07:40

Re: How to display breadcrumb for the current product category ?

Post by PiotrH » 24 Jul 2023, 06:43

Hi !

It looks like f_catid is not enough - f_name is also required.

Code: Select all

	
/shop/black-shirt-men/0?f_catid=1
Missing required parameter for [Route: aimeos_shop_tree] [URI: shop/f_name~f_catid/l_page?] [Missing parameter: f_name].
I changed my code to:

Code: Select all

$params = array_diff_key([
        'd_name'   => $productItem->getName('url'),
        'd_prodid' => $productItem->getId(),
        'd_pos'    => $position !== null ? $position++ : '',
        'f_catid'  => $productItem->getRefItems('catalog')->getId()->first(),
        'f_name'   => $productItem->getRefItems('catalog')->getName()->first()
    ], $detailFilter);
Now it works.

Post Reply