Adding current product category in product detail view.

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
woo13244
Posts: 10
Joined: 02 Aug 2018, 21:49

Adding current product category in product detail view.

Post by woo13244 » 13 Aug 2018, 15:37

Is there a quick and easy way to add the product category in my detail view? Specifically in the prod_name, I have found the " $this->detailProductItem variable does not hold any reference to its category. When trying to add the current category in the Detail\Standard.php controller I tried to follow the example fround in the list\Standard.php but it seems like it relies on the search function to find the current category. Any tips on finding the product category maybe by prod_id since i have access to that already in the detail controller.......maybe have to create my own model??

Thanks for the help,
Woo

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

Re: Adding current product category in product detail view.

Post by aimeos » 15 Aug 2018, 15:52

You can use the catalog manager to find all categories your product is listed in:

Code: Select all

$catalogManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' );

$search = $catalogManager->createSearch();
$expr = [
    $search->compare( '==', 'catalog.lists.refid', $prodId ),
    $search->compare( '==', 'catalog.lists.domain', 'product' ),
    $search->compare( '>', 'catalog.status', 0 ),
];
$search->setConditions( $search->combine( '&&', $expr ) );

$catItems = $catalogManager->searchItems( $search );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply