Questions tagged [controllers]

Denotes questions about controllers and action methods

Filter by
Sorted by
Tagged with
0
votes
2answers
123 views

Magento 2 : Can't able to override controller

I need to override this below controller : Magento\Catalog\Controller\Adminhtml\Product\Attribute\Validate.php But, I can't able to override. I need to customize checkUniqueOption() function. di....
0
votes
1answer
66 views

How to set GrandTotal in the magento 2.3 via controller?

Kindly give me an example about how to set GrandTotal via the controller in magento 2.3. I am new to Magento.
0
votes
2answers
1k views

How to get product collection in controller in Magento2

I am creating a new module in magento2 and in controller file, I try to get product collection in controller index.php file so how can I get product collection in Magento 2. so give me suggestion to ...
0
votes
1answer
54 views

magento 2 get first level category from current catgeory ID in controller

I am trying to get first level category from current category ID in my controller . For example- I have Maincategory SubCategory1 SubCategory2 SubChild1 SubChild2. ...
2
votes
1answer
80 views

How to execute custom controller action for product in magento2?

I would like to write some custom code product actions in a controller is executed. When I have click on the product than showing multiple brands and after that click on brand then show product ...
1
vote
1answer
707 views

Magento2 : How To Solve Controller 404 Not Found Error On Live Server

I have create one controller and it is working fine in local environment but when i upload that files to live server is shows 404 not found error, These are my code, please let me know if anyone have ...
0
votes
1answer
124 views

Magento 2: Call Controller method from Model

How to call the controller method from model? Or How to programmatically reindexing using API? Here is my code.Below code gives me error like below. { "messages": { "error": [ ...
2
votes
4answers
435 views

Magento 2: Call to a member function setState() on array

I want to change the order Status programmatically but when I run the function realTest() as I mentioned below then it gives me an error Call to a member function setState() on array in the below ...
0
votes
3answers
137 views

How can I change the Order Status in Controller. Magento 2

I'm trying to change the specific order Order Status. for that I tried. <?php namespace Vendor\Module\Controller\Index; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\...
0
votes
2answers
563 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
2answers
1k views

Magento 2.3: Call to undefined method Magento\Framework\View\Result\Page\Interceptor::setPath()

I want to configure Nextopia Extension, i installed it properly after that when i go to this URL http://mysite.dev.us/nsearch, i get an error like this: And the file /app/code/Nextopia/Search/...
0
votes
2answers
504 views

Get Model Data in ajax request

I am making an ajax request in my module to grab some custom CRUD data to populate a select box on the fly. I have a working ajax request and controller Javascript define(["jquery"], function($){ ...
0
votes
3answers
75 views

Block not showing in custom frontend controller

Here is my custom frontend controller namespace Namespace\Testing\Controller\Payment; class Failure extends \Magento\Framework\App\Action\Action { /** * @var \Magento\Checkout\Model\Session ...
0
votes
2answers
118 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
0
votes
1answer
938 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 ...
0
votes
2answers
170 views

Magento 2: Use a custom controller as website root?

I'm building a little module on magento2 and I can currently access it at mysite.com/test/mymodule. I want to be able to access it at mysite.com. How can I do that? I've tried doing a URL rewrite ...
1
vote
1answer
86 views

GET Products by brand and category

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
1answer
385 views

Magento 2 how to receive a webhook body?

I'm doing an integration with a system called Sift Science. What I need to accomplish is to receive a response whenever someone in Sift Science performs an action (for example> Approve account, ban ...
3
votes
2answers
201 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
74 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
160 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!
0
votes
4answers
529 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
228 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
37 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
25 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\...
3
votes
5answers
1k 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 ...
1
vote
0answers
126 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
741 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 ...
1
vote
1answer
2k 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
72 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
44 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 ...
3
votes
0answers
77 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
26 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
51 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
100 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
630 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
160 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
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 ...
3
votes
2answers
266 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
382 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
24 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
91 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
31 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
287 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 ...
2
votes
2answers
232 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
1k 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
445 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
1answer
183 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
809 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
799 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->...

1 2
3
4 5
19