Questions tagged [controllers]

Denotes questions about controllers and action methods

Filter by
Sorted by
Tagged with
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 ...
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
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 ...
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 ...
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 { ...
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() ...
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
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
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 ...
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://...
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
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 ...
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 ...
0
votes
1answer
76 views

Magento 2 - Update collection data through ajax

I have a collection inside my Block file Vendor\MyModule\Block\PostsCollectionList.php protected function postCollection() { return $this->postCollectionFactory->create() ->...
0
votes
1answer
13 views

How to get Html post request value in Controller?

I've been trying to send the SKU of the product from the product page to another page so I can integrate it with an API. Here's my code phtml code: Here's my Controller code: For some reason I can't ...
0
votes
1answer
46 views

How to override a controller using Plugin?

I want to override abstact class controller Magento\Sales\Controller\AbstractController\Reorder.php using Plugin. How can I do that? di.xml <?xml version="1.0"?> <config xmlns:xsi=&...
0
votes
0answers
41 views

How to add condition to reorder.php?

What I am trying to do: So I am trying to edit the reorder button that is in the customer's order page. Condition now: As you can see in the picture below, when one of the item in the order history is ...
0
votes
1answer
51 views

Override abstract class reorder.php controller not working

I am trying to override abstract class controller magento\module-sales\Controller\AbstractController\Reorder.php with my controller. Below are the code New custom module called ReorderButton module....
0
votes
1answer
23 views

in magento controller file there is one get function is there “$mobile -> $model ->getphone();” where is that get phone method defined

in magento custom module controller file there is one get function is there for getting a phone number "$mobile -> $model ->getphone();" where is that get phone method defined.
0
votes
1answer
27 views

Magento 2 Email template How to add Controller Path

I want to add controller path in Email template.I have create custom email template using programmatically. This is my code :- {{template config_path="design/email/header_template"}} <...
0
votes
1answer
17 views

Magento 2 admin controller is not working

Here am added a admin controller, here is my code etc/adminhtml/routes.xml <?xml version="1.0" ?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
2
votes
1answer
246 views

Magento 2 How to Create Shipment Programmatically

Here am trying to make shipment from a controller. here is my controller public function execute() { $orderId= 11; if ($orderId <= 0) { echo 'Order not found.'; ...
0
votes
1answer
25 views

How to hit controller on saving my data of Store->Configuration in Magento 2?

I have created some setting in Store->Configuration in Magento 2 i want to hit a controller if the setting is changed otherwise the i want the controller didn't hit. How would i do that ? My ...
0
votes
0answers
20 views

Send Mail controller goes to 302 in Magento 2?

I have created a custom controller and the controller which is used to send mail goes to 302 in Magento 2. So i think that's why i didn't receive any mail in my mailbox. If it is correct please tell ...
0
votes
0answers
17 views

How to send mail in Magento 2 from custom Module? [duplicate]

I have created a custom module and in phtml file i have added html and by using ajax i will call the controller file. But the issue is on using mail function it will show me an error on mail function ...
0
votes
0answers
28 views

How to execute php file from magento admin in Magento 2?

I have created a php file on root folder of magento in Magento 2 and hit a controller on that file. That process is done and i have tested it it running on terminal. How would i run that script from ...
0
votes
1answer
53 views

How to execute a controller file using shell_exec in Magento 2?

I want to create product using controller so how would i hit the controller using shell_exec. How would i do that ? My controller file is <?php namespace Mageplaza\HelloWorld\Controller\Index; ...
0
votes
0answers
18 views

How to add product weight using program in magento 2?

I have created a controller and create product from that controller hit. But on creating the product it successfully created but it doesn't show on froentend but when i manually enable that the item ...
0
votes
1answer
54 views

Magento 2 Custom Admin Sub Menu Redirects to White Blank Page!

I created a Module and I am getting this 404 page error after I hit the submenu link. Here is the code. I can not figure out what is wrong. acl.xml <?xml version="1.0"?> <!-- /** *...
1
vote
2answers
51 views

Magento 2 How to redirect to a custom block from a Controller

I have added a front phtml file followed by a Block, I need to redirect to that block from a controller. this is the Block path, it's working fine. http://mywebsite.co/schools/schoolzone_search/index/...
0
votes
1answer
294 views

In Custom table always create a new row in magento 2?

I have created a custom table and update data using model and resource model. But it always create a new row on hitting ajax how to update row as old data is appear. I think i want to use Update query ...
0
votes
2answers
46 views

Custom controller goes to 404 for custom form in Magento 2?

I have created a custom controller to show a custom form but it goes to 404 page in Magento 2 ? Controller file path : ( app/code/Company/Module/Controller/Index/Booking.php ) <?php namespace ...
0
votes
1answer
460 views

Magento 2 Interceptor generation error: during running di:compile command

Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI ...
0
votes
2answers
70 views

How to get only disabled product in Magento 2 Controller?

How to get only disabled product In Controller I have getting all the products <?php namespace Mageplaza\HelloWorld\Controller\Index; use Magento\Catalog\Model\Product\Attribute\Source\Status; use ...
0
votes
1answer
29 views

Custom Controller goes to 404 in Magento 2?

I have created a custom controller and die on controller execute page but it goes to 404 ? COntroller file ( path : app/code/Mageplaza/HelloWorld/Controller/Index/helloworld.php ) <?php namespace ...
0
votes
1answer
29 views

Magento 2.3.5: How to get csv from the WEB directory of Module?

I want to get csv file from web folder of custom module in magento 2 so how can i do this. please help me. Thanks In Advance.
1
vote
0answers
46 views

Magento 2 add text input to massaction from dropdown

In magento 1, if I wanted to add a text input to send a custom value with my massaction to my controller, I would do something like: $this->getMassactionBlock()->addItem('add_ship_method', array(...

1
2 3 4 5
19