Jump to content

Save button does not work (high PS skills needed)


Recommended Posts

Hi,

 

this is my first topic in Prestashop forum so I believe that I will describe my problem enough to be understood by you.

 

I have created module to add Youtube videos on product pages. User can add youtube URL to a specific product in back office AdminProducts section in an extra tab added by hookDisplayAdminProductsExtra. Form is showing ok but when I hit SAVE button I am just redirected to index.php?controller=AdminProducts&token=TOKEN&id_product=ID_PRODUCT without any changes submitted.

 

I think it is important to mention that when I tested module on newly installed Prestashop 1.6.1.7 it worked with the same code as below flawlessly. After hitting SAVE button it stayed on the same tab and also processed the submitted changes. But when I installed module on live Prestashop 1.6.0.11, the strange behavior began. Can you help please? Thanks.

 

 

Regarding part of module.php:

 

public function displayAdminProductTab() {
  
  if (Tools::isSubmit('submit'.$this->name)) {
    DO SOMETHING
  } //If
  
  $token = Tools::getAdminTokenLite('AdminProducts');
  $cancel_url = AdminController::$currentIndex.'&token='.$token;
  $youtube_url = $this->getProductYtUrl(); //My own function. It works well so I will not post its content here.
  
  $params = array(
    'title' => $this->l('Youtube product video'),
    'cancel_url' => $cancel_url,
    'youtube_url' => $youtube_url ? $youtube_url : '',
    'submit_action' => 'submit'.$this->name
  );
  
  $this->context->smarty->assign($params);
  
  return $output.$this->display(__FILE__, 'module.tpl');
}
 
public function hookDisplayAdminProductsExtra($params) {
  return $this->displayAdminProductTab();
}
 
Content of module.tpl:
 
<div class="panel">
  <div class="panel-heading">{$title}</div>
  <div class="form-wrapper">
    <div class="form-group">
      <label class="control-label col-lg-3">{l s='Youtube URL' mod='productytvideo'}</label>
      <div class="col-lg-9">
        <input type="text" name="productytvideo" value="{$youtube_url}" size="20">
      </div>
    </div>
  </div>
  <div class="panel-footer"> <a href="{$cancel_url}" class="btn btn-default"><i class="process-icon-cancel"></i>{l s='Cancel' mod='productytvideo'}</a>
    <button type="submit" name="{$submit_action}" class="btn btn-default pull-right"><i class="process-icon-save"></i>{l s='Save' mod='productytvideo'}</button>
  </div>
</div>
 
 
I also noticed that there is a difference in loaded submit redirection URL between PS versions 1.6.0.11 and 1.6.1.7 and somehow I feel that this is a cruicial clue to solve my problem.
 
1.6.0.11 (not working with my code)
index.php?controller=AdminProducts&token=TOKEN&id_product=PRODUCT_ID
 
1.6.1.7 (working with my code)
index.php?controller=AdminProducts&token=TOKEN&updateproduct&id_product=PRODUCT_ID
 

If this is really it, how can I force my SAVE button to add &updateproduct attribute to redirection URL in 1.6.0.11? Unfotunately updating to 1.6.1.7 is not an option for me and I would really like to avoid PS core file editing.

Thank you for your help again ;)

Edited by balko.online (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...