Questions tagged [controllers]

Denotes questions about controllers and action methods

0
votes
0answers
5 views

Custom Customer Account Dashboard link 404s on every hit

I'm desperate for help... I've tried everything I could on my own, read everything I can, but nothing is working. I'm developing an extension on Magento 2.3.1, and have followed, I don't know, every ...
2
votes
0answers
28 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
20 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
25 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
34 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
130 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
23 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
19 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
16 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
35 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
45 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
29 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
47 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
81 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
43 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
65 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
17 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
34 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
44 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
122 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
32 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 ...
1
vote
0answers
15 views

Magento 1.7 - Blank page on login and checkout

I'm having some trouble with the login page and the checkout page. Here is the debug message whenever i try to login (just show a blank page): Notice: Undefined variable: message in /home/235880....
0
votes
0answers
34 views

How to add massaction in product grid in magento 1

What is the easiest way to add add mass action to product grid using only observer and controller(no block). I would like to see a simple example because it is the first time I create it.
2
votes
2answers
60 views

Magento 2 secret key problem

I've a form that performs an Ajax call to a controller, but the response always is You entered an invalid Secret Key. Please refresh the page. PereiraTech/Faturamento/Controller/Adminhtml/Ac/Index....
3
votes
2answers
65 views

Magento 2 - Unable to Get Request Params in controller

I am trying to get input data in the controller but controller not getting url params. <?php namespace Crud\Crudatfrontend\Controller\Result; use Magento\Framework\App\Action\Context; use ...
2
votes
1answer
30 views

Magento 2.1.7 - Unable to send form data to controller using AJAX

I am trying to fetch input value but I am unable to get values in the controller. Here is my code, Controller\Index\Index.php <?php namespace Crud\Crudatfrontend\Controller\Index; class Index ...
1
vote
0answers
20 views

how to fix 5.5.2 Syntax error. m189sm22281031qkf.2 - gsmtp in magento 2 email [closed]

controller delete.php <?php namespace Webkul\Mpquotesystem\Controller\Adminhtml\Managequotes; use Magento\Backend\App\Action; use Webkul\Mpquotesystem; class Delete extends \Magento\Backend\...
0
votes
0answers
16 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. ...
3
votes
2answers
72 views

set x-frame-options in custom controller magento2

I have a custom controller with below code. namespace Vendor\Module\Controller\Service; class Login extends \Magento\Framework\App\Action\Action{ protected $_storeManager; protected $_customerFactory;...
0
votes
0answers
18 views

How to set the coupon on the specific product using SKU. Magento 2

I followed this code $price = 100; $sku = '24-WG085'; $discount = ($price - (($price + 1) / 2)); $shoppingCartPriceRule = $this->_objectManager->create('Magento\SalesRule\Model\Rule'); $...
0
votes
1answer
34 views

Cannot call my custom Helper Class. Magento 2

I'm trying to call my custom Helper class in Controller but when I call the function of my helper in Controller it gives me Fatal error: Uncaught Error: Call to undefined method Magento\Backend\Helper\...
0
votes
1answer
25 views

call a controller in other module

I've installed a module and I need to get some value from frontend and pass it to a controller in my module. is it a good practice to update in other module js files that are not created by me? and ...
0
votes
0answers
71 views

Magento 2.3.1 Download an excel file with PHPSpreadsheet

Trying to create a download button for an Xlsx file. Using PHPSpreadsheet for this however when downloading the file it seems corrupted with a stack trace at the bottom of excel files: Stack trace: #...
1
vote
0answers
78 views

Ajax call always returns in error from controller Magento 2

From my controller, I return a JSON data to my Ajax call but it always goes in the error section, even when it's not an error. jQuery.ajax({ type: 'POST', url: '/yxcustomer/index/...
1
vote
1answer
58 views

Unable to get newly inserted Product's Id using After Plugin for Catalog Product save controller method

I have created interceptor for catalog product controller's save action <type name="Magento\Catalog\Controller\Adminhtml\Product\Save"> <plugin name="ricky_catalog_save_product" ...
0
votes
1answer
53 views

Magento 2 : custom controller with multiple functions (actions) [closed]

i need index controller file in that i need to write addaction,deleteaction,getinfo,updateaction, like this place code multiple functions.same as like magento 1 after thaif i want add data can call ...
3
votes
2answers
167 views

Allow only one qty of item into cart in Magento 2

I have created a custom controller in my module and calling via ajax to add the item to cart. Below is my controller code. <?php namespace {Vendor}\{Module}\Controller\Product; ...
1
vote
1answer
72 views

UI component save button controller magento 2

I have UI admin form xml file. I've got SaveButton.php block file, but I need to save form in db. As far as I know I need controller. How this controller would look like and in which directory it ...
6
votes
2answers
485 views

“We can't save the customer” error after Migration - Magento 2.3

I have migrated store from Magento 1.7.0.2 to Magento 2.3. When i Create the customer it shows me error "We can't save the customer." I have checked log file and i can see log, "Class Magento\Eav\...
2
votes
1answer
21 views

How to call a function which is in a overwritten controller block?

I have developed a module to overwrite a controller. I have the next route: Lecasa/Javinewlistproductcontroller/Block/Catalog/Product/List.phtml This List.phtml file is: class ...
0
votes
0answers
13 views

Trouble understanding Magento 2 context DI order in core code

In the module-customer/Controller/Adminhtml/Group , the Context class is passed into the __construct method 3rd to last, before the resultForwardFactory and resultPageFactory factory classes. ...
1
vote
1answer
28 views

Which block file calls for My Account page when it loads

I have written some helper functions, which does some database inserts The problem is I am calling all these functions from my phtml which gets loaded first time when My account is loaded for the ...
1
vote
0answers
17 views

How many ways are there to create a controller and what are they?

I have been developing with Magento 1.9 for the last two weeks. I have found several problems to develop each project (probably because my first project with magento had a high level...). I come ...
0
votes
0answers
16 views

Copy the cart to new page, but no action triggered when click on “update shopping cart”

I've copied my cart summary into a new page. I see my cart like if it was in checkout_cart_index, that's ok. But when I change a quantity and click on "update shopping cart", the page reloads and ...
0
votes
1answer
216 views

magento2 file upload Pdf not working

i have create controller for save data but i have not save pdf file so please help me how can fix this issue Thanks!! <?php public function execute() { $resultRedirect = $this->...
3
votes
1answer
47 views

Override OnepageController.php Not Working

I'm trying to override the successAction in the app/code/core/Mage/Checkout/controllers/OnepageController.php. I have done the following: I've created my override folder here: app/code/...
1
vote
1answer
22 views

Magento override Catalog Compare controller doesn't work

for some reason the Compare controller override doesn't work for me, I tried about everything I could find, but it just doesn't happen and I am running out of ideas. Do you see anything I am doing ...
0
votes
2answers
310 views

Add multiple items to cart in Magento2

I am implementing add to cart functionality from ajax using product id. This is my code of template file <tr class="border_bottom child-items selected"> <td >...
1
vote
1answer
227 views

Magento 2 Write to CSV within Controller

I have the following code: protected $_fileSystem; protected $_directoryList; public function __construct( \Magento\Framework\Filesystem $fileSystem, \Magento\Framework\App\Filesystem\...
0
votes
1answer
164 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 ...