I am trying to override/rewrite Magento\Fedex\Model\Source\Generic by using preference but to no avail.
Is there some other way that is used to override source models in Magento 2?
You can do it via plugin. First of all you must create di.xml
<config>
<type name="Magento\Fedex\Model\Source\Generic">
<plugin name="your_plugin_name" type="YourVendor\YourModule\Plugin\GenericPlugin" sortOrder="10" />
</type>
</config>
Then you must create GenericPlugin.php and use after method.
namespace YourVendor\YourModule\Plugin;
class GenericPlugin
{
public function afterToOptionArray(\Magento\Fedex\Model\Source\Generic $subject, $result)
{
// here you change the result
return $anotherResult;
}
}
More information here.