Questions tagged [controllers]

Denotes questions about controllers and action methods

197 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
98 views

How to do the same controller action to create an image for one button but not for another?

We are calling same controller action for 2 buttons for create product pro-grammatically and assign a custom image for that product. 1. create - custom image uploading for newly created product 2. ...
5
votes
0answers
1k views

How to add product to wishlist after login by guest customer?

Add to wishlist is being done in AJAX for online customers and the products are successfully added in wishlist. For offline/guests, if they click add to wishlist a pop-up is shown with link to login. ...
4
votes
1answer
380 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\...
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 ...
3
votes
1answer
389 views

How to return search API response from controller in magento 2?

I have an API(ukvehicledata) for search using registration id. I want to integrate with magento 2.2 I am getting response in controller as JSON format. I have converted it into an array. Now I ...
3
votes
0answers
95 views

Disable the full_page cache for a specific controller

I have a controller that I want to exclude from the full page cache however want to cache the block rendered within the controller. I have tried the below code however this does not seem to work: ...
3
votes
1answer
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
0answers
74 views

Block data are not shown in PHML magento 2

I am new to Magento 2 module development. I have a custom table sample_data(id,sample_text,sample_number) I want to fetch a listing of this custom table.But unfortunately when I type www....
3
votes
0answers
147 views

How to save/select a custom phml form in DB on Magento 2

I have created a custom module, and i have this phtml: <div class="container-club"> <h2>test<h2> <div class="club-img"> </div> <div class="club-...
3
votes
2answers
3k 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 ...
2
votes
0answers
65 views

Redirect to Magento2 website with session id

We have a small requirement like a punchout payload concept. The user will redirect to Magento 2 website from 3rd party with the session_id. We want to capture that session_id and implement our logic. ...
2
votes
1answer
277 views

Magento 2.3 - How to pass array from controller to template

I am working on a custom module. I am getting array of attribute values in my custom controller and I want to pass these values in my template to list in a select dropdown. Please provide a solution - ...
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 ...
2
votes
1answer
89 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 ...
2
votes
1answer
251 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 ...
2
votes
0answers
436 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. ...
2
votes
1answer
39 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 ...
2
votes
1answer
531 views

I want add the extra fee on the checkout page using controller Magento 1

I have developed one module for membership.There are three option for membership on order review section.Custom fee will add the based on the membership selection.I have download the custom fee module ...
2
votes
0answers
406 views

Magento 2 : How to remove block from controller?

I've been trying to remove block from controller. I can able to render from controller but i need to remove existing layout block when new one render. Vendor\Module\Controller\Grouprequest.php &...
2
votes
1answer
264 views

Braintree and Kount (GENE version 2.2.3) installation on Magento ver. 1.14.0.1

I'm trying to configure ENS via a Braintree, Kount, Magento workflow, and are experiencing errors that i'm unable to diagnose. Here's what I'm doing: Order # 100096149 | Jan 8, 2018 3:51:07 PM (...
2
votes
1answer
1k views

Magento 2 add new Button in admin Controller

I am working on module which will work for sync product from Third party Api.I have already created admin controller page but don't have Idea how to add button Sync Products whose action will call a ...
2
votes
0answers
436 views

Changing the currency format in index page

I am trying to set the currency format in My magento store based on the option selected by the customer. When customers click on an option in the header I am redirecting them to a page called check....
2
votes
1answer
398 views

CRUD logic in Controller or Block?

I have referred several blogs which explains CRUD functionality, some of the blogs write code like saving a model, in a Controller and some in a Block. Blogs CRUD functionality in Block : http://...
2
votes
3answers
987 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> ...
2
votes
0answers
1k views

Magento 2.x - Adding product to quote, but quote is not stored in properly

[edit: one problem solved, one remaining (details at the end of this post)] I am trying to add products programmatically to the shopping cart but have problems with storing the cart. I am using the ...
2
votes
1answer
796 views

Magento 2.1: Letter Case for Controller Actions URL Route

I tried to create a custom payment gateway by creating a custom module based on Paypal module, specically Paypal Express Checkout. I was able to replicate the route for controller actions: Start, ...
2
votes
2answers
508 views

ajax Customer register how to continue the process?

In my custom controller I am checking if customer is logged in or not.If not redirects to customer login page . public function customaddAction() { if(!Mage::helper('customer')->isLoggedIn()) ...
2
votes
2answers
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 form phtml and pasted it into a new phtml file. However, submitting the form redirects to the contacts ...
2
votes
1answer
339 views

Extending Core Controller isn't Working

I am need of making a change to the Magento function _checkBaseUrl found within: app/code/core/Mage/Core/Controller/Varien/Front.php As best practice I am trying to extend it with my own module so I ...
2
votes
1answer
682 views

Magento 2 Controller response very slow

I've written an ajax call to get some user specific content. But I found that the response of the ajax call is very slow. Indeed, I found that this is due to the slow response of the controller class. ...
1
vote
0answers
46 views

Magento 2 add text input to massaction from dropdown

In magento 1, if I wanted to add a text input to send a custom value with my massaction to my controller, I would do something like: $this->getMassactionBlock()->addItem('add_ship_method', array(...
1
vote
0answers
97 views

How to call function in my controller in browser url which shows 'hello world' in magento 2.3.5

I am here trying to make a hello world message when trying to access my controller function using browser url demomagento.com/app/code/Icosmoz/Unicenta/Controller/Adminhtml/Home/index.php This is the ...
1
vote
0answers
66 views

Bundle_option_qty not working, with programmatically add bundle product to cart (magento 2.3.2)

I would like to add a bundle product to cart programmatically, however i'm experiencing a problem with the bundle_option_qty. I can change the selection of the bundle option, however the code is ...
1
vote
0answers
75 views

Error add new block into block Magento 2

I'm using Magento 2.3.4 and t tried to append a block to another block like this in my controller: $category_list_subcategories = $resultPage->getLayout()->getBlock('promotion.view....
1
vote
0answers
35 views

Excess qty adding into cart when adding product in cart with custom option programmatically

I am using this the following code to add a product in cart with custom option value. But all the time cart qty taking the value of "Maximum Qty Allowed in Shopping Cart" and then adding 1. For ...
1
vote
1answer
383 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 ...
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:...
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
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
1answer
286 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 ...
1
vote
0answers
37 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....
1
vote
0answers
696 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
47 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
20 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 ...
1
vote
1answer
158 views

Get breadcrumb in Controller Action

I need to get the breadcrumb in the controller action because I am using the cache modules(FPC and another system externally). It cached the breadcrumb in the frontend page. With that, I would use ...
1
vote
2answers
24 views

Using a custom block

I've created a simple module, purely for the block. I want to add it to the newsletter.phtml file that controls the customers newsletter subscriptions as I need to create custom functionality through ...
1
vote
1answer
52 views

Can I make separate controller for AJAX actions? (Magento 1.x)

I have my custom module and everything works fine, but I would like to create separately controller for AJAX actions (AjaxController). Currently I Have only IndexController. Everytime I get: {"error":...
1
vote
0answers
24 views

How to create a shorter route in Magento 2?

Hi so i am wondering how is it possible to create a shorter route other than the usual helloworld/index/index. If I wanted my route to end in [magentodomain]/helloworld/index how would I be able to ...
1
vote
0answers
1k views

Magento 2: How to call a command from a Controller?

I have created a command and now I need to call it from a controller. How to do it? This is the command: class CleanVarnish extends Command { protected function configure() { $this-&...
1
vote
2answers
2k 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 ...