Smarty Call of php class function results in internal server error

I try to call get() function from Shopware\Bundle\StoreFrontBundle\Struct\Attribute in order to access storage variables but it does not work, 

{$supplier.attributes.core->toArray()|var_dump}

{$supplier.attributes.core->get(„external_link“)|var_dump}

none of the above functions work, however they are public functions, what is the problem here?

The get() will cause an exception, when there is no entry for this specific supplier in the s_articles_supplier_attributes table. You should add an IF-Statement like this:

{if $supplier.attributes.core}
{$supplier.attributes.core->get('attribute')}
{/if}

There might be some old installations that are missing the entries, because this functionality was added with 5.2. You cann add an entry for every supplier via sql to fix this.

1 „Gefällt mir“

[@Moritz Naczenski](http://forum.shopware.com/profile/14574/Moritz Naczenski “Moritz Naczenski”)‍ Thank you very much, I’ve added the if statement and it worked, so that means if you call a function on null it will throw an exception right?