Including list of categories as subpart of products-default
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 1
- Joined: 27 Mar 2017, 05:00
Including list of categories as subpart of products-default
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,
client\html\templates\common\partials\products-default.php
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.
client\html\templates\common\partials\products-default.php
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.
Re: Including list of categories as subpart of products-defa
In principle, it's the same as described here: post4084.html#p4071
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:
The last step is to create a product ID -> catalog Item mapping you can hand over to the views.
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( '==', 'catalog.id', <catids> ) ) );
$search->setSlice( 0, 0x7fffffff );
$catalogItems = $catalogManager->searchItems( $search );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star