Price display on filtering

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Doggiefield
Posts: 18
Joined: 13 May 2020, 13:07

Price display on filtering

Post by Doggiefield » 25 May 2020, 15:57

Hi
We are using Aimeos for Laravel 2019.04
I hope you can help me out with the following challenge that we have:

Our selection product can have about 70 subproducts (based on a the combinations of length, width and softness)
some of the subproducts have different prices. (price added in the subproduct)
Selection product - no width, length or softness is set - Price is set to €200,-
Subproduct 1 - width = 40 / length = 80 / softness = extra soft - No price set (so uses section product price)
Subproduct 2 - width = 60 / length = 80 / softness = extra soft - Price € 240,-
Subproduct 3 - width = 60 / length = 90 / softness = extra soft - Price € 250,-
subproduct 4 - width = 70 / length = 80 / softness = hard - Price € 280,-
subproduct 5 - width = 70 / length = 90 / softness = extra soft- Price € 280,-

I try to achieve the following without any luck:
When I use the product filter on the frontend and I filter on product width=60 then the price of the selection product € 200,- is still shown. But in reality the price for a product with width=60 has is minimum € 240,-

We where hoping to get the following result:
1) when filtered on width=60 (width=60 has multiple product with different prices, so show lowest price)
then show price "from € 240,-"
2) when fitered on width=70 (width=60 has multiple product but the prices are the same, so show price)
then show "€ 280"
3) when filtered on softness=hard
then show "€ 280"
4) when filtered on softness is extra soft
then show "from € 200"

I hope you can help us to achieve this.

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

Re: Price display on filtering

Post by aimeos » 27 May 2020, 08:28

That's not possible out of the box because in the list view, only the selection price is shown with "from €200".

To achieve what you want, the list view needs to load the selection articles and their attributes too using https://aimeos.org/docs/Configuration/C ... ts/domains:

Code: Select all

'client' => [
	'html' => [
		'catalog' => [
			'lists' => [
				'domains' => ['media', 'price', 'text', 'attribute', 'product']
			]
		]
	]
]
Then, you have to implement your own algorithm in the catalog/lists/item-body-* template to filter the articles with the passed attribute ID:

Code: Select all

foreach( $product->getRefItems( 'product', null, 'default' ) as $articles ) {
	foreach( $articles as $article ) {
		if( $article->getListItem( 'attribute', 'variant', $this->param( 'f_attrid', [] ) ) {
			$list[] = current( $article->getRefItems( 'price', 'default', 'default' ) );
		}
	}
}
$price = null;
foreach( array_filter( $list ) as $priceItem ) {
	if( $price === null || $priceItem->getValue() < $price ) {
		$price = $priceItem->getValue();
	}
}
Something like that, I've not tested it but it should give you an impression what you have to do.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Doggiefield
Posts: 18
Joined: 13 May 2020, 13:07

Re: Price display on filtering

Post by Doggiefield » 27 May 2020, 12:42

Thanks a lot, we will give it a try.

Doggiefield
Posts: 18
Joined: 13 May 2020, 13:07

Re: Price display on filtering

Post by Doggiefield » 13 Jun 2020, 09:42

Thank you for the advice, this has helped a lot. We have got this working now.
Now we only have to apply this on the product detail page as well.

Post Reply