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)
#4074 by chris.schloegel
27 Mar 2017, 05:29
I've been searching and searching and, I believe I've just confused myself. Before I hack something together I'd like a more elegant, upgrade-proof solution. What I am trying to do is essentially add a new subpart to Catalog\Lists\Items or, more specifically,

Endgame: This subpart would essentially output a div with the first category name as its' contents -- between the media and text subparts.

At this point I am figuring I should be returning the html via the subpart getBody method but I'm at a loss for how to actually get the categories. I could also easily accomplish this simply by overriding the products-default template but I'm not sure the best way to query and add the categories to the productItems so they'd be available to me there.

Any help with the best way to accomplish this would be greatly appreciated.
#4085 by aimeos
27 Mar 2017, 16:30
In principle, it's the same as described here:

The difference is that you need to get the categories for the used products, which is one more step then for retrieving associated items to attributes:
Code: Select all$listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
$listSearch = $listManager->createSearch( true );
$expr = [
    $listSearch->compare( '==', 'catalog.lists.refid', <prodids> ),
    $listSearch->compare( '==', 'catalog.lists.domain', 'product' ),
    $listSearch->compare( '==', 'catalog.lists.type.code', 'default' ),
$listSearch->setConditions( $listSearch->combine( '&&', $expr ) );
$listSearch->setSlice( 0, 0x7fffffff );
$listItems = $listManager->searchItems( $listSearch );

// collect catalog IDs with $listItem->getParentId()

$catalogManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' );
$search = $catalogManager->createSearch( true );
$search->setConditions( $search->compare( $search->compare( '==', '', <catids> ) ) );
$search->setSlice( 0, 0x7fffffff );
$catalogItems = $catalogManager->searchItems( $search );

The last step is to create a product ID -> catalog Item mapping you can hand over to the views.