Access data in a variant?


#1

I have an “objects with metadata” in a class and when one of the objects is a variant, it doesn’t readily access the data as when it isn’t a variant:

image

Not a variant:
image

Variant:
image

Notice the ComponentType shows in the first screenshot but not the second. For the variant, ComponentType is held in the parent. I’m hoping I don’t have to access the data differently if it is a variant or not?


#2

So, once again… I figured out my own issue. I wasn’t calling the getter but just accessing the property.
{% for comp in packaging.getPackageBOMComponents %}
{% set comp_obj = comp.getObject %}

{{ comp_obj.getComponentType }}


#3

that changed with Pimcore 5.5 -> they made all properties protected and Twig is quite good in finding the getter for a property. So, with Pimcore 5.5, you can start to use {comp_obj.componentType} and it calls get getComponentType