[Solved] How can a product's category's "css-class" attribute be used in the basket?

Questions around the TYPO3 integration and plugins
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!
rowild

[Solved] How can a product's category's "css-class" attribute be used in the basket?

Post by rowild » 04 Nov 2020, 20:14

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:

Code: Select all

<?php foreach( $this->summaryBasket->getProducts() as $position => $product ) ... : ?>
  <?php $prodId = $product->getId(); ?>
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!
Last edited by rowild on 09 Nov 2020, 07:20, edited 1 time in total.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: How can a product's category's "css-class" attribute be used in the basket?

Post by aimeos » 07 Nov 2020, 08:26

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, Image give us a star

rowild

Re: How can a product's category's "css-class" attribute be used in the basket?

Post by rowild » 09 Nov 2020, 07:18

That works great. Thank you!

Post Reply