Questions tagged [controllers]

Denotes questions about controllers and action methods

Filter by
Sorted by
Tagged with
2
votes
2answers
50 views

Controller URL does not work

I have the problem that i always get the error 404 not found, if I want to get the url of my controller. This is my filestructure: And this is the URL I am trying to get loaded: http://localhost/...
0
votes
1answer
29 views

Send data from controller to phtml in Magento 1

Send data from controller to Phtml in Magento 1. I use ajax send data from phtml to controller and handle it. After processing, I want to send the data back to phtml. And put it on <option value ...
0
votes
2answers
29 views

What are getResponse, getRequest functions? (Bonus: explanation of getUrl)

I don't understand getResponse and getRequest functions of the Mage_Core_Controller_Varien_Action class. EDIT: See below an explanation of getUrl function! Thanks!
-1
votes
0answers
18 views

How to override Controller file [duplicate]

i want to make changes in vendor/magento/module-contact/Controller/Index/Post.php . How can I override Post.php in-app folder? I am using Magento 2.3
0
votes
4answers
121 views

Wishlist ajax remove

I want to remove product from wishlist from a custom button on detail. I did a plugin for the Magento\Wishlist\Controller\Index\Remove.php with an aroundExecute but for some reason I can't load/create ...
1
vote
1answer
24 views

Magento 2: Get value from Cron system.xml

I would like to take the value of the ahead schedule of this system.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:...
0
votes
1answer
27 views

Get value changed in admin grid SaveButton magento 2

I created a custom magento 2 form. As far as saving, I would like to take the modified value in the save.php of the controller. Is there any method I can use? This is my save.php controller <?php ...
0
votes
0answers
16 views

how to get guest email address in CollectTotalsObserver page in magento 2

how to get a guest email address in CollectTotalsObserver page in Magento 2. public function execute(\Magento\Framework\Event\Observer $observer) { /** @var \Magento\Quote\Api\Data\...
0
votes
0answers
45 views

Get Data from Controller

I'm trying to create some type of search method for customers where they select the product's brand they want to search and then, if they want, they can also select the category they want (if there ...
1
vote
5answers
191 views

Magento2: How can I logout customer from controller?

In Magento 2, I want to write a custom controller. Whenever anyone tries to call the controller URL (http://mymagento.com/mycontroller/index/index). It should redirect to this controller an event ...
0
votes
0answers
11 views

Modifying the custom controller url to SEO friendly in Magento 2

I have created my custom module for loading the custom template. Here is the code of Vendor/Module/etc/frontend/routes.xml <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
0
votes
1answer
29 views

Magento 2 How to send data to Controller with Ajax from a template?

I'm trying to send some data to my Controller from a template.html using Ajax, so my checkout page does not refresh when I send a custom form, but I don't get anything, the information is an extra ...
0
votes
0answers
27 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
37 views

I am overriding a controller and want to use a custom helper in the overrided controller,how can i?

I've overridden following controller:- Magento\Customer\Controller\Account\CreatePost.php And the constructor method of this class is:- public function __construct( Context $context, ...
0
votes
0answers
38 views

Magento 2 custom product attribute

Need help/idea's for the following: We have products which can be applied to different car models and car manufacturers. So field manufacturer is multi-select, populating this field is not a problem ...
0
votes
0answers
12 views

Magento 2.3.1 in multi shipping overview Post controller page not working go to Success page

Magento2.3.1 in multi shipping overview Post controller page not working go to Success page Page Redirect is not working how to solve this issues ? Payment id is not showing on this page ???? vendor/...
2
votes
0answers
18 views

Production mode doesnt load any content for custom module

I have created a custom module in Magento 2. In developer mode it is working well, however same module does not show any content in the production mode of Magento its show only white screen. There is ...
0
votes
0answers
23 views

How to edit customer information with custom attributes Magento 2

I have created 2 custom attributes and one is a select type so I succeed to make them appear in the form of edit account but when trying to save I get an error and I am stuck there. I also have two ...
0
votes
0answers
22 views

controller not reaching magento2

One strange thing is happing in my application, I have one custom link in my email. On development server everything works fine, but on production server when I clicked the link nothing happens, ...
0
votes
0answers
30 views

Magento2 redirecting to homepage

Can anyone let me know why below code of refer URL redirects to homepage, instead of last page visited in controller ? This happens only in live website, beta website works perfect: $resultRedirect ...
1
vote
1answer
47 views

Update record error : “Unique constraint violation found” in magento2

In the controller, I am inserting and updating data. But when record is already exist it's not update it's again try to insert so i am getting above error: if(!$checkoutPrescriptionCollection->...
3
votes
1answer
80 views

How can I make my controller return JSON back to my template PHTML

Controller: <?php namespace MyCompany\ExampleAdminNewPage\Controller\Adminhtml\Product; use Magento\Framework\App\Action\Context; use Magento\Framework\Controller\ResultFactory; class Product ...
2
votes
2answers
29 views

Magento 2 - Email attachment is not working in my controler

Here is my code. $pdfFile = 'pub/pdf/13_rajeshnagappan2016@gmail.com.pdf'; $store = $this->_storeManager->getStore()->getId(); $transport = $this->_transportBuilder->...
0
votes
0answers
24 views

Magento 1.9 Success Message Not Showing on Product Page Redirect

I am having trouble getting the success message to be shown when redirecting to a product page from my controller. No success message is shown on the product page when redirected. However, success ...
0
votes
0answers
12 views

Magento 2 : How to load iframe from admin controller

I call iframe in block function and call in phtml. Iframe display also. But, it's display outside that page. I want to display from controller. How to do that? Any help would be appreciated. Thanks....
0
votes
1answer
28 views

Access specified product on custom URL

Greetings StackExchange. I' have a task where I cannot google anything on the subject. I want to create a copy of the standard Magento product view but it should be accessible on a custom URL. I ...
2
votes
2answers
79 views

Magento2: Custom module not working

I have created new module but it is not working.Please Help me on this. registration <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\...
4
votes
1answer
99 views

Class 'Magento\TestFramework\TestCase\AbstractController' not found when running unit test for custom module

I tried to make a unit test for my custom module like this: app/code/MyCompany/UnitTest/Test/Unit/Controller/SpinTest.php namespace MyCompany\UnitTest\Controller; class SpinTest extends \Magento\...
1
vote
0answers
23 views

Magento2: Block Controller Issue

When I call to controller first time showing my data on page after some seconds data not showing on page. page is showing blank. Controller public function execute() { $itemid = $this->...
1
vote
2answers
36 views

Custom Customer Account Dashboard link 404s on every hit

I'm hoping for the community's help on a head scratcher. I'm developing an extension on Magento 2.3.1, and have followed every single guide I've found / including using the magento 2.3 devdocs for ...
2
votes
0answers
30 views

Dynamically hide mutiselect for different actions

In Magento 2, I have 2 actions in my controller: newAction() and edit(). Both actions will use for a same form with few inputs. Among them is multiselect for store selection. I want to show it when I ...
1
vote
1answer
32 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 ...
4
votes
0answers
35 views

Unable to add multiple Products to cart in magento2

I have used below code in my controller. use Magento\Framework\Controller\ResultFactory; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; class Addtocart extends \...
2
votes
2answers
42 views

How to get Current Module and Full Action Name in ajax controller

I need Full Action Name in Ajax Controller Magento 2. protected $request; public function __construct( ... \Magento\Framework\App\Request\Http $request ) { $this->request = $request; }...
1
vote
4answers
161 views

Magento2: How to fix error not showing?

When I submit data to saveprofile.php (controller). saveprofile.php use Magento\Authorization\Model\UserContextInterface as UserContextInterface; use Magento\Authorization\Model\Acl\Role\User as ...
1
vote
1answer
26 views

Magento 2 How to include custom library in controller

I have created custom extension with some library classes. I have placed the libraries in lib/internal/SSOSdk folder. I need to include one of the library class in my controller. I have used the below ...
0
votes
0answers
66 views

Magento 2.3 - Custom Payment Method error on install - Type Error occurred when creating object: Magento\Framework\Communication\Config\Data

I want to install a payment module, but i got this error. Magento clean instal. When i run setup:upgrade i got: Running schema recurring...Type Error occurred when creating object: Magento\Framework\...
0
votes
1answer
18 views

Magento 2 : Form data not saving

I have an XML form on the backend. It has the save button the code for which is this - class SaveButton implements \Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface { ...
2
votes
1answer
77 views

Magento2 controller redirecting to blank page

Magento2 after executing the file controller redirecting to a blank page. can anyone please help me? $this->_view->loadLayout(); $this->_view->renderLayout(); routes.xml <...
1
vote
1answer
52 views

Pass parameter to controller from template Magento 2

I am creating product programmatically on controller action. I want to send price value from template file. This is my controller: public function execute() { if (!$this->session->...
0
votes
1answer
38 views

How to add custom option price when product is adding add to cart using controller

I have to add the custom option price when product is adding add to cart using controller
0
votes
1answer
80 views

Magento 2.3: Mass Action For Status Not Working

I'm very new to Magento 2.3, i created a Mass Action for Status Change, when i open action dropdown and click Change status a tree menu should open with 2 options, but when i click on Change status ...
1
vote
1answer
269 views

Magento2: How can call observer function in controller file?

I have created a custom observer below: Observer file public function abc($order,$itemIds) { } Controller file public function aaa($order,$itemIds) { here we want to call abc($order,$itemIds);...
1
vote
2answers
44 views

Get product views in Controller

If anyone could help me. My curent value that I get is '0' in my controller: foreach($productCollection as $product) { $_helper_views =$this->helper_views->getProductCount($...
2
votes
1answer
69 views

Magento 2 - Frontend Controller conditional based 404 page

I have custom frontend controller, I added the URL Rewrite for this controller I want to figure out the way, How I send requesting URL to 404 page based on some condition within the controller. I ...
0
votes
0answers
23 views

Not able to set cookie in observer

I am trying to set a cookie on the observer "catalog_controller_category_init_after" but it does not create the cookie but when I do exit after set cookie it will create cookie after I remove exit ...
0
votes
2answers
51 views

Magento 2 : Use of echo language construct is discouraged

i had develop magento 2 extension and i have use ajax call to my controller for getting some data. but coding standard provide me some error my controller code is ...... public function execute() {...
1
vote
1answer
55 views

Can we redirect controller to another controller in another custom function rather execute function?

Can we redirect controller to another controller in such a way that previous controller continue its working in its execute method and next controller works render the layout at a same time? and after ...
1
vote
2answers
134 views

Magento 2 - Controller with parameter

I want to create the controller which get the parameter like http://example.com/manufacturerpages/index/id/497 When I do this, It goes to 404 error plus I am also not able to get the id in ...
1
vote
1answer
41 views

how to use post method to contoller and phtml for button event in magento 2

I have a button in phtml file some.phtml <button class="example-button-1 example-button-3 :active" type="button" id="acceptnow" ><span>Active</span></button> I want to ...