I am trying to create a country dropdown for a custom product attribute.
This is the error message:
Error: Call to undefined method Magento\Directory\Model\Config\Source\Country::setAttribute() in /var/www/html/vendor/magento/module-eav/Model/Entity/Attribute/AbstractAttribute.php:652
This is my install:
$eavSetup->addAttribute( \Magento\Catalog\Model\Product::ENTITY, 'countries', [ 'group' => 'Countries', 'type' => 'text', 'frontend' => '', 'label' => 'Countries', 'input' => 'multiselect', 'class' => '', 'source' => 'Magento\Directory\Model\Config\Source\Country', 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::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' => 'Magento\Directory\Model\Config\Source\Country' 