category name in the catalog detail page

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!
User avatar
GülsümAkça
Posts: 57
Joined: 20 Nov 2020, 13:30

category name in the catalog detail page

Post by GülsümAkça » 01 Mar 2022, 16:29

is it possible to get the category id or category name in the catalog/detail/body-standard.php?
thank you

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

Re: category name in the catalog detail page

Post by aimeos » 03 Mar 2022, 08:57

Yes, if you add this to the configuration documented here:
https://aimeos.org/docs/2021.x/config/c ... l/#domains

Code: Select all

'catalog' => [
	'text',
]
Then, you can use in your template:

Code: Select all

<?= $this->detailProductItem->getCategoryItems()->getName()->first() =>
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
GülsümAkça
Posts: 57
Joined: 20 Nov 2020, 13:30

Re: category name in the catalog detail page

Post by GülsümAkça » 06 Mar 2022, 10:18

is this working in 2020.x version?
Attachments
Screenshot_46.png
Screenshot_46.png (26.11 KiB) Viewed 6632 times

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

Re: category name in the catalog detail page

Post by aimeos » 06 Mar 2022, 14:12

Sorry, the method is named "getCatalogItems()":
https://github.com/aimeos/aimeos-core/b ... hp#L27-L32

Fixed that in the initial reply.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
PedroLópezAndradas
Posts: 22
Joined: 16 Jan 2023, 11:30

Re: category name in the catalog detail page

Post by PedroLópezAndradas » 01 Feb 2023, 08:33

How this works on 2022.x?

Thanks

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

Re: category name in the catalog detail page

Post by aimeos » 02 Feb 2023, 13:35

Category references move from mshop_catalog_list to mshop_product_list table and you can now use:

Code: Select all

$product->getRefItems( 'catalog' );
Make sure, the categories are fetched by the manager with the correct domains.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
loeffe1
Posts: 52
Joined: 21 Feb 2020, 10:33

Re: category name in the catalog detail page

Post by loeffe1 » 23 May 2023, 11:16

This seems to be bugged when a product is added in several categories. The path fetched by $this->detailProductItem->getRefItems( 'catalog' ) is incorrect.

Also I see no way of getting the actual category the product was accessed through and translated labels of the categories.

User avatar
loeffe1
Posts: 52
Joined: 21 Feb 2020, 10:33

Re: category name in the catalog detail page

Post by loeffe1 » 24 May 2023, 10:26

I am now passing the categoryId the product was actually opened from to the detail view and am using it in my Decorator to work my way back through the category tree to get an actual, existing breadcrumb path and not just some random chaos. This was the only solution I could think of that fixes this problem.

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

Re: category name in the catalog detail page

Post by aimeos » 24 May 2023, 10:36

Code: Select all

$this->detailProductItem->getRefItems( 'catalog' )
This doesn't return any category path, just the categories the product is assigned to.

Only the catalog/stage component fetches the category path for creating the breadcrumb:
https://github.com/aimeos/ai-client-htm ... #L183-L240
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply