Questions tagged [controllers]

Denotes questions about controllers and action methods

Filter by
Sorted by
Tagged with
1 vote
2 answers
4k 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 ...
3 votes
1 answer
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 ...
3 votes
2 answers
4k 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
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 ...
5 votes
4 answers
18k views

Magento 2: how to call checkout session in controller?

Please anyone tell me, how to call checkout session in module's controller? this method doesn't work for me <?php namespace Demo\Demo\Controller\Demo; class Demo extends \Magento\Framework\App\...
0 votes
1 answer
27 views

what is the correct way to add ajax url?

My controller file is Vendor/MultipleCustomerAccount/Controller/Account/LogoutPost.php what should be the ajax url?
0 votes
0 answers
22 views

Magento2: How to get controller URL without index/index and how to access parameter in controller?

I am using magento2.4.3-p2 and I want to access the controller URL without index/index AND parameter. for example https://example.com/product-info/A123456 I want to access A123456 code from this URL ...
0 votes
2 answers
45 views

What is wrong in my ajax url?

I have written the following code the js $.ajax({ showLoader: true, cache: false, url: url.build('multiplecustomer/account/Logout'), type: "POST", }).done(function (data) { ...
0 votes
2 answers
2k views

Magento 2 how to get all categories of a product in controller

I am trying to get all categories with their levels of a product through it's ID in my controller which is overriding default magento controller. Can I get product's category path url through it's id ...
1 vote
2 answers
4k 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
1 answer
1k 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 ...
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 ...
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
0 answers
39 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
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
26 views

Send Custom Data to Controller

I am new to magento 2. I want to send the day and time option selected by user at checkout to my Controller. When the user selects a day and time slot from the dropdown, it gets the value but I do not ...
1 vote
1 answer
6k views

Doing simple Ajax call - ajax URL not outputting anything

app/etc/modules/Custom_Customajax.xml <?xml version="1.0"?> <config> <modules> <Custom_Customajax> <active>true</active> <...
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:"...
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
23 views

Magento 2 How create front controller with a specific path?

I want create controller for specific path, but i can't know how i can do this. My controller must work with path like: site.com/usa/some-review/dynamicParam My path for controller: site.com/some-...
3 votes
2 answers
3k 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" ...
0 votes
1 answer
25 views

My custom POST Controller return empty response

I created my custom Controller for POST request, but i all time have empty response. $testIds = $this->request->getPost('test'); $items = []; foreach ($testIds as $id) { $...
1 vote
1 answer
11k views

How to configure custom admin module to show phtml file

I try to set up my admin module. I was using this this tutorial. Now when I click my new tabs in admin area the URL looks like this http://.../index.php/admin/custom/index/key/...
1 vote
3 answers
4k views

pass data from module controller to layout

i make a simple module and i want to get all products of category and pass these products to my layout file. as well as i want to get products of a specific category and display these to my layout or ...
2 votes
0 answers
55 views

Implimenting Custom Controller with payment option issues [closed]

I'm hoping someone can contribute to my complex issue. We have implemented a custom registration form with the aim of enrolling 'consultants'. Part of this enrollment is to order a special starter ...
0 votes
1 answer
1k 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
2 answers
1k views

Redirect Form Action to Controller (404 error on form submit)

I'm new to Magento. Need to create an extension which will enable to add comments to products on 'product view' pages. I created a new tab next to "descriptions" and "reviews" and added the form, but ...
2 votes
1 answer
2k views

Rewriting app/code/core/Mage/Catalog/controllers/Product/CompareController.php

I am trying to rewrite app/code/core/Mage/Catalog/controllers/Product/CompareController.php. In my config.xml I have the following: <frontend> <routers> <catalog> <...
3 votes
1 answer
958 views

extending a controller and model that are already extended

Below is my attempt to overwrite two pieces of magento core / enterprise code. However, I'm unsure as to how to overwrite these because they're already extensions of other pieces of code. Any ...
0 votes
0 answers
23 views

Magento 2 : preference for reviews post controller error:Type Error occurred when creating object:

I get this error Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: I created a prefernce for review controller Post and added the construct method ...
3 votes
1 answer
2k views

How to add a saveAndContinueEdit type button in admin view order?

I have created a module to implement a new product option type. This product option can be configured from the admin view order page : and for each product that has this option, I have a radio button ...
3 votes
1 answer
2k views

Rewriting controller vs. adding a new controller to an existing module

I'm looking at a community extension called Ambassador_Affiliate, and it's doing something that I have not seen before. I'm not sure what it's doing, so I'd like to check with the community. In ...
5 votes
3 answers
3k views

Constructor for Magento Controller

I need constructor or init function that can be run for my custom module. I need to call it every time when request made to my module's controller in magento.
7 votes
4 answers
13k views

Call action after "Save Config" was clicked in the admin

How can I call an action of my controller in a custom module after "Save Config" was clicked in System --> Configuration --> Catalog? (image) Settings of my module are inside that section, and I need ...
11 votes
1 answer
4k views

How do I make my custom module pages use SSL?

I've created a Module with some pages and I'm wondering how do I force this pages to use SSL on the url, like the customer login page. Not all of the pages need it, but some do. What comes to mind (...
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> ...
0 votes
2 answers
2k 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
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="<?...
3 votes
1 answer
695 views

Setting X-Magento Tags for custom controller

I have a custom controller for infinite scroll and filtered attributes which simply returns a json response. When modifying a category or product these cached responses are not cleared however. ...
0 votes
0 answers
32 views

magento 2.4.3 Request validation failed for action "\Controller\Adminhtml\Import\Save\

4.3 admin custom controller redirecting to dashboard <form enctype="multipart/form-data" method="post" action="<?php echo $block->getFormAction(); ?>" id=&...
1 vote
0 answers
22 views

Magento 2 : Redirect to customer after login to previous URL

For ex. suppose I open this URL before login. https://d89a529178.nxcli.net/hbftextiles/cuttingapproval/cfa/edit/id/43080 Actual result: It opens up the login page, once I log in it redirects to the ...
0 votes
3 answers
17k 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"> &...
0 votes
1 answer
277 views

Error on Di compile magento 2

I have set up Magento 2.4.4. On di:compile I am getting this error. Class "Hybrid_Provider_Model_OAuth2" not found#0 /var/www/vhosts/any.com/dev2.any.com/vendor/composer/ClassLoader.php(571) ...
0 votes
0 answers
4 views

Duplicate the website is rendering my custom page blank

Due to some issues, my had to duplicate by website on another server, with the same specs (php version, apache...) But for some reason, some of my page are not blank. I've seen this before, I changed ...
0 votes
2 answers
178 views

Magento 2 Custom Controller Action Created Using New Module Route Not Working

I am using magento2.3.5-p2 community edition ( open source ) I want to create a custom Controller so that I can post data using ajax to the Controller function created client side will call the ...
0 votes
0 answers
143 views

Add UI Component in the Custom Block

Made the layout file in which I have called the custom block. <?xml version="1.0" encoding="UTF-8"?> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
1 vote
1 answer
9k views

Remove or manipulate parameters in controller

I am trying to remove a parameter under certain conditions when it is passed to my controller. The var_dump of the request contains all the parameters. The parameter I want to remove is called ...
0 votes
1 answer
104 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 ...
0 votes
0 answers
24 views

Multiple image upload with preview at frontend side. - M2

I have custom form in phtml template file. i want to add multiple image upload with image preview functionality as showing in above image. Can anyone guide me how i can create such functionality. ...

1
2 3 4 5
20