Questions tagged [controllers]

Denotes questions about controllers and action methods

Filter by
Sorted by
Tagged with
0 votes
0 answers
7 views

Submitting a form on a CMS page that is loading a template file is returning a 404 error on the post request

I think I am running into a routing issue where my post request is not reaching my controller. Test/Example/view/frontend/templates/swatches.phtml <form action="<? echo $block->getUrl('...
1 vote
1 answer
1k views

How to override Product details Page controller magento 2

hi all, i want to override Magento\Catalog\Controller\Product\View.php file i tried to override but it's not loading the product page. <?php /** * * Copyright © Magento, Inc. All rights ...
0 votes
1 answer
2k 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 ...
2 votes
1 answer
2k 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="<?...
0 votes
1 answer
1k 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-...
4 votes
2 answers
2k 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 ...
0 votes
3 answers
18k 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(){ ...
0 votes
2 answers
3k 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
1 answer
352 views

Bundle_option_qty not working, with programmatically add bundle product to cart (magento 2.3.2)

I would like to add a bundle product to cart programmatically, however i'm experiencing a problem with the bundle_option_qty. I can change the selection of the bundle option, however the code is ...
0 votes
1 answer
1k 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 ...
0 votes
1 answer
2k 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 ...
0 votes
1 answer
2k views

Magento 2 controller redirect on button click in phtml file

I want to redirect customer using controller when button is clicked in one of my phtml files. So far I got, controller: public function execute(){ return $this->addToCart(); } public ...
1 vote
2 answers
5k 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 ...
1 vote
2 answers
2k views

How to call front controller from javascript?

How can I call my custom controller through javascript? Any way by which I can pass the url of controller and call that with "parameter"?
0 votes
1 answer
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
2 answers
2k 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 ...
1 vote
1 answer
2k 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
1 answer
2k views

Magento controller only executing once - cannot disable cache

I have a controller that only executes once after the cache is cleared. After that the response is always the same - cache is there instead of a new execution. The class is extends\Magento\Framework\...
1 vote
1 answer
32 views

Having trouble refactoring Submit Index class that extends deprecated Magento\Framework\App\Action\Action;

<?php namespace Alex\AskQuestion\Controller\Submit; use Alex\AskQuestion\Model\AskQuestionFactory; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; use Magento\...
0 votes
0 answers
70 views

How can I set a different home page depending on customer group (including people not logged in) on Magento 2.4?

I want to change homepage based on customer group. I tried defining a plugin in this post Magento 2: Change hompage on login , But it doesn't seem to work for me. I could override the CMS default ...
0 votes
1 answer
42 views

Argument 5 passed to Vendor\Module\Model\ResourceModel\PriceResult\Collection\Interceptor::__construct()

I have created a custom module and it's working fine,if I only run php bin/magento setup:upgrade command. However, when I attempt to run php bin/magento s:d:c it raises an exception. Type Error ...
9 votes
4 answers
12k views

magento2.3 controller won't handle post method

This is something I used to be able to do in 2.2, but in 2.3 I can't. A simple controller to handle a POST method, and only receive and send application/json content type. It works for GET/PUT ...
1 vote
2 answers
2k views

How to override the category controller in Magento 2.3?

How to override the category controller in Magento 2.3? Please give me any solution?
0 votes
0 answers
27 views

MassAction if I select all items I get NULL in the controller

I have this grid: <?xml version="1.0" encoding="UTF-8"?> <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=&...
0 votes
1 answer
281 views

Requesting controller action via Curl request

I am sending a CURL request to a controller action and construct() function is working (called) but it doesn't call the execute() function of the controller. For now, I am calling the execute() ...
1 vote
9 answers
7k views

simple Controller not working with Magento2

Trying to follow this https://www.mageplaza.com/magento-2-module-development/ to create a module, but nothing is working for me. I am using Magento with xampp. My root folder name is Magento2 path: ...
6 votes
3 answers
28k views

Retreive and return response from controller in magento2

I have a problem in which I'm making an AJAX call to a controller. But, I am not able to check whether it is working or not. I also want to return data in response. But, it keeps throwing some errors. ...
0 votes
1 answer
25 views

Need a block to cache its result regardless if it called from the controller or the template

I have a block with a function getParts() which is called from a template. This function does a bunch of queries and returns an array of data. I need to make it so if it does not return any data, a ...
3 votes
1 answer
5k views

Magento 2 - How to add Popup on Custom Button in Order View Page and pass information to Controller for further action?

I have added a custom button on the Sales Order View page in Admin using Plugin. When that button clicks it should open a popup with form and when I submit that form then this information should pass ...
1 vote
1 answer
2k views

Magento 2 - Call Ajax controller on click of place order?

I've set up the JS, and controller and checkout.html I need to call the controller with ajax to getPrice() method. My controller name is GetAjax.php and here is the controller code. <?php ...
0 votes
2 answers
97 views

Email already exist in db validation

I need help on to correct my implementation on validating the email if it's already exists. Anyone knows what's wrong with my code? It is not validating this part. It will save even if the email ...
0 votes
1 answer
89 views

Magento2: get values to databse

I'm trying to get values from the popup model of radio buttons into the database and I'm not getting that, what am I doing wrong? BLOCK FILE <?php namespace vendor\ThreeYearOrders\Block; use ...
0 votes
0 answers
24 views

Redirect Disabled child categories to the Parent Category

I want to redirect the Redirect Disabled child categories to the Parent Category.
3 votes
2 answers
1k views

Max URL Levels in Controller Magento 2

I have custom controller outputting JSON format which works well for the below URL level; ** Works base url/module/folder/action //equates to Vendor\Module\Controller\Folder\Index.php However I ...
0 votes
1 answer
153 views

How to add Progress Bar in Save Controller Magento2?

I wanted to add a progress bar while the code in Save controller is executing on Clicking Save Button in Ui_component Form in Magento2? How Can I implement this Thanks !!
3 votes
0 answers
50 views

Troubleshoot issue with controller [closed]

How to manage troubleshoot issue with controllers are not working and returning is erroremphasized text
0 votes
1 answer
592 views

Save custom frontend form data to database magento 2.4.5

I have created custom form on frontend and now on submit click I want to save filled data to database. module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/...
3 votes
2 answers
8k views

How to create a new email template in a custom module on Magento 1

I created a new module to overwrite the AddressController.php controller. Here I make some changes and i receive some data from the customer address form. What I want to do now is to take all the ...
2 votes
2 answers
9k views

Magento 2 headers already sent error in my controller

I am working through Alan Storm's tutorial about the first steps in setting up a Controller in Magento 2 and came across an odd little error on page load after setting up my route: Warning: Cannot ...
1 vote
1 answer
235 views

How to execute Cron from controller file in magento2

I have created a UI form admin html. I have a requirement when the form is saved, Need to fetch data from custom module and perform some action. The logic is working but if I have records of more than ...
2 votes
2 answers
5k 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 ...
4 votes
2 answers
5k 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
2 answers
150 views

Cron job generates a different output compared with a controller in Magento 2.4.1

I implemented a custom plugin that loops through all products and generates a CSV file. Even if the execute() function has the same code in both files (cron job and controller), the CSV file generated ...
0 votes
2 answers
285 views

Custom controller action to specific path in magento 1.9

how to redirect the custom controller path to specific store name http://testurl.com/testmodule/index/testview/id/123/ to http://testurl.com/testname thanks
1 vote
1 answer
1k views

Controller _forward and Full Page Cache

I found an interesting workaround for an issue I was having; not sure if it's best-practice, but I was wondering if someone could explain to me how this works: I needed to provide a check on ...
2 votes
2 answers
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 from phtml and pasted them into a new phtml file. However, submitting the form redirects to the ...
0 votes
2 answers
299 views

Controller method does not work

I'm using Magento 1.8.1.0 community edition. I have managed to add a custom admin controller and the default indexAction() method does work. However, if I try to access the other method, ...
0 votes
1 answer
500 views

Magento 2: Controller Invalid return type for Account Controller

Just wrote the following controller: namespace MySite\MyCustomModule\Controller\Dashboard; use Magento\Customer\Controller\AccountInterface; use Magento\Framework\App\Action\HttpGetActionInterface as ...
0 votes
1 answer
21 views

Page cannot be found from controller even set the routes.xml

I want to add a page by the controller, I have set the routes and controller files according to the guideline. However, it still cant show the page. app/code/Mymodule/OrderController/Controller/Page/...
2 votes
3 answers
1k 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> ...

1
2 3 4 5
20