cancel
Showing results for 
Search instead for 
Did you mean: 

Error when overriding with plugin

Error when overriding with plugin

Hello,


I have created a module and a plugin for overriding getAllowedCountries in \Magento\Directory\Model\AllowedCountries.

But I get an error when doing this. I can see that Magento generates Interceptor.php files in the "generated" folder. It looks like Magento is using plugins in the core code for overriding some functions.

 

Could that be the problem?

"Select from existing customer addresses: Error: Object of class Magento\Directory\Model\AllowedCountries\Interceptor could not be converted to string in C:\Workspace\lbaltimeters\vendor\magento\framework\App\Config.php:74 Stack trace: #0 C:\Workspace\lbaltimeters\generated\code\Magento\Framework\App\Config\Interceptor.php(23): Magento\Framework\App\Config->getValue('general/country...', Object(Magento\Directory\Model\AllowedCountries\Interceptor), 'store') #1 C:\Workspace\lbaltimeters\app\code\LbAltimeters\AllowAllCountries\Plugin\AllowedCountriesPlugin.php(124): Magento\Framework\App\Config\Interceptor->getValue('general/country...', Object(Magento\Directory\Model\AllowedCountries\Interceptor), 'store') #2 C:\Workspace\lbaltimeters\app\code\LbAltimeters\AllowAllCountries\Plugin\AllowedCountriesPlugin.php(68): LbAltimeters\AllowAllCountries\Plugin\AllowedCountriesPlugin->getCountriesFromConfig(Object(Magento\Directory\Model\AllowedCountries\Interceptor), 'store') #3 C:\Workspace\lbaltimeters\vendor\magento\framework\Interception\Interceptor.php(121):"