#prestashop #prestashop-1.7
#prestashop #prestashop-1.7
Вопрос:
Я создаю пользовательский модуль в Prestashop 1.7.X, где я хочу получить все сведения о пользователе, когда он регистрируется в магазине. Поэтому для этого я использую перехват actionCustomerAccountAdd. Но этот перехват не запускается в Prestashop 1.7.X. Когда я использую тот же перехват в prestashop 1.6.X, он работает без каких-либо проблем.
Вот мой пример кода
if (!defined('_PS_VERSION_')) {
exit;
}
class Hellouser extends Module
{
protected $config_form = false;
public function __construct()
{
$this->name = 'hellouser';
$this->tab = 'other';
$this->version = '1.0.0';
$this->author = 'test';
$this->need_instance = 0;
$this->module_key = '';
parent::__construct();
$this->bootstrap = 'true';
$this->displayName = $this->l('Hello User');
$this->description = $this->l('This is the demo module');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall module?');
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
$this->js_path = $this->_path.'views/js/';
$this->css_path = $this->_path.'views/css/';
$this->img_path = $this->_path.'views/img/';
$this->logo_path = $this->_path.'logo.png';
$this->module_path = $this->_path;
}
public function install()
{
if (!parent::install() ||
!$this->registerHook(
array('actionCustomerAccountAdd')))
return false;
}
public function uninstall()
{
return parent::uninstall();
}
public function hookActionCustomerAccountAdd($params) {
print_r($params);
exit;
}
}
Комментарии:
1. проверьте, зарегистрирован ли хук в модулях> позиции
2. Я не думаю, что в prestashop 1.7 есть какая-либо возможность проверить положение модуля?
3. Предложение @tarekfellah является действительным. если модуль не зарегистрирован в выбранном перехвате, он не будет отображаться в списке.
Ответ №1:
попробуйте с этим отредактированным
public function install()
{
if (!parent::install() ||
!$this->registerHook('actionCustomerAccountAdd'))
return false;
return true;
}
Комментарии:
1. Включен режим разработки, вы не получили никаких ошибок? регистрация клиента успешно завершена?
2. В разделе внешний вид> позиции вы можете проверить, зарегистрирован ли хук или нет
3. Я использую prestashop 1.7. так доступна ли эта функциональность в этой версии?
4. в функции установки добавьте return true; после возврата false;
5. Я видел раздел позиции prestashop, но такого перехвата, как actionCustomerAccountAdd, нет. Но я вижу тот же хук в Prestashop 1.6. На самом деле в документах prestashop 1.7 указано, что доступен перехват actionCustomerAccountAdd, но он не отображается в позиции.