listing categories
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!
- mahammadareef
- Posts: 54
- Joined: 14 Oct 2022, 11:54
listing categories
I want to list out 20 categories on the home page (in the shop by category section) - based on the option value given in categories - how to achieve this -explain to me with steps
and what is the exact use of option + value options available in the catalog adding part
and what is the exact use of option + value options available in the catalog adding part
Re: listing categories
The option/value pairs are just configuration values which can be stored in each category and which can be used e.g. in the template to enable the CSS based megamenu. But you can't filter for those values as they are stored as JSON encoded string in the "config" column of the mshop_catalog table.
If you you explicitly want to filter the categories in the database by a custom value, you could add a manager decorator adding a new column to the mshop_catalog table:
https://aimeos.org/docs/latest/models/extend-managers/
If you you explicitly want to filter the categories in the database by a custom value, you could add a manager decorator adding a new column to the mshop_catalog table:
https://aimeos.org/docs/latest/models/extend-managers/
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
- mahammadareef
- Posts: 54
- Joined: 14 Oct 2022, 11:54
Re: listing categories
okay assume i added one coloumn is_branded_category , how to write filter option , if posssible please show it in this data() function of my component (here it retrives all the category tree )
Code: Select all
public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface
{
$tree = \Aimeos\Controller\Frontend::create( $this->context(), 'catalog' )->uses( $this->domains() )
->getTree( \Aimeos\Controller\Frontend\Catalog\Iface::LIST );
$products = \Aimeos\Controller\Frontend::create( $this->context(), 'product' )->uses( $this->domains() )
->category( $tree->getChildren()->getId()->all(), 'promotion' )->search();
$this->addMetaItemCatalog( $tree, $expire, $tags );
$this->addMetaItems( $products, $expire, $tags, ['product'] );
$view->homeTree = $tree;
// $view->homeStockUrl = $this->stockUrl( $products );
return parent::data( $view, $tags, $expire );
}
Re: listing categories
The catalog controller has a compare() method where you can add custom conditions:
https://github.com/aimeos/ai-controller ... hp#L26-L35
In your example:
https://github.com/aimeos/ai-controller ... hp#L26-L35
In your example:
Code: Select all
$cntl = \Aimeos\Controller\Frontend::create( $this->context(), 'catalog' );
$categories = $cntl->compare( '==', 'is_branded_category', 1 )->slice( 0, 20 )->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