How to add a Decorator to catalog detail bought-together and suggest subparts

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!
boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

How to add a Decorator to catalog detail bought-together and suggest subparts

Post by boettner » 11 Jan 2022, 15:10

Hi all,

I would like to add my Decorator to the catalog detail bought-together and suggest subparts but it seems there's no configuration option to do so.

My goal is price manipulation and it already works in the basket, the checkout and the catalog in general. I also have a Price Rule available but that doesn't affect these subparts either.

Do I have any other chance?

Thanks
Robert.

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

Re: How to add a Decorator to catalog detail bought-together and suggest subparts

Post by aimeos » 12 Jan 2022, 08:51

There's no way to add a decorator for that parts in the templates because they are not provided by an own subpart.

The price rules should affect all product prices, regardless where they are used. Unfortunately, this isn't the case for related products yet because only the price of the main product is modified:
https://github.com/aimeos/aimeos-core/b ... hp#L73-L78

Can you create a PR that loops over the referenced products and applies the rules too?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: How to add a Decorator to catalog detail bought-together and suggest subparts

Post by boettner » 12 Jan 2022, 13:50

Hi and thanks once again for pointing me in the right direction.

Did it like so:

Code: Select all

if ( ! ($boughTogetherProducts = $product->getRefItems('product', null, 'bought-together'))->isEmpty()) {
	foreach ($boughTogetherProducts->getRefItems('price') as $price) {
		$taxrate = 19;
		/** @var \Aimeos\MShop\Price\Item\Standard $price */
		$price->setTaxRate($taxrate);
		$price->setValue($price->getValue()->first() * (1 + $taxrate / 100));
	}
}
$taxrate is of course a dynamic value here. Simplified it for the post.

Post Reply