Magento 2.3: How to Echo From Controller On Button Click?Retreive and return response from controller in magento2How to call a model method from controller in Magento2Magento 2 “Recoverable Error: Argument 2 passed” when trying to define model in constructorI created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Magento 2 Custom Module New Controller Issuegetting error in while running Cutom admin controller URL in magento 2Magento 2 : Problem while adding custom button order view page?Magento 2 admin form controller errorDI not working in ControllerMagento 2.2.5: Overriding Admin Controller sales/orderMagento 2.3 Can't view module's front end page output?
Smallest Guaranteed hash collision cycle length
Was this a power play by Daenerys?
Extrude the faces of a cube symmetrically along XYZ
Reaction of borax with NaOH
Surely they can fit?
Why was Endgame Thanos so different than Infinity War Thanos?
How does Howard Stark know this?
Why was Thor doubtful about his worthiness to Mjolnir?
Can I use my laptop, which says 100-240V, in the USA?
Proof that the inverse image of a single element is a discrete space
Two researchers want to work on the same extension to my paper. Who to help?
How to select certain lines (n, n+4, n+8, n+12...) from the file?
What are the components of a legend (in the sense of a tale, not a figure legend)?
Do atomic orbitals "pulse" in time?
What is the best way for a skeleton to impersonate human without using magic?
What does a comma mean inside an 'if' statement?
What to do if SUS scores contradict qualitative feedback?
SSD - Disk is OK, one bad sector
Create a list of all possible Boolean configurations of three constraints
How did Thanos not realise this had happened at the end of Endgame?
Size of a folder with du
A curve pass via points at TiKz
What is the significance of 4200 BCE in context of farming replacing foraging in Europe?
On studying Computer Science vs. Software Engineering to become a proficient coder
Magento 2.3: How to Echo From Controller On Button Click?
Retreive and return response from controller in magento2How to call a model method from controller in Magento2Magento 2 “Recoverable Error: Argument 2 passed” when trying to define model in constructorI created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Magento 2 Custom Module New Controller Issuegetting error in while running Cutom admin controller URL in magento 2Magento 2 : Problem while adding custom button order view page?Magento 2 admin form controller errorDI not working in ControllerMagento 2.2.5: Overriding Admin Controller sales/orderMagento 2.3 Can't view module's front end page output?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm very new to Magento, I have a custom module and some tabs and fields in it, i have an 'import' tab, in that their is 'Import' button, just want to know the workflow of that button, like on button click just echo
something from controller. Right now i'm getting no response on button click...
appcodeVendor_NameModule_NameviewadminhtmltemplatesformImport.phtml
<div class="pp-buttons-container">
<button id="<?php echo $block->getId() ?>" onclick="return false;">
<span><span><span><?php echo 'Import'; ?></span></span></span>
</button>
</div>
<script type="text/javascript">
require(["jquery",], function($)
"use strict";
$(document).on('click','.col-action-grouped a',function()
);
);
</script>
appcodeVendor_NameModule_NameBlockAdminhtmlFormEditTabImport.php
<?php
namespace ECCustomimportBlockAdminhtmlFormEditTab;
class Import extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
protected $_template = 'form/import.phtml';
public function isReadonly()
return false;
public function getTabLabel()
return __('Import');
public function getTabTitle()
return __('Import');
public function canShowTab()
return true;
public function isHidden()
return false;
appcodeVendor_NameModule_NameControllerAdminhtmlIndexImport.php
<?php
namespace ECCustomimportControllerAdminhtmlIndex;
use ECCustomimportModelCustomimportFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoBackendAppActionContext;
class Import extends MagentoBackendAppAction
/**
* @param Context $context
*/
public function __construct(
Context $context,
CustomimportFactory $modelCustomimportFactory
)
$this->modelCustomimportFactory = $modelCustomimportFactory;
$this->resultFactory = $context->getResultFactory();
parent::__construct($context);
public function execute()
ignore_user_abort(true);
set_time_limit(0);
$id = $this->getRequest()->getParam('id');
$model = $this->modelCustomimportFactory->create()->load($id);
$model->import();
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setPath('adminhtml/*/index');
return $resultRedirect;
magento2 magento2.3 phtml custom-button
add a comment |
I'm very new to Magento, I have a custom module and some tabs and fields in it, i have an 'import' tab, in that their is 'Import' button, just want to know the workflow of that button, like on button click just echo
something from controller. Right now i'm getting no response on button click...
appcodeVendor_NameModule_NameviewadminhtmltemplatesformImport.phtml
<div class="pp-buttons-container">
<button id="<?php echo $block->getId() ?>" onclick="return false;">
<span><span><span><?php echo 'Import'; ?></span></span></span>
</button>
</div>
<script type="text/javascript">
require(["jquery",], function($)
"use strict";
$(document).on('click','.col-action-grouped a',function()
);
);
</script>
appcodeVendor_NameModule_NameBlockAdminhtmlFormEditTabImport.php
<?php
namespace ECCustomimportBlockAdminhtmlFormEditTab;
class Import extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
protected $_template = 'form/import.phtml';
public function isReadonly()
return false;
public function getTabLabel()
return __('Import');
public function getTabTitle()
return __('Import');
public function canShowTab()
return true;
public function isHidden()
return false;
appcodeVendor_NameModule_NameControllerAdminhtmlIndexImport.php
<?php
namespace ECCustomimportControllerAdminhtmlIndex;
use ECCustomimportModelCustomimportFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoBackendAppActionContext;
class Import extends MagentoBackendAppAction
/**
* @param Context $context
*/
public function __construct(
Context $context,
CustomimportFactory $modelCustomimportFactory
)
$this->modelCustomimportFactory = $modelCustomimportFactory;
$this->resultFactory = $context->getResultFactory();
parent::__construct($context);
public function execute()
ignore_user_abort(true);
set_time_limit(0);
$id = $this->getRequest()->getParam('id');
$model = $this->modelCustomimportFactory->create()->load($id);
$model->import();
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setPath('adminhtml/*/index');
return $resultRedirect;
magento2 magento2.3 phtml custom-button
your callinggetId()
method but it is not in your block class. Also your onclick function does not do anything so sure you will not get a response from that
– magefms
May 8 at 10:04
you can check this on how to pass response from the controller to ajax magento.stackexchange.com/questions/138043/…
– magefms
May 8 at 10:09
add a comment |
I'm very new to Magento, I have a custom module and some tabs and fields in it, i have an 'import' tab, in that their is 'Import' button, just want to know the workflow of that button, like on button click just echo
something from controller. Right now i'm getting no response on button click...
appcodeVendor_NameModule_NameviewadminhtmltemplatesformImport.phtml
<div class="pp-buttons-container">
<button id="<?php echo $block->getId() ?>" onclick="return false;">
<span><span><span><?php echo 'Import'; ?></span></span></span>
</button>
</div>
<script type="text/javascript">
require(["jquery",], function($)
"use strict";
$(document).on('click','.col-action-grouped a',function()
);
);
</script>
appcodeVendor_NameModule_NameBlockAdminhtmlFormEditTabImport.php
<?php
namespace ECCustomimportBlockAdminhtmlFormEditTab;
class Import extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
protected $_template = 'form/import.phtml';
public function isReadonly()
return false;
public function getTabLabel()
return __('Import');
public function getTabTitle()
return __('Import');
public function canShowTab()
return true;
public function isHidden()
return false;
appcodeVendor_NameModule_NameControllerAdminhtmlIndexImport.php
<?php
namespace ECCustomimportControllerAdminhtmlIndex;
use ECCustomimportModelCustomimportFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoBackendAppActionContext;
class Import extends MagentoBackendAppAction
/**
* @param Context $context
*/
public function __construct(
Context $context,
CustomimportFactory $modelCustomimportFactory
)
$this->modelCustomimportFactory = $modelCustomimportFactory;
$this->resultFactory = $context->getResultFactory();
parent::__construct($context);
public function execute()
ignore_user_abort(true);
set_time_limit(0);
$id = $this->getRequest()->getParam('id');
$model = $this->modelCustomimportFactory->create()->load($id);
$model->import();
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setPath('adminhtml/*/index');
return $resultRedirect;
magento2 magento2.3 phtml custom-button
I'm very new to Magento, I have a custom module and some tabs and fields in it, i have an 'import' tab, in that their is 'Import' button, just want to know the workflow of that button, like on button click just echo
something from controller. Right now i'm getting no response on button click...
appcodeVendor_NameModule_NameviewadminhtmltemplatesformImport.phtml
<div class="pp-buttons-container">
<button id="<?php echo $block->getId() ?>" onclick="return false;">
<span><span><span><?php echo 'Import'; ?></span></span></span>
</button>
</div>
<script type="text/javascript">
require(["jquery",], function($)
"use strict";
$(document).on('click','.col-action-grouped a',function()
);
);
</script>
appcodeVendor_NameModule_NameBlockAdminhtmlFormEditTabImport.php
<?php
namespace ECCustomimportBlockAdminhtmlFormEditTab;
class Import extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
protected $_template = 'form/import.phtml';
public function isReadonly()
return false;
public function getTabLabel()
return __('Import');
public function getTabTitle()
return __('Import');
public function canShowTab()
return true;
public function isHidden()
return false;
appcodeVendor_NameModule_NameControllerAdminhtmlIndexImport.php
<?php
namespace ECCustomimportControllerAdminhtmlIndex;
use ECCustomimportModelCustomimportFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoBackendAppActionContext;
class Import extends MagentoBackendAppAction
/**
* @param Context $context
*/
public function __construct(
Context $context,
CustomimportFactory $modelCustomimportFactory
)
$this->modelCustomimportFactory = $modelCustomimportFactory;
$this->resultFactory = $context->getResultFactory();
parent::__construct($context);
public function execute()
ignore_user_abort(true);
set_time_limit(0);
$id = $this->getRequest()->getParam('id');
$model = $this->modelCustomimportFactory->create()->load($id);
$model->import();
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setPath('adminhtml/*/index');
return $resultRedirect;
magento2 magento2.3 phtml custom-button
magento2 magento2.3 phtml custom-button
edited May 8 at 9:50
Saif Zakir
asked May 8 at 9:36
Saif ZakirSaif Zakir
276
276
your callinggetId()
method but it is not in your block class. Also your onclick function does not do anything so sure you will not get a response from that
– magefms
May 8 at 10:04
you can check this on how to pass response from the controller to ajax magento.stackexchange.com/questions/138043/…
– magefms
May 8 at 10:09
add a comment |
your callinggetId()
method but it is not in your block class. Also your onclick function does not do anything so sure you will not get a response from that
– magefms
May 8 at 10:04
you can check this on how to pass response from the controller to ajax magento.stackexchange.com/questions/138043/…
– magefms
May 8 at 10:09
your calling
getId()
method but it is not in your block class. Also your onclick function does not do anything so sure you will not get a response from that– magefms
May 8 at 10:04
your calling
getId()
method but it is not in your block class. Also your onclick function does not do anything so sure you will not get a response from that– magefms
May 8 at 10:04
you can check this on how to pass response from the controller to ajax magento.stackexchange.com/questions/138043/…
– magefms
May 8 at 10:09
you can check this on how to pass response from the controller to ajax magento.stackexchange.com/questions/138043/…
– magefms
May 8 at 10:09
add a comment |
1 Answer
1
active
oldest
votes
I solved it by doing make an ajax request and sent in to controller.
appcodeVendor_NameModule_NameviewadminhtmltemplatesformImport.phtml
<div class="pp-buttons-container">
<button class="import" id="<?php echo $block->getId() ?>" onclick="return false;">
<span><span><span><?php echo 'Import'; ?></span></span></span>
</button>
</div>
<script type="text/javascript">
require(["jquery",'mage/url'], function($, url)
"use strict";
$(document).on('click','.col-action-grouped a',function()
);
$(document).on('click','.import',function()
jQuery.ajax(
url: '/admin/customimport/index/import',
type: "POST",
data: data:'success',
success: function(response)
console.log('Sucess');
);
);
);
</script>
appcodeVendor_NameModule_NameControllerAdminhtmlIndexImport.php
<?php
namespace ECCustomimportControllerAdminhtmlIndex;
use ECCustomimportModelCustomimportFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoBackendAppActionContext;
class Import extends MagentoBackendAppAction
/**
* @param Context $context
*/
public function __construct(
Context $context,
CustomimportFactory $modelCustomimportFactory
)
$this->modelCustomimportFactory = $modelCustomimportFactory;
$this->resultFactory = $context->getResultFactory();
parent::__construct($context);
public function execute()
echo 'Success';
exit;
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273815%2fmagento-2-3-how-to-echo-from-controller-on-button-click%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I solved it by doing make an ajax request and sent in to controller.
appcodeVendor_NameModule_NameviewadminhtmltemplatesformImport.phtml
<div class="pp-buttons-container">
<button class="import" id="<?php echo $block->getId() ?>" onclick="return false;">
<span><span><span><?php echo 'Import'; ?></span></span></span>
</button>
</div>
<script type="text/javascript">
require(["jquery",'mage/url'], function($, url)
"use strict";
$(document).on('click','.col-action-grouped a',function()
);
$(document).on('click','.import',function()
jQuery.ajax(
url: '/admin/customimport/index/import',
type: "POST",
data: data:'success',
success: function(response)
console.log('Sucess');
);
);
);
</script>
appcodeVendor_NameModule_NameControllerAdminhtmlIndexImport.php
<?php
namespace ECCustomimportControllerAdminhtmlIndex;
use ECCustomimportModelCustomimportFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoBackendAppActionContext;
class Import extends MagentoBackendAppAction
/**
* @param Context $context
*/
public function __construct(
Context $context,
CustomimportFactory $modelCustomimportFactory
)
$this->modelCustomimportFactory = $modelCustomimportFactory;
$this->resultFactory = $context->getResultFactory();
parent::__construct($context);
public function execute()
echo 'Success';
exit;
add a comment |
I solved it by doing make an ajax request and sent in to controller.
appcodeVendor_NameModule_NameviewadminhtmltemplatesformImport.phtml
<div class="pp-buttons-container">
<button class="import" id="<?php echo $block->getId() ?>" onclick="return false;">
<span><span><span><?php echo 'Import'; ?></span></span></span>
</button>
</div>
<script type="text/javascript">
require(["jquery",'mage/url'], function($, url)
"use strict";
$(document).on('click','.col-action-grouped a',function()
);
$(document).on('click','.import',function()
jQuery.ajax(
url: '/admin/customimport/index/import',
type: "POST",
data: data:'success',
success: function(response)
console.log('Sucess');
);
);
);
</script>
appcodeVendor_NameModule_NameControllerAdminhtmlIndexImport.php
<?php
namespace ECCustomimportControllerAdminhtmlIndex;
use ECCustomimportModelCustomimportFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoBackendAppActionContext;
class Import extends MagentoBackendAppAction
/**
* @param Context $context
*/
public function __construct(
Context $context,
CustomimportFactory $modelCustomimportFactory
)
$this->modelCustomimportFactory = $modelCustomimportFactory;
$this->resultFactory = $context->getResultFactory();
parent::__construct($context);
public function execute()
echo 'Success';
exit;
add a comment |
I solved it by doing make an ajax request and sent in to controller.
appcodeVendor_NameModule_NameviewadminhtmltemplatesformImport.phtml
<div class="pp-buttons-container">
<button class="import" id="<?php echo $block->getId() ?>" onclick="return false;">
<span><span><span><?php echo 'Import'; ?></span></span></span>
</button>
</div>
<script type="text/javascript">
require(["jquery",'mage/url'], function($, url)
"use strict";
$(document).on('click','.col-action-grouped a',function()
);
$(document).on('click','.import',function()
jQuery.ajax(
url: '/admin/customimport/index/import',
type: "POST",
data: data:'success',
success: function(response)
console.log('Sucess');
);
);
);
</script>
appcodeVendor_NameModule_NameControllerAdminhtmlIndexImport.php
<?php
namespace ECCustomimportControllerAdminhtmlIndex;
use ECCustomimportModelCustomimportFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoBackendAppActionContext;
class Import extends MagentoBackendAppAction
/**
* @param Context $context
*/
public function __construct(
Context $context,
CustomimportFactory $modelCustomimportFactory
)
$this->modelCustomimportFactory = $modelCustomimportFactory;
$this->resultFactory = $context->getResultFactory();
parent::__construct($context);
public function execute()
echo 'Success';
exit;
I solved it by doing make an ajax request and sent in to controller.
appcodeVendor_NameModule_NameviewadminhtmltemplatesformImport.phtml
<div class="pp-buttons-container">
<button class="import" id="<?php echo $block->getId() ?>" onclick="return false;">
<span><span><span><?php echo 'Import'; ?></span></span></span>
</button>
</div>
<script type="text/javascript">
require(["jquery",'mage/url'], function($, url)
"use strict";
$(document).on('click','.col-action-grouped a',function()
);
$(document).on('click','.import',function()
jQuery.ajax(
url: '/admin/customimport/index/import',
type: "POST",
data: data:'success',
success: function(response)
console.log('Sucess');
);
);
);
</script>
appcodeVendor_NameModule_NameControllerAdminhtmlIndexImport.php
<?php
namespace ECCustomimportControllerAdminhtmlIndex;
use ECCustomimportModelCustomimportFactory;
use MagentoFrameworkControllerResultFactory;
use MagentoBackendAppActionContext;
class Import extends MagentoBackendAppAction
/**
* @param Context $context
*/
public function __construct(
Context $context,
CustomimportFactory $modelCustomimportFactory
)
$this->modelCustomimportFactory = $modelCustomimportFactory;
$this->resultFactory = $context->getResultFactory();
parent::__construct($context);
public function execute()
echo 'Success';
exit;
answered May 8 at 11:32
Saif ZakirSaif Zakir
276
276
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273815%2fmagento-2-3-how-to-echo-from-controller-on-button-click%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
your calling
getId()
method but it is not in your block class. Also your onclick function does not do anything so sure you will not get a response from that– magefms
May 8 at 10:04
you can check this on how to pass response from the controller to ajax magento.stackexchange.com/questions/138043/…
– magefms
May 8 at 10:09