cancel
Showing results for 
Search instead for 
Did you mean: 

Call a custom function in admin

Call a custom function in admin

I have a plugin that imports customer pricing using a csv. I want to be able to run that import on schedule with a custom file.

 

I have to add the file over here, and then choose save config to upload it

 

Screen Shot 2021-06-14 at 12.25.35 PM.png

<blockquote class="imgur-embed-pub" lang="en" data-id="qN2VpNy"><a href="https://imgur.com/qN2VpNy">View post on imgur.com</a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>

 

What do I have to do to call the correct function in my own module? I created a custom module for this, and I found a function called getElementHtml in file

Magedelight\Customerprice\Block\Adminhtml\Form\Field

which represents the backend form, but I can't figure out how to call it in my module.

22 REPLIES 22

Re: Call a custom function in admin

You can include the template in your page and then call the function.
Add this to the layout file corresponding to your admin page:
<block class="Magedelight\Customerprice\Block\Adminhtml\Form\Field" template="Magedelight_Customerprice::custom.phtml" name="custom.import.form"/>
Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Call a custom function in admin

Thank you. I'll try to implement that

Re: Call a custom function in admin

Every function hooked to admin_init will be called after you save settings in the admin page. You should add some extra check of conditions to trigger your code on correct page. For example aces etm

 

 

 

Re: Call a custom function in admin

A common task we might perform with a model like this is to update an article’s status from “draft” to “published”. We could easily do this in the admin one article at a time, but if we wanted to bulk-publish a group of articles, it’d be tedious. So, let’s write an action that lets us change an article’s status to “published.”

indigocard

Re: Call a custom function in admin

I was able to go another way. The plugin developer updated their API with a bulk update endpoint, so I'm writing a script outside of the plugin that calls the api and does what I need

Re: Call a custom function in admin


@web_master12 wrote: Official DGCustomerFirst Survey

I was able to go another way. The plugin developer updated their API with a bulk update endpoint, so I'm writing a script outside of the plugin that calls the api and does what I need


We could easily do this in the admin one article at a time, but if we wanted to bulk-publish a group of articles, it’d be tedious. So, let’s write an action that lets us change an article’s status to “published.”

Re: Call a custom function in admin

I have seen a first-time Article it is so wonderful thanks for sharing this article.

 

myestub

Re: Call a custom function in admin

I have seen this article this is very nice thanks for sharing it with us.

 

twitchbitstousd

Re: Call a custom function in admin

You must have shopped a Marshalls store in the U.S. or Puerto Rico and be a legal resident of the United States to be eligible for the Sweepstakes.

 

marshallsfeedback

 

talktosurvey

 

walgreenslistens