namespace My\Nosto\Observer\Person;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Nosto\Object\AbstractPerson;
use Nosto\Object\ModelFilter;
use Nosto\Tagging\Model\ElementFilter;
class Load implements ObserverInterface
* NOTE! You must inject the classes / services required to determinate
* the marketing permission consent
public function __construct()
* Observer for "nosto_person_load_after" event
* @param Observer $observer
public function execute(Observer $observer)
/* @var ModelFilter $modelFilter */
$modelFilter = $observer->getData('modelFilter');
// Note that you can disable completely person data processing
// $modelFilter->setValid(false);
/* @var AbstractPerson $person */
$person = $observer->getData('person');
if ($modelFilter instanceof ModelFilter
&& $person instanceof AbstractPerson) {
$person->setMarketingPermission(
$this->hasMarketingPermissions($person)
* Custom marketing permission detection
* @param AbstractPerson $person
private function hasMarketingPermissions(AbstractPerson $person)
if ($person->getEmail()) {
// Do your extra validation here
return $person->getMarketingPermission();