'Shopware 5 - Looping through all attributes

Hello i need some help with shopware. My question is probably pretty basic but i cannot get it done. I want to print out attributes from an article. In shopware documentation they call them {$sArticle.attr1} till {$sArticle.attr20} but they can also have different names so i cannot refer directly to the name and instead i want only a few attributes to be printed.

so far i know that all attributes are stored in the s_articles_attributes database table and i only want to print out those columns when the column name containes='artikelattribut_'

The code is going to be implemented in a table from frontend/detail/tabs --> description.tpl

the actual table already uses the $sArticle.sProperties and the code looks the following:

{if $sArticle.sProperties}
            <div class="product--properties panel has--border">
                <table class="product--properties-table">
                    {foreach $sArticle.sProperties as $sProperty}
                        <tr class="product--properties-row">
                            {* Property label *}
                            {block name='frontend_detail_description_properties_label'}
                                <td class="product--properties-label is--bold">{$sProperty.name|escape}:</td>
                            {/block}

                            {* Property content *}
                            {block name='frontend_detail_description_properties_content'}
                                <td class="product--properties-value">{$sProperty.value|escape}</td>
                            {/block}
                        </tr>
                    {/foreach}


</table>
</div>
{/if}

The thing is that $sArticle.sProperties and {$sArticle.attr1} till {$sArticle.attr20} are different. All i want is a second {foreach} that loops threw all article attributes maybe the idea is getting clear with that:

{foreach $sArticle.attr FROM s_articles_attributes WHERE name contains='artikelattribut_'}

I hope somebody understands my problem. Thankfull for any advice. Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source