I would like to display the result from Observer to every page, any way I can do it?
app/code/MyVendor/GeoIp/Observer/GeoObserver.php
<?php
namespace MyModuleGeoIpObserver;
use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
use MyModuleGeoIpHelperGeoLocation;
use MagentoFrameworkViewLayoutInterface;
class GeoObserver implements ObserverInterface {
public function __construct(
GeoLocation $helperGeoLocation,
LayoutInterface $layout
){
$this->helpGeoLocation = $helperGeoLocation;
$this->layout = $layout;
}
public function execute(Observer $observer)
{
$displaytext = $this->helpGeoLocation->getCountryCodeByIp();
$result = "<p> GEO: $displaytext </p>";
return $result;
}
}