I have a multidimensional array where some objects exist and others do not. I keep getting
The "code" method for the "stdClass" object does not exist in ... ?
The code I use in my template is:
{% for item in items %} <p>{% if item.product.code %}{{ item.product.code }}{% endif %}</p> {% endfor %}
Some products do not have this code, and, unfortunately, this data structure is provided through the feed, so I canโt change it.
When I looked at the Twig documentation, I realized that if the object or method was not there, would it just return null?
symfony twig
Adam Stacey Aug 11 '11 at 23:17 2011-08-11 23:17
source share