I am trying to create a country dropdown for a custom product attribute.
This is the error message:
Error: Call to undefined method
MagentoDirectoryModelConfigSourceCountry::setAttribute() in
/var/www/html/vendor/magento/module-eav/Model/Entity/Attribute/AbstractAttribute.php:652
This is my install:
$eavSetup->addAttribute(
MagentoCatalogModelProduct::ENTITY,
'countries',
[
'group' => 'Countries',
'type' => 'text',
'frontend' => '',
'label' => 'Countries',
'input' => 'multiselect',
'class' => '',
'source' => 'MagentoDirectoryModelConfigSourceCountry',
'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => false,
'unique' => false,
'apply_to' => 'configurable',
]
);
The issue is with the source:
'source' => 'MagentoDirectoryModelConfigSourceCountry',