Get product category

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Get product category

Post by aimeos » 02 Apr 2021, 17:16

Use the methods of the item instead:

Code: Select all

$product->getCatalogItems();
$product->getStockItems();
Check the product item interface for reference:
https://github.com/aimeos/aimeos-core/b ... hp#L27-L47
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kdim95
Advanced
Posts: 195
Joined: 26 Aug 2022, 12:17

Re: Get product category

Post by kdim95 » 02 Sep 2022, 14:42

aimeos wrote: 02 Apr 2021, 17:16 Use the methods of the item instead:

Code: Select all

$product->getCatalogItems();
$product->getStockItems();
Check the product item interface for reference:
https://github.com/aimeos/aimeos-core/b ... hp#L27-L47
Laravel framework version: 9.26.1
Aimeos Laravel version: * 2022.07.2
PHP Version: 8.1.9
Environment: Linux

Hello,

I am trying to output the categories of the products in the following template:
templates/client/html/catalog/detail/body.php

I want them to show in the list of characteristics tab.
How should I go about doing this in my version of aimeos?

I have tried a few methods from this thread, like adding 'catalog' => ['text'] to the domains config, but I either end up with errors or the categories don't show up for the product. I expect the categories to be present somewhere in the $view when I dd($view) in the template.

The latest answer $product->getCatalogItems(); also shows this error in the logs:
Called unknown macro "getCatalogItems" on class "Aimeos\MShop\Product\Item\Standard"

Also the link provided leads to a 404 page.

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

Re: Get product category

Post by aimeos » 02 Sep 2022, 14:52

Since 2022.01, you can get the categories using:

Code: Select all

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

kdim95
Advanced
Posts: 195
Joined: 26 Aug 2022, 12:17

Re: Get product category

Post by kdim95 » 02 Sep 2022, 15:17

aimeos wrote: 02 Sep 2022, 14:52 Since 2022.01, you can get the categories using:

Code: Select all

$producItem->getRefItems( 'catalog' );
I think this works but should they be appearing under -node?
The other items, for example $mediaItems have them under #bdata.
How do I get them from inside the -node?
By the way, I noticed that I am posting in the wrong forum, I am working with Aimeos Laravel.

xJbCaF7.png
xJbCaF7.png (55.88 KiB) Viewed 3067 times

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

Re: Get product category

Post by aimeos » 05 Sep 2022, 06:27

The catalog items will be under "listRefItems" if there are any available and you have to load them together with the product by passing "catalog" as part of the second parameter to search(). Depending on the component you want to fetch the categories, you can add the "catalog" domain by configuration. For list and detail views, they are already fetched:
- https://aimeos.org/docs/2022.x/config/c ... s/#domains
- https://aimeos.org/docs/2022.x/config/c ... l/#domains
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply