Jump to content

Adding new tabs and fields to Prestashop products' back office


KServices

Recommended Posts

Hello,

I need help in the development of my module, i followed this pretty useful tutorial 'http://nemops.com/prestashop-products-new-tabs-fields/#.Wl3gVKjiaM8', to add a new tab in the products back office

But i don't know where execute my sql function when click on 'save and stay' button

My tpl

<div class="form-group">
  <input name="configurator_shipping" type="number" step="0.01">
  <label for="configurator_shipping">Frais de port</label>
  <div class="panel-footer {if version_compare($smarty.const._PS_VERSION_,'1.6','<')}margin-form{/if}">
    <button class="button btn btn-default" id="cancelConfiguratorProduct" name="cancelConfiguratorProduct" type="submit"><i class="process-icon-save"></i> {l s='Cancel' mod='configurator'}</button>
    <button class="button btn btn-default pull-right" id="submitConfiguratorProduct" name="submitAddproduct" type="submit"><i class="process-icon-save"></i> {l s='Save' mod='configurator'}</button>
  </div>
</div>

And in my module PHP

public function hookDisplayAdminProductsExtra($params)
{
  $this->smarty->assign(array('product' => $product));
  return $this->display(__FILE__, 'product-extra.tpl');
}

am trying to catch the click event with the hookActionProductSave And hookActionProductUpdate

But these function aren't executed. So where can i find my posted values  ?

Does someone have an idea ?

Edited by KServices (see edit history)
Link to comment
Share on other sites

Please follow the tutorial properly. you will have the answer.

newfieldstut.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public function hookActionProductUpdate($params)
{
    // get all languages
    // for each of them, store the new field
 
    $id_product = (int)Tools::getValue('id_product');
 
    $languages = Language::getLanguages(true);
    foreach ($languages as $lang) {
        if(!Db::getInstance()->update('product_lang', array('custom_field'=> pSQL(Tools::getValue('custom_field_'.$lang['id_lang']))) ,'id_lang = ' . $lang['id_lang'] .' AND id_product = ' .$id_product ))
            $this->context->controller->_errors[] = Tools::displayError('Error: ').mysql_error();
    }
 
}
Link to comment
Share on other sites

 /**
    * hookActionProductUpdate
    *
    * Product Update
    * 
    **/
    public function hookActionProductUpdate($params)
    {
        $id_product = (int)Tools::getValue('id_product');
        var_dump(Tools::getValue('configurator_shipping'));
        die();

    }

This function is already in my newfieldstut.php but i don't understand why it is never called.

Edited by KServices (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...