Questions tagged [controllers]

Denotes questions about controllers and action methods

Filter by
Sorted by
Tagged with
0
votes
1answer
1k views

Redirect contact form to another page after submit

How can I redirect the default Magento form to a separate thank you page on submission, rather than redirecting it to the contact form with the thank you message itself? Here is my Indexcontroller....
0
votes
1answer
16 views

Build Customer View URL on Controller

How can I programmatically build this url: http://127.0.0.1/magento2/sales/order/view/order_id/61/? Im in a custom controller with the current Order object.
0
votes
2answers
31 views

null Order on custom controller

Im in a custom controller tying to get the order info with checkout session. There is my code. $order = $this->_checkoutSession->getLastRealOrder(); // Magento\Sales\Model\Order\Interceptor ...
1
vote
1answer
1k views

How to Fix - Front controller reached 100 router match iterations

I know there is a lot written about this kind of error but I haven't been able to fix it yet. Here is the Report error: a:5:{i:0;s:52:"Front controller reached 100 router match iterations";i:1;s:446:"...
0
votes
1answer
879 views

Request Response JSON in magento 2

I have modified form review as popup modal and have overrides the controller in my custom module, the review saved successfully in DB. I need to pass the response to the to JS in JSON format , Help me ...
0
votes
0answers
14 views

How to redirect to the same page after form submit in sales order view?

I am creating a custom form in a custom tab of Sales Order View. When I click on Use Template button, it redirects me to Page Not Found 404. I want to show a success/fail message and redirect to same ...
0
votes
1answer
21 views

Is it good to use Access Token in Magento 2 for REST API?

I am using REST API for some product insertion process in my Controller File and i will used that Access Token to generate the token. Is it good to use that on my Live Website Code If not then what ...
1
vote
2answers
51 views

How to call a controller function in a block?

Is it possible to call a controller function in a block, if yes, please define how can i achieve that.
0
votes
1answer
18 views

How to display an image using raw controller?

I'm new to magento and learning hard thesedays. I have a task to display an image using raw controller but couldn't really find out how to do this. I have my image on etc/frontend/web/images as shown ...
2
votes
4answers
20k views

Magento Call a function of Model in Controller

I have a function abc in a model. I want to call that function abc in the controller. I am new to Magento and don't have any idea regarding this. Can anybody tell me how to do this?
0
votes
0answers
15 views

How to use 2 models in layout folder in xml that should show in inside view show.phtml file. Please tell how the controller is linked with block

How to use 2 models in layout folder in xml that should show in inside view show.phtml file. Please tell how the controller is linked with block. And how a layout file is linked with the controller ...
1
vote
1answer
63 views

Magento 2: Multiple file upload not working

I want to upload multiple file using below code from different Choose File option, and it works for single file upload. So I want to upload multiple choose file in one click and save their path in ...
1
vote
1answer
21 views

Warning: Illegal offset type in isset or empty

Controller file code below, data get print successfully but throw Exception #0 (Exception): Warning: Illegal offset type in isset or empty public function execute() { try { ...
0
votes
1answer
835 views

Magento2 How to call model function in Controller

I have following model in one module namespace Abc\Abcd\Model\Job; use Magento\Backend\App\Action\Context; abstract class AbstractJob extends AbstractModel { private $name; public function ...
2
votes
3answers
988 views

How can I override admin create order controller?

I am trying to override adminhtml_sales_order_create controller. I have created a small module app/code/local/Akina/Sales/etc/config.xml <?xml version="1.0"?> <config> <modules> ...
0
votes
0answers
28 views

Magento 2 controller return 404 error

C:\xampp\htdocs\m2\app\code\Vendor\Mymodule\registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, '...
0
votes
1answer
57 views

Ajax call not working on Magento_Wishlist

I have created a controller for products added wishlist or not, if available include class name, Controller: <?php namespace Vendor\Mymodule\Controller\Index; class Wishlist extends \Magento\...
0
votes
1answer
931 views

Magento 2 A customer with the same email already exists in an associated website error

I'm stuck in a weird problem. Everytime I try to create an account and add an address to that account programmatically I get an error called A customer with the same email already exists in an ...
1
vote
1answer
1k views

Magento 2: Submitted Form not calling Controller

To continue with the question below Magento 2: How to define Scope For Router.php app\code\Custom\Module\view\frontend\templates\posts\view.phtml <form class="form post reply" action="<?...
1
vote
1answer
30 views

Pass data to block file from ajax request

How do I pass data from the controller to my block file? Below is the code which I am using inside the controller. $this->_view->loadLayout(); $this->_view->getLayout() ...
1
vote
1answer
136 views

How to change Wishlist button color once product added to Wishlist using controller

How to change the wishlist button color once the products added to the wishlist.I am getting an error while using a controller. Ref: 1)https://magento.stackexchange.com/a/256570/57334 2)https://...
2
votes
2answers
1k views

Custom Contact Form - Override Controller

I am trying to add a contacts form on multiple cms/products pages. I copied the default contacts form phtml and pasted it into a new phtml file. However, submitting the form redirects to the contacts ...
0
votes
1answer
23 views

Ajax call to Controller 404'ing

I've created a controller within my custom module to add items to my basket and i'm trying to make an ajax call across to it. However, I can't even call my controller currently as I get a 404 error ...
0
votes
2answers
2k views

Magento 2 Plugin not called

etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> &...
1
vote
4answers
1k views

Magento 2 - Error trying Redirect to login page for controller if not logged in

I know this question has been asked before a couple of times here: Magento 2 : Redirect From Homepage to Login if not Logged Magento 2 - Redirect user to a specific page if not logged in However i ...
0
votes
1answer
1k views

