Catalog Manager - Get child catalog items ?
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Catalog Manager - Get child catalog items ?
Laravel framework version: 9.47.0
Aimeos Laravel version: ~2022.10
PHP Version: 8.2.1
Environment: Linux
Hello,
What's the best way to get the child catalog items in Catalog Manager search results?
My code:
I want to be able to use getChildren() on each item inside $catalog_items, but the result is always empty.
Aimeos Laravel version: ~2022.10
PHP Version: 8.2.1
Environment: Linux
Hello,
What's the best way to get the child catalog items in Catalog Manager search results?
My code:
Code: Select all
$catalog_manager = \Aimeos\MShop::create( $this->context, 'catalog' );
$catalog_items = $catalog_manager->search( $catalog_filter ); // Catalog children missing here
Re: Catalog Manager - Get child catalog items ?
I came up with this, since the items have a catalog.parentid.
The function gets the catalog items which have a matching catalog.parentid.
The function gets the catalog items which have a matching catalog.parentid.
Code: Select all
$catalog_manager = \Aimeos\MShop::create( $this->context, 'catalog' );
$catalog_items = $catalog_manager->search( $catalog_filter );
$catalog_item_children = getCatalogChildren( $catalog_items, $catalog_items->first() );
function getCatalogChildren( $catalog_items, $catalog_item )
{
return $catalog_items->filter( function($value, $key) use($catalog_item) {
return $value->getParentId() == $catalog_item->getId();
} );
}
Re: Catalog Manager - Get child catalog items ?
The getTree() method is the only one that fetches the children and returns a tree structure:
https://github.com/aimeos/aimeos-core/b ... hp#L33-L43
Use the frontend controller if you need to fetch categories for the frontend:
https://github.com/aimeos/ai-controller ... hp#L73-L80
https://github.com/aimeos/aimeos-core/b ... hp#L33-L43
Use the frontend controller if you need to fetch categories for the frontend:
https://github.com/aimeos/ai-controller ... hp#L73-L80
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