Questions tagged [controllers]

Denotes questions about controllers and action methods

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

How to Call Controller When hit any URL from website in Magento 2?

I have my custom controller that has my custom code, now I need to run that code when any URL hits from the site. My Controller URL is like common/index/code run can anyone help me how can I archive ...
0
votes
2answers
25 views

Getting information about a request using HttpGetActionInterface

I'm in the process of removing the deprecated Action implementation from my controllers in favor of the ActionInterface implementations. With the old extension approach of the Magento\Framework\App\...
0
votes
1answer
27 views

Get Controller of each request

What I want just to print out name of each controller called at a specific request? So How can I do that any help thanks in advance?
0
votes
1answer
13 views

Can't override magento contact

I seem to be missing something when it comes to overriding controllers. This is a somewhat recurring question in here, but nothing I've found in other questions worked for me, so either they might be ...
0
votes
3answers
33 views

Magento 2, How to call Controller custom function?

I have a controller with custom function getPost(). I want to call this function from my phtml My phtml code: <form id="my-form" method="POST" action="<?php echo $block-...
0
votes
1answer
45 views

add firstname and lastname in newsletter grid in magento 2.3.x

I want to add firstname and lastname in newsletter grid in Magento 2.3.x. first_name and last_name in newsletter form in frontend. adding columns to databse table "newsletter_subscribers". ...
0
votes
0answers
17 views

Why is Delete action not deleting?

Hello newbie developer here. Currently I have made a module that will show a list of stores, with this list you can add, edit, save, and delete. My issue at the moment is that I cant get the store to ...
0
votes
0answers
40 views

Magento 2.4.3 - Notice: Undefined property: $_view - Decomposition of Controllers

I have been trying to create module in Magento 2.4.3 that has significant changes where decomposition is favored instead of inheritance - https://community.magento.com/t5/Magento-DevBlog/Decomposition-...
2
votes
1answer
101 views

Find Routes File For Magento 2 Rest API

I have inherited a Magento 2 site, and I am trying to find the rest api that is handling the checkout. The route is <magento_site>/rest/default/V1/<checkout _information>. As is, i have ...
0
votes
0answers
38 views

How to check if controller is redirected?

I want to put some JS code when the customer is successfully registered. What I found is after register \Magento\Customer\Controller\Account\CreatePost redirect it to the account page. I tried \...
0
votes
1answer
79 views

Magento 2: How to use redirect in Router.php

I am trying to redirect a cms page to a custom controller. in router.php I can check the current URL, If the current URL is as an example if it matches /test-url i want to do a redirect to /test-url-...
0
votes
0answers
15 views

How to create a module to add .well-known/file via controller?

I need to create a dynamic file to add the controller route below and change the content via the admin panel. mystore.com/.well-known/file I can't create a static file, and the admin option is ...
0
votes
1answer
34 views

How get user information inside of controller

I create route, and controller for it. All works fine if i call route like so. .... return $this->_pageFactory->create(); .... However when I want get user data from Magento\Customer\Model\...
0
votes
1answer
31 views

Magento 2 How to create cache for a collection inside controller

Hi am having a controller Search.php every time I do operation it loads all the collection and takes much time to load. So I wanted to cache the custom collection and optimize the loading time. this ...
0
votes
0answers
16 views

Magento 1.9 get post data contactform

I have created a custom contact form with indexcontroller. Emails are sent correctly with full post data but I cannot get the post values in the controller. public function postAction() { $...
0
votes
1answer
52 views

How to call controller in observer or block or helper?

How can I call controller in my observer like my observer function is this public function abcd{ //some code/// how to call controller here? } The controller function is execute ...
0
votes
1answer
16 views

pop up modal is not submitting and not going to controller action url?

<?php /** /** @var $block \Magento\Catalog\Block\Product\View */ ?> <?php $_product = $block->getProduct(); ?> <?php $buttonTitle = __('Add to Cart'); ?> <?php $isSaleable = $...
0
votes
1answer
21 views

Controller does not work

this is my controller <?php namespace Prevaj\Orderswatches\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { protected $_pageFactory; /** * Undocumented ...
0
votes
1answer
156 views

Magento 2 How to pass variable from Controller to Observer on checkout_cart_product_add_after event

I'm trying to send a $price variable from a controller where I add to cart my product to checkout_cart_product_add_after event observer. Here is my Controller: public function execute(){ $...
0
votes
1answer
55 views

gmail receiving html tags - magento 2

Guys I have a module for sending e-mail, which when sending the e-mail is arriving with the html tags, example: br span, that is, it is not being interpreted. I think the code is read by php as a ...
3
votes
2answers
43 views

email is coming with tags without interpretation

Guys I have a module for sending e-mail, that when sending the e-mail it is arriving with the html tags, example: br span, that is, it is not being interpreted. I think the code is read by php as a ...
1
vote
1answer
113 views

Magento 2 Invalid Form Key when post to a controller

I'm trying to send a form from a Java Spring Application to Magento. What I'm doing in Java is just creating an standard form and on action I wrote Magento's controller path. Like this: http://ip/...
0
votes
1answer
28 views

Magento 2 custom dashboard Page

I want to show a completely custom dashboard. I have a controller for that. I just want to show this page when Admin login. I don't want to show the default Magento dashboard controller I want my ...
0
votes
1answer
32 views

Magento 2 call url param in Model Collection filter

I'm trying to get some data that matches the id in the URL. I have a param in admin URL like below. seller/items/index/id/9/ I'm using the admin UI component which is working fine. My model code ...
1
vote
1answer
63 views

Magento 2 : I want to add categories from front-end using controller in Magento 2

Here is the code I am using but it is given error. Please help. Thanks in advance. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $rootCat = $objectManager->create('Magento\...
1
vote
2answers
68 views

Magento 2: Redirect to specific page on customer registration fail

I have made custom registration form which uses Magento's createPost for creating a new customer. On registration fail it is redirecting to customer/account/create I would like it to redirect it to ...
0
votes
0answers
21 views

set three page on one controller action URL

set three url on one controller action. exp: i have three category url like below mydomain.test/seller/index/category/suppermarket mydomain.test/seller/index/category/suppermarket/groceries mydomain....
0
votes
0answers
51 views

My Account reorder link onclick Ajax call controller in magento 2.4

My Account reorder link onclick Ajax call controller in magento 2.3 app/code/Vendorname/Modulename/view/frontend/templates/order/history.phtml <?php if ($this->helper(\Magento\Sales\Helper\...
0
votes
1answer
25 views

Controller to Observer Conversion?

I am new to Magento 2 modules and would like to create a module to run the below class whenever someone accesses the homepage. I believe it would be easier if I converted this to an observer so I just ...
0
votes
1answer
18 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
38 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
18 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
51 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
55 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
16 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
43 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 ...
0
votes
1answer
199 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 ...
0
votes
1answer
56 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
40 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
139 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
130 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
44 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
543 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
98 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 ...
1
vote
2answers
350 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
130 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
24 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
1answer
65 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
30 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
209 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() ->...

1
2 3 4 5
20