I have created a product variant with 1 attribute (say “Subscription Plan” or
attribute_sub_plan) and 1 field (say “Number of Issues” or
field_num_issues). The attribute was for human readability while the field was an integer for internal use.
The attribute was added to the variation type when created, while the field was added to the variation type on the “Add field” button after creation. I can see both fields in the Product Variant interface.
I can easily get the attribute value like this:
$plan_name = $variation->getAttributeValue('attribute_sub_plan')->getName();
However, I cannot get the field value like I usually can with other entities:
$num_issues = $variation->get('field_num_issues')->value;
As a matter of fact, I cannot even get the field “field_num_issues”. It gives me this error:
InvalidArgumentException with message 'Field field_num_issues is unknown.'
Do you have any idea how I can get the value?