[Solved] How can a product's category's "css-class" attribute be used in the basket?
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
[Solved] How can a product's category's "css-class" attribute be used in the basket?
Hi! Each category of the shop I am working on has its own color. That means that all products of the "green" category has a green border. The design requests that the color of the category a product belongs to should be displayed in the basket (where each product again has a border).
In "templates/common/summary/detail-standard.php" there is a foreach loop, within which I can get a product's id:
But I have no idea where to go from here. How to I get the product and its items (categories)?
The documentation says that a manager can be used almost anywhere to retrieve almost everything. But I have no idea, where a manager is created (obviously not in a view template, since $context is not available there) and what it needs. (It seems there is no tutorial available on "how to create a manager", which would be greatly welcomed!)
Any guidance would be most welcome! Thank you!
In "templates/common/summary/detail-standard.php" there is a foreach loop, within which I can get a product's id:
Code: Select all
<?php foreach( $this->summaryBasket->getProducts() as $position => $product ) ... : ?>
<?php $prodId = $product->getId(); ?>
The documentation says that a manager can be used almost anywhere to retrieve almost everything. But I have no idea, where a manager is created (obviously not in a view template, since $context is not available there) and what it needs. (It seems there is no tutorial available on "how to create a manager", which would be greatly welcomed!)
Any guidance would be most welcome! Thank you!
Last edited by rowild on 09 Nov 2020, 07:20, edited 1 time in total.
Re: How can a product's category's "css-class" attribute be used in the basket?
The easiest way would be to add a hidden attribute with the color code to each product (e.g. type "catcolor") in the admin backend. This hidden attribute will be automatically added to the basket product and can be retrieved using this in your loop:
Code: Select all
$product->getAttribute( 'catcolor', 'hidden' )
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
Re: How can a product's category's "css-class" attribute be used in the basket?
That works great. Thank you!