Jump to content

How to add custom action in render list


Mukesh Ravi
 Share

Recommended Posts

Hi All,

 

 

 

I am using Prestashop 1.5.6

I want add a new custom action (say "new action") in render action list.

I reached to admincontroller but don't know how to do this?

For more clarification I am attaching a screenshot.

 

Please help me.

 

Thanks in Advance...!

post-262404-0-96683600-1395210785_thumb.png

Share this post


Link to post
Share on other sites

In AdminProductsController line 2294 you can add a row action (test for example)

	public function renderList()
	{
		$this->addRowAction('edit');
		$this->addRowAction('duplicate');
		$this->addRowAction('delete');
		$this->addRowAction('test');
		return parent::renderList();
	}

Then in the same controller (or in the HelperList) you need to define the displayTestLink. For example this one is copy pasted from the displayEditLink in the HelperList, and changed only the title, from Edit to Test and the path to find the tpl (since we are in the controller)

public function displayTestLink($token = null, $id, $name = null)
	{
		$tpl = $this->createTemplate('helpers/list/list_action_edit.tpl');
		if (!array_key_exists('Test', self::$cache_lang))
			self::$cache_lang['Test'] = $this->l('Test', 'Helper');
	
		$tpl->assign(array(
				'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token != null ? $token : $this->token),
				'action' => self::$cache_lang['Test'],
				'id' => $id
		));
	
		return $tpl->fetch();
	}

But you get the idea, you generate the html for each button dinamicaly, the tpl is very simple:

<a href="{$href}" class="edit" title="{$action}">
	<img src="../img/admin/edit.gif" alt="{$action}" />
</a>
  • Like 4

Share this post


Link to post
Share on other sites

  • 2 weeks later...

You can have a look at http://doc.prestashop.com/display/PS15/Overriding+default+behaviors#Overridingdefaultbehaviors-Overridingacontroller

 

you can put your AdminProductsController under override/controllers/admin, override the public function renderList() and add your displayXXXLink method

 

don't forget to delete cache/class_index.php if you do it manually.

Share this post


Link to post
Share on other sites

  • 1 year later...
  • 5 weeks later...
  • 3 months later...

You can have a look at http://doc.prestashop.com/display/PS15/Overriding+default+behaviors#Overridingdefaultbehaviors-Overridingacontroller

 

you can put your AdminProductsController under override/controllers/admin, override the public function renderList() and add your displayXXXLink method

 

don't forget to delete cache/class_index.php if you do it manually.

Hey man, is it possible to override controller and add custom row action or order products? I can`t even find where should I do it. In AdminProduct or AdminOrders controller? Thanks for any help!

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More