Extend NewAction Controller in Magento 2 Newsletter Vendor module

I have extended the core controller of Magento_Newsletter NewAction controller. My aim is to add a thank you page after a successful subscription. and I'm having a problem because I wan't it to ...
2
votes
1answer
1k views

Magento 2 add new Button in admin Controller

I am working on module which will work for sync product from Third party Api.I have already created admin controller page but don't have Idea how to add button Sync Products whose action will call a ...
3
votes
2answers
3k views

How to override cart\addcontroller in magento 2?

I want this function in \code \StwBuyXGetY \BuyXGetY \Controller\Checkout\Cart\Add.php(this is written in magento 1.9, I want to convert it into magento 2). But I cant add any new function in add ...
0
votes
0answers
18 views

Magento 2 - Passing variable to controller is not working

I want to pass a selected value to a controller. After researching, it seems that I can use Ajax call to pass the value. I don't know why this is not working, but it seems the url that I use to call ...
0
votes
0answers
17 views

How to pass parameter from phtml template file to controller in Magento 2

I have created a custom module. It basically displays a popup modal that prompts user to enter their ship-to location. Below is my code: Learning\etc\module.xml <?xml version="1.0"?> &...
0
votes
1answer
1k views

Magento 2 login popup

I have a client login popup on my page with the form action="<?= $block->escapeUrl($block->getPostActionUrl()) ?>" How can I change this so the form will not redirect to the account ...
3
votes
1answer
1k views

Magento 2 Init script after page load

Is there any option to init (text/x-magento-init) script after page load? Example, I am working on a simple quickview feature and my controller returns my a layout - phtml file - with rendered html ...
4
votes
3answers
4k views

Redirect to login page if not login magento

I want to restrict the visitors for a single store in multistore website. If they are not logged in, redirect them to login page. They can also create account and login after they visit the website. ...
1
vote
1answer
2k views

Magento 2 - Create csv file for download in admin

I need to create a file in mangento 2 admin. I'm using a button to get in a controller route. My form ui component: <item name="buttons" xsi:type="array"> <item name="save" ...
1
vote
2answers
3k views

How to update order grand total via controller in Magento 2.2.2?

I am trying to update the order's grand total via a controller. Here is my controller's code: <?php namespace Company\Vendor\Controller\Index; use Magento\Framework\App\Action\Action; use ...
0
votes
2answers
16k views

Sending ajax POST data to controller

This is my ajax request: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ ...
1
vote
2answers
2k views

Magento2: CRON Job is scheduled but Not Running

I have created a Cron job followed this question Installed the Extension and check it from admin back it says the job is pending. Below is the screenshot and my code in detail, Please let me know if ...
0
votes
2answers
1k views

Magento 2.2.4 : post data in url

I want to get parameters from my page to the second. My values are submitted in the first page, but I can't achieve to get data on my second page (where I want to display theses data). I'm trying this ...
0
votes
0answers
16 views

Magento 2.4: How to display the filename after uploading the file via ajax?

I want to show the filename instead of uniqid(). I have the below code in my controller, how can I display the actual file name after uploading the file <?php namespace Vendor\Module\Controller\...
0
votes
0answers
24 views

Controller Issue (Magento 2)

Controller is not executing Magento\Newsletter\Controller\Subscriber\NewAction.php Below is the ajax request to call the execute method for Magento\Newsletter\Controller\Subscriber\NewAction.php but ...
1
vote
2answers
91 views

Execute method is not calling in controller Magento 2

I am facing issue with newsletter. it suppose to subscribe user in newsletter and send them email which seems not working execute method is not even calling. on direct accessing the url or using ...
6
votes
3answers
22k views

Magento 2 - Send form data to Controller using AJAX and return Result to PHTML

I am working on a simple custom module, where user can input height and the weight/BMI will be shown as output on form submit. The page where user enters input is Calculation Page while output is ...
6
votes
3answers
13k views

Magento 2: How to get data from controller to block/view

I am looking for the right flow of data of how Magento wants me to do it. I have some data which I want to pass to the view. How do I do this the right way? I saw the following answer for Magento 1.x ...
1
vote
1answer
20 views

How can I implement HttpMethod (HttpMethodNameActionInterface) for ActionInterface in a controller?

This class Magento\Framework\App\Action\Action is deprecated: What is the interface to be implemented in the controller action? How should I implement the interface in the controller action? What ...
0
votes
0answers
10 views

Accessing block from controller in magento2

I'm trying to use functions in \Magento\Swatches\Block\Product\Renderer\Listing\Configurable directly from my controller. Ive created an instance like this : $swatchInstance = $this->layoutFactory-&...
0
votes
0answers
5 views

Change “Request Method” of a request (controller) Magento 1

Where the type of request "POST & GET" is defined in Magento 1 for controller requests ?
0
votes
0answers
21 views

How to submit form using other controller in Magento 2

I have a form in phtml file. There are 2 fields in that username and password. I want to set that username and password value from other controller and submit that form. I tried using this below way : ...
0
votes
0answers
7 views

Magento 1 Request Flow

I am using Magento 1.4, i can see many request's have "POST" HTTP verb in the request, Specifically "POST" should not be necessarily used for "logoutAction". Where the ...
0
votes
1answer
48 views

After making ajax query controller redirects back to product page

I’m making an ajax query from a product page (code below). If I run it directly in browser, it works but if I run it inside a code (javascript) it redirects me back to the product page with a status ...
0
votes
1answer
24 views

Uncaught Error: Call to a member function dispatch() on null

i am creating custom tab for frontend customer dashboard. it works well but after click the custom tab, the error of the title occurs. nothing comes on debug log. this error occurs before the ...

1
2 3 4 5
19