Jump to content

Edit History

lightx

lightx


added code

I am trying to develop a module that listens for a new product add, then prints to screen a message that a new product has added for debug.

I implemented the hook: 

<?php

if (!defined('_PS_VERSION_')) {
    exit;
}

class IZerSync extends Module
{
    protected $config_form = false;

    public function __construct()
    {
        $this->name = 'iZerSync';
        $this->tab = 'administration';
        $this->version = '1.0.0';
        $this->author = 'LightX';
        $this->need_instance = 1;

        /**
         * Set $this->bootstrap to true if your module is compliant with bootstrap (PrestaShop 1.6)
         */
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('iZerSync');
        $this->description = $this->l('synchronize prestashop with iZer system. ');

        $this->confirmUninstall = $this->l('');

        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
    }

    /**
     * Don't forget to create update methods if needed:
     * http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update
     */
    public function install()
    {
        Configuration::updateValue('IZERSYNC_LIVE_MODE', false);

        include(dirname(__FILE__).'/sql/install.php');

        return parent::install() &&
            $this->registerHook('header') &&
            $this->registerHook('backOfficeHeader') &&
            $this->registerHook('actionOrderDetail') &&
            $this->registerHook('actionOrderSlipAdd') &&
            $this->registerHook('actionOrderStatusUpdate') &&
            $this->registerHook('actionProductAdd') &&
            $this->registerHook('actionProductDelete') &&
            $this->registerHook('actionProductUpdate') &&
            $this->registerHook('actionValidateOrder');
    }

    public function uninstall()
    {
        Configuration::deleteByName('IZERSYNC_LIVE_MODE');

        include(dirname(__FILE__).'/sql/uninstall.php');

        return parent::uninstall();
    }

    /**
    * Add the CSS & JavaScript files you want to be loaded in the BO.
    */
    public function hookBackOfficeHeader()
    {
        if (Tools::getValue('module_name') == $this->name) {
            $this->context->controller->addJS($this->_path.'views/js/back.js');
            $this->context->controller->addCSS($this->_path.'views/css/back.css');
        }
    }

    /**
     * Add the CSS & JavaScript files you want to be added on the FO.
     */
    public function hookHeader()
    {
        $this->context->controller->addJS($this->_path.'/views/js/front.js');
        $this->context->controller->addCSS($this->_path.'/views/css/front.css');
    }

    public function hookActionProductAdd($prod)
    {
        $test = "testing!";
        /* Place your code here. */
        echo "<script>console.log('$test')</script>";
    }
}

 

but i dont see the test in the console.
lightx

lightx

i am trying to develop a module that listens for a new product add, then prints to screen a message that a new product has added for debug.

i implemented the hook: 

public function install()
{
$this->registerHook('actionProductAdd');
}
public function hookActionProductAdd($prod)
{
echo "<script>console.log('test')</script>";
}
 
but i dont see the test in the console.
×
×
  • Create New...