Jump to content

Displaying attributes of related products in groups


Recommended Posts

Hi, I'm writing a module in which I display products related to a specific feature. It looks something like this: 

in this case I have 2 related products (these are batteries) assigned to my product X with different capacities.

image.png.7eb516c1b7da13795dc21a0fbb0a08f9.png

another example which is more complicated as I have 32 products related to different colors and sizes (2 sizes + 16 colors)

image.png.b5e06f5fb51e4863f59658095e9bdc9d.png

I would like to combine the same values so that they do not duplicate each other. e.g:

image.png.5b84aa431a1fc4cba71aa4041da08927.png

can you help me how to do it?

 

{foreach from=$accessories item=accessory name=accessories_list} 
            		{assign var='accessoryLink' value=$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)}
            		{if $accessory.features}
						{foreach from=$accessory.features item=feature}
							{if $feature.id_feature == $id_cechy1 && isset($feature.value)}
								<a href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{$accessory.name|escape:'htmlall':'UTF-8'}" class="variant2 product_image">
									<li class="btn btn-default">
										{if $show_img == 1}
											<img src="{$link->getImageLink($accessory.link_rewrite, $accessory.id_image, 'home_default')|escape:'html'}" alt="{$accessory.name|escape:'htmlall':'UTF-8'}" style="height:40px; float:left;" />
										{/if}
										<span class="editable" style="margin: 5px;">
										{$feature.value|escape:'htmlall':'UTF-8'}
										</span>
										<div class="price">
											{if $show_price == 1}
										 		{number_format($accessory.price, 2, ',', '')}
											{/if}
										</div>
									</li>
								</a>
							{/if}
						{/foreach}
					{/if}
				{/foreach}

 

 

Edited by Sasni
update (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...