Skip to content

Instantly share code, notes, and snippets.

@kpodemski
Created August 28, 2020 11:25
Show Gist options
  • Save kpodemski/690c24e28104f663d2ebe270c3581af8 to your computer and use it in GitHub Desktop.
Save kpodemski/690c24e28104f663d2ebe270c3581af8 to your computer and use it in GitHub Desktop.
PrestaShop - add your own variable to whitelist
<?php
class ExtraFieldInWhitelist extends Module
{
public function __construct()
{
$this->name = 'extrafieldinwhitelist';
$this->tab = 'front_office_features';
$this->version = '1';
$this->author = 'Krystian Podemski';
$this->bootstrap = true;
parent::__construct();
$this->displayName = 'Extra whitelisted field for Front-Office';
$this->description = 'Allow to use extra fields in ProductPresenter';
}
public function install()
{
if (!parent::install() || !$this->registerHook('actionFrontControllerAfterInit')) {
return false;
}
return true;
}
public function hookActionFrontControllerAfterInit()
{
$this->context->controller->get('prestashop.core.filter.front_end_object.product')->whitelist(['test_field']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment