Questions tagged [controllers]

Denotes questions about controllers and action methods

Filter by
Sorted by
Tagged with
0 votes
0 answers
56 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 ...
Michel Meyran's user avatar
0 votes
1 answer
41 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 ...
Bushra's user avatar
  • 62
0 votes
0 answers
23 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=&...
elunicotomas's user avatar
0 votes
1 answer
24 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 ...
Nick's user avatar
  • 121
0 votes
2 answers
69 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 ...
jsnewbie21's user avatar
0 votes
1 answer
55 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 ...
Bayzel's user avatar
  • 177
0 votes
0 answers
20 views

Redirect Disabled child categories to the Parent Category

I want to redirect the Redirect Disabled child categories to the Parent Category.
Rana Zain's user avatar
  • 608
0 votes
1 answer
95 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 !!
Syed Hassan Zamir's user avatar
3 votes
0 answers
45 views

Troubleshoot issue with controller [closed]

How to manage troubleshoot issue with controllers are not working and returning is erroremphasized text
Ansari's user avatar
  • 435
0 votes
1 answer
435 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/...
Rakhi Prajapati's user avatar
1 vote
1 answer
190 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 ...
Manjunath's user avatar
  • 177
0 votes
2 answers
123 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 ...
iupaem's user avatar
  • 31
0 votes
1 answer
19 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/...
hill2011's user avatar
0 votes
1 answer
66 views

Which controller the export hits

I'm trying to understand where the controller of export stock sources is being hitted My url is the following /admin/export/export/key/fjkzegjzehgjze/entity/stock_sources/file_format/csv The code ...
Claims's user avatar
  • 1,049
1 vote
0 answers
190 views

Getting value of text field in controller?

Magento 2.3 I added a new text field to review.phtml, it looks like that: <input type="text" id="tel" name="pptel" /> Now in my controller I am trying to get that ...
user4095519's user avatar
0 votes
4 answers
272 views

Why is my post controller returning a 404?

I've created and enabled a module at app/code/Post/Test: app/code/Post/Test/registration.php: <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\...
Timothy Fisher's user avatar
0 votes
2 answers
282 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) { ...
Mohmad Ashik M A's user avatar
0 votes
1 answer
136 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?
Mohmad Ashik M A's user avatar
0 votes
1 answer
453 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 ...
Elf-12's user avatar
  • 11
0 votes
1 answer
666 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 ...
Muhammad Muiz Ather's user avatar
0 votes
2 answers
445 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-...
David Young's user avatar
0 votes
1 answer
137 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) { $...
David Young's user avatar
0 votes
0 answers
66 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 ...
Verdu's user avatar
  • 1,720
-1 votes
1 answer
833 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) ...
Hamendra Sunthwal's user avatar
0 votes
2 answers
715 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 ...
Mohd Farhan Bin Ramli's user avatar
0 votes
0 answers
134 views

Magento 2.4.1 controller cache control

It seems that on my Magento 2 instance the controller methods are somehow cached because I am doing changes, compiling the code, but they are not visible when they are called. I even added a die() ...
iupaem's user avatar
  • 31
0 votes
1 answer
635 views

How to Call Controller When hit any URL from website in Magento 2?

I have my custom controller that has my custom code, now I need to run that code when any URL hits from the site. My Controller URL is like common/index/code run can anyone help me how can I archive ...
Jay Parmar's user avatar
2 votes
2 answers
1k views

Getting information about a request using HttpGetActionInterface

I'm in the process of removing the deprecated Action implementation from my controllers in favor of the ActionInterface implementations. With the old extension approach of the Magento\Framework\App\...
Hurrpadurr's user avatar
0 votes
1 answer
130 views

Get Controller of each request

What I want just to print out name of each controller called at a specific request? So How can I do that any help thanks in advance?
Muhammad Ali's user avatar
0 votes
1 answer
18 views

Can't override magento contact

I seem to be missing something when it comes to overriding controllers. This is a somewhat recurring question in here, but nothing I've found in other questions worked for me, so either they might be ...
Vinícius Machado Fabiano's user avatar
0 votes
3 answers
571 views

Magento 2, How to call Controller custom function?

I have a controller with custom function getPost(). I want to call this function from my phtml My phtml code: <form id="my-form" method="POST" action="<?php echo $block-...
Alok Kumar's user avatar
0 votes
1 answer
164 views

add firstname and lastname in newsletter grid in magento 2.3.x

I want to add firstname and lastname in newsletter grid in Magento 2.3.x. first_name and last_name in newsletter form in frontend. adding columns to databse table "newsletter_subscribers". ...
Deep Shah's user avatar
  • 535
3 votes
1 answer
772 views

Find Routes File For Magento 2 Rest API

I have inherited a Magento 2 site, and I am trying to find the rest api that is handling the checkout. The route is <magento_site>/rest/default/V1/<checkout _information>. As is, i have ...
MCattaneo's user avatar
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-...
Tj1997's user avatar
  • 47
0 votes
1 answer
397 views

How get user information inside of controller

I create route, and controller for it. All works fine if i call route like so. .... return $this->_pageFactory->create(); .... However when I want get user data from Magento\Customer\Model\...
user2217288's user avatar
0 votes
1 answer
432 views

Magento 2 How to create cache for a collection inside controller

Hi am having a controller Search.php every time I do operation it loads all the collection and takes much time to load. So I wanted to cache the custom collection and optimize the loading time. this ...
Praveen Negimani's user avatar
0 votes
1 answer
372 views

How to call controller in observer or block or helper?

How can I call controller in my observer like my observer function is this public function abcd{ //some code/// how to call controller here? } The controller function is execute ...
Asad Ullah's user avatar
  • 1,461
0 votes
1 answer
98 views

pop up modal is not submitting and not going to controller action url?

<?php /** /** @var $block \Magento\Catalog\Block\Product\View */ ?> <?php $_product = $block->getProduct(); ?> <?php $buttonTitle = __('Add to Cart'); ?> <?php $isSaleable = $...
kks's user avatar
  • 19
0 votes
1 answer
31 views

Controller does not work

this is my controller <?php namespace Prevaj\Orderswatches\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { protected $_pageFactory; /** * Undocumented ...
pon aravind's user avatar
0 votes
1 answer
719 views

Magento 2 How to pass variable from Controller to Observer on checkout_cart_product_add_after event

I'm trying to send a $price variable from a controller where I add to cart my product to checkout_cart_product_add_after event observer. Here is my Controller: public function execute(){ $...
Oscar Vazquez's user avatar
0 votes
1 answer
124 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 ...
lucas's user avatar
  • 309
3 votes
2 answers
227 views

email is coming with tags without interpretation

Guys I have a module for sending e-mail, that when sending the e-mail it 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 ...
lucas's user avatar
  • 309
1 vote
1 answer
916 views

Magento 2 Invalid Form Key when post to a controller

I'm trying to send a form from a Java Spring Application to Magento. What I'm doing in Java is just creating an standard form and on action I wrote Magento's controller path. Like this: http://ip/...
Oscar Vazquez's user avatar
0 votes
1 answer
88 views

Magento 2 custom dashboard Page

I want to show a completely custom dashboard. I have a controller for that. I just want to show this page when Admin login. I don't want to show the default Magento dashboard controller I want my ...
Ramesh KR's user avatar
  • 836
0 votes
1 answer
480 views

Magento 2 call url param in Model Collection filter

I'm trying to get some data that matches the id in the URL. I have a param in admin URL like below. seller/items/index/id/9/ I'm using the admin UI component which is working fine. My model code ...
Ramesh KR's user avatar
  • 836
1 vote
1 answer
338 views

Magento 2 : I want to add categories from front-end using controller in Magento 2

Here is the code I am using but it is given error. Please help. Thanks in advance. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $rootCat = $objectManager->create('Magento\...
Shubham Sahu's user avatar
1 vote
2 answers
317 views

Magento 2: Redirect to specific page on customer registration fail

I have made custom registration form which uses Magento's createPost for creating a new customer. On registration fail it is redirecting to customer/account/create I would like it to redirect it to ...
GenZ Dev's user avatar
  • 590
0 votes
0 answers
119 views

My Account reorder link onclick Ajax call controller in magento 2.4

My Account reorder link onclick Ajax call controller in magento 2.3 app/code/Vendorname/Modulename/view/frontend/templates/order/history.phtml <?php if ($this->helper(\Magento\Sales\Helper\...
Ravindrasinh Zala's user avatar
0 votes
1 answer
35 views

Controller to Observer Conversion?

I am new to Magento 2 modules and would like to create a module to run the below class whenever someone accesses the homepage. I believe it would be easier if I converted this to an observer so I just ...
A. Andersen's user avatar
0 votes
1 answer
79 views

Build Customer View URL on Controller

How can I programmatically build this url: http://127.0.0.1/magento2/sales/order/view/order_id/61/? Im in a custom controller with the current Order object.
Sergio Vargas's user avatar

1
2 3 4 5
20