# Display variants in the listing

**URL:** <https://forum.shopware.com/t/display-variants-in-the-listing/52453>\
**Category:** International (English Only)\
**Tags:** programming\
**Created:** [18. April 2018 um 16:18 UTC](https://forum.shopware.com/t/display-variants-in-the-listing/52453 "2018-04-18T16:18:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![roberto](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@roberto](https://forum.shopware.com/u/roberto)\
**Post date:** [18. April 2018 um 16:18 UTC](https://forum.shopware.com/t/display-variants-in-the-listing/52453/1 "2018-04-18T16:18:15Z")

</div>

Hello,

I’ve seen there’s a block called `frontend_listing_box_variant_description` in file `themes/Frontend/Bare/frontend/listing/product-box/box-basic.tpl` that seems to be prepared to display the product variant in the listing, but I can’t make it work and there’s no information about this on any guide (at least one I can find)

```
{* Variant description *}
{block name='frontend_listing_box_variant_description'}
	{if $sArticle.attributes.swagVariantConfiguration}
		
			
				{foreach $sArticle.attributes.swagVariantConfiguration->get('value') as $group}
					
						{$group.groupName}: {$group.optionName} {if !$group@last}|{/if}
					
				{/foreach}
			
		
	{/if}
{/block}

```

Anyone have this working?

---

<div class="post-metadata">

**Author:** ![roberto](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@roberto](https://forum.shopware.com/u/roberto)\
**Post date:** [19. April 2018 um 15:37 UTC](https://forum.shopware.com/t/display-variants-in-the-listing/52453/2 "2018-04-19T15:37:45Z")

</div>

Still trying to achieve this but from a different approach. Now I’m able to display the variants in the listing but I modified the sArticles file, now I’m trying to extend that file to not change core files. I’m using the getListing function to retrieve the variants and return them into the sArticles array.

I’ve created a plugin and subscribed to Enlight\_Controller\_Action\_PostDispatchSecure\_Frontend\_Listing but now I don’t know how to get the current sArticles array to modify it as I did on the getListing function.

Someone to point me in the right direction?

Thanks!

---

<div class="post-metadata">

**Author:** ![odessite](https://avatars.discourse-cdn.com/v4/letter/o/f05b48/32.png) [@odessite](https://forum.shopware.com/u/odessite)\
**Post date:** [19. April 2018 um 15:55 UTC](https://forum.shopware.com/t/display-variants-in-the-listing/52453/3 "2018-04-19T15:55:56Z")

</div>

Hello Roberto

```
**'Enlight\_Controller\_Action\_PostDispatch\_Frontend\_Listing'** =\> **'onPostDispatchListing'** , **'Enlight\_Controller\_Action\_PostDispatch\_Frontend\_Search'** =\> **'onPostDispatchSearch'** ,

_/\*\*_ _\*_ _@param_ _\Enlight\_Event\_EventArgs $args_ _\*/_ **public function** onPostDispatchListing(\Enlight\_Controller\_ActionEventArgs $args) { $request = $args-\>getSubject()-\>Request(); $action = $args-\>getSubject(); $response = $action-\>Response(); $view = $action-\>View(); **if** (!$request-\>isDispatched() || $response-\>isException() || !$view-\>hasTemplate() ) { **return false** ; } $assignData = $view-\>getAssign( **'sArticles'** ); _print\_r_($assignData); **exit** ; } _/\*\*_ _\*_ _@param_ _\Enlight\_Event\_EventArgs $args_ _\*/_ **public function** onPostDispatchSearch(\Enlight\_Controller\_ActionEventArgs $args) { $request = $args-\>getSubject()-\>Request(); $action = $args-\>getSubject(); $response = $action-\>Response(); $view = $action-\>View(); **if** (!$request-\>isDispatched() || $response-\>isException() || !$view-\>hasTemplate() ) { **return false** ; } $assignData = $view-\>getAssign( **'sSearchResults'** ); _print\_r_($assignData); **exit** ; }

```

For widgets or emotions you need to extend ` **Enlight\_Controller\_Action\_PostDispatch\_Widgets** `, in case you want to extend similar/related articles on detail page, you need extend ` **Enlight\_Controller\_Action\_PostDispatch\_Frontend\_Detail** ` and get ` **sArticle** `[’ **sRelatedArticles** ’]/[’ **sSimilarArticles** ’]

I hope my answer will help you.

---

<div class="post-metadata">

**Author:** ![roberto](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@roberto](https://forum.shopware.com/u/roberto)\
**Post date:** [20. April 2018 um 11:38 UTC](https://forum.shopware.com/t/display-variants-in-the-listing/52453/4 "2018-04-20T11:38:39Z")

</div>

This is absolutely brilliant! Thank you very much @odessite‍ this helped me a lot to achieve what I was trying to do, I owe you a beer at least!

---

<div class="post-metadata">

**Author:** ![Pfeifakopf](https://avatars.discourse-cdn.com/v4/letter/p/8e7dd6/32.png) [@Pfeifakopf](https://forum.shopware.com/u/Pfeifakopf)\
**Post date:** [14. August 2018 um 13:23 UTC](https://forum.shopware.com/t/display-variants-in-the-listing/52453/5 "2018-08-14T13:23:33Z")

</div>

Hello, could someone explain what to do from the beginning?  
I’m sorry, but it’s hard to understand, if you are new with shopware.  
Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Sition](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Sition](https://forum.shopware.com/u/Sition)\
**Post date:** [20. August 2018 um 23:06 UTC](https://forum.shopware.com/t/display-variants-in-the-listing/52453/6 "2018-08-20T23:06:00Z")

</div>

I would advise to extend the productlisting service to resolve the issue on a higher level.

The additional variant data can be stored as a parameter for the sArticle which is available in the tpl-file.

---

<div class="post-metadata">

**Author:** ![yodorada](https://avatars.discourse-cdn.com/v4/letter/y/90ced4/32.png) [@yodorada](https://forum.shopware.com/u/yodorada)\
**Post date:** [3. September 2018 um 15:12 UTC](https://forum.shopware.com/t/display-variants-in-the-listing/52453/7 "2018-09-03T15:12:57Z")

</div>

Hi Sition,  
can you give a quick hint on how to accomplish extending the service.  
I am stuck in developing a proper extension… I implemented the ListProductServiceInterface and the ContextServiceInterface and managed to retrieve the article data, but now I don’t know how to query all according variants…

Can you help out?  
Thanks a lot!

> [@Sition schrieb:](https://forum.shopware.com/profile/25235/Sition "Sition")
> 
> I would advise to extend the productlisting service to resolve the issue on a higher level.
> 
> The additional variant data can be stored as a parameter for the sArticle which is available in the tpl-file.
