magefan / module-geoip

Detect Country by IP in Magento 2
Open Software License 3.0
52 stars 10 forks source link

Fatal error addFielToFilter() #2

Closed Axel29 closed 6 years ago

Axel29 commented 6 years ago

Hi,

If php-geoip is not installed, there's a fallback to the database tables but the code breaks in this case.

Here's the error:

Fatal error: Uncaught Error: Call to undefined method Magefan\GeoIp\Model\ResourceModel\IpToCountry\Collection::addFielToFilter() in /var/www/vendor/magefan/module-geoip/Model/IpToCountryRepository.php:56 Stack trace: #0 /var/www/vendor/magefan/module-geoip/Model/IpToCountryRepository.php(74): Magefan\GeoIp\Model\IpToCountryRepository->getCountryCode('127.0.0.1') #1 /var/www/app/code/Clrz/GeoIp/Helper/Popin.php(193): Magefan\GeoIp\Model\IpToCountryRepository->getVisitorCountryCode() #2 /var/www/app/code/Clrz/GeoIp/view/frontend/templates/switch/languages.phtml(35): Clrz\GeoIp\Helper\Popin->getUserCountry() #3 /var/www/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/projec...') #4 /var/www/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Clrz\GeoIP\Block\Store\Switcher\Interceptor), '/var/www/projec...', Array) #5 /var/www/generated/code/Clrz/GeoIP/Block/Store/Switcher/Interce in /var/www/vendor/magefan/module-geoip/Model/IpToCountryRepository.php on line 56

Axel29 commented 6 years ago

EDIT : Found the issue (took me some time to really READ the error ^^")

You used "addFielToFilter", there's a "d" missing for "addFieldToFilter" for both lines 56 and 57.

magefan commented 6 years ago

Thank you. Making correction.

magefan commented 6 years ago

The fix was made. Please try to update the extension to the version 2.0.1

Axel29 commented 6 years ago

That was fast :) Thanks, it works perfectly even without php-geoip now!