20

This happens because 'secret key' is missing when you just type in URL manually. Secret key feature is enabled by default and can be disabled here: Stores => Configuration => Advanced => Admin => Security => Add Secret Key to URLs. Then you should be able to reach your action.


14

You can just use a "naked" input field, you just have to add the following attribute: data-form-part="product_form" so: <input data-form-part="product_form" type="text" name="my_new_field" value="123"> You will then be able to get the POST data for your input.


12

In router.xml file (companyName/customModule/etc/adminhtml/router.xml) For me the solution was to have the route id and frontName have the same value. In your case this would be: <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/...


8

isAllowed() is used to check if your controller(for specific method) is authorized for logged in user or not. It by default returns true so you should define it to restrict from user. As you can see, by default, this method returns true. That means if you don’t define your own _isAllowed method your Admin Panel features will be open to any user with an ...


7

In Magento 2 you need to create menu.xml file in your module's etc/adminhtml folder. Here is example of menu.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Backend/etc/menu.xsd"> <menu> <add id="Lapisbard_StoreLocator::storelocator" title="...


7

The solution above is not fully correct. You are adding a field as a "naked" html element and a product form is an UI form with its own peculiarities. A special class (vendor/magento/module-ui/view/base/web/js/form/form.js) is responsible for fields collection and their validation when a form is sent. Also, this class should miss the fields that are not ...


5

Visibility in the admin menu is not determined by the controller and its _isAllowed method but directly by the ACL. If you want the menu to be always visible and not controlled by ACL, don't define it in your modules adminhtml.xml. The redirect to dashboard if you enter the URL manually probably comes from a missing/wrong key parameter that prevents ...


5

The error message is pretty clear about it: Controller file was loaded but class does not exist So the controller file has been loaded but the class name is wrong. Class name and file name in your question seem to match, but I noticed that TransationController probably should read TransactionController ("C" is missing). Double check that file name and ...


5

I may be wrong here, but I think you have an other class that extends \Webkul\Grid\Controller\Adminhtml\Grid\Index. And this class has as dependency an instance of the object manager. Something like this: namespace Some\Namespace\Here; class YourClassHere extends \Webkul\Grid\Controller\Adminhtml\Grid\Index { public function __construct( \...


5

I'm pretty sure it's because your URL is not properly generated. Let's take the following example: getUrl('adminRouteFrontName/controllerFolder/actionClass') Here is how an URL should be generated and here is how you must replace the values: adminRouteFrontName : it is the value declared in your adminhtml/routes.xml so I'm not sure what you put there in ...


5

You can read directly from config file such as app/etc/local.xml with: Mage::getConfig() Thus you can use the following: Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName'); However, instead of doing this I reckon you should use the helper that lets you generate admin URLs: Mage::helper("adminhtml")->getUrl("adminhtml/...


5

As Magento compile the classes and put them in var/generation folder, So it will always be a better practice to delete var/generation and var/cache folder, whenever you created a new class or change any parameters of constructor of any class. If you don't want to delete whole folder then try to delete files from the same class path from where you are ...


5

So as far as I understand it you will need to update your module's config xml to also include the adminhtml dependency. To do this you should include the following in your Bye_World config. before="Hello_World" The reason for this is....


5

In your block create protected $_template = 'Company_Module::labelposition.phtml'; now, make labelposition.phtml and add your html field with attribute data-form-part="formname". Here the formname must be name of your uiform like <uiComponent name="product_form"/>. e.g. <input type="text" data-form-part="product_form" name="test" value="Hello ...


4

For all actions of a single controller class, you can override the preDispatch or postDispatch methods: class YourController extends Mage_Adminhtml_Controller_Action { public function preDispatch() { // put logic before controller actions here parent::preDispatch(); } public function postDispatch() { // put logic ...


4

Maybe it's better to use that property: /** * Array of actions which can be processed without secret key validation * * @var array */ protected $_publicActions = ['action_name'];


4

Double check to make sure all your files, folders and namespace are correct. Did you include the following files: /Gift/registration.php /Gift/composer.json /Gift/etc/module.xml Using the instruction you provide, I have recreated your module and it work find see demo https://github.com/magepal/stackexchange/tree/develop/102629 Edit After do some ...


4

I just want to add that Your Question and Your answer both are working for me :). I was searching for a simple method for redirection and accidentally I found that old method (of Mage 1) is still supported on Mage 2, I used the following code to redirect from my custom controller to product grid and it worked :) $this->_redirect('catalog/product/index'); ...


4

Folder structure for following controller will be app/code/Test/Priya/Controller/Adminhtml/Priya in side that folder Index.php namespace Test\Priya\Controller\Adminhtml\Priya; use Magento\Framework\Controller\ResultFactory; use Magento\Backend\App\Action\Context; use Magento\Framework\View\Result\PageFactory; class Index extends \Magento\Backend\App\...


4

try with $block->getUrl('foo/bar/index');


3

It doesn't work because you are not stopping the current request. You need the following code too: /** @var $controller Mage_Core_Controller_Varien_Action */ $controller = $observer->getData('controller_action'); $controller->setFlag( $controller->getRequest()->getActionName(), Mage_Core_Controller_Varien_Action::...


3

To do the following in Magento 2, you must do the following in your execute method: public function execute() { /* Do your controller action stuff here */ $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('adminRouteFrontName/controllerFolder/actionClass'); return $resultRedirect; } You don't need ...


3

It is a core Hack Some one directly edited core file of Magento app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php. As the error indicates, go to the line 139 in that file and you can find PHP error (most probably some syntax error) there. I recommend you to replace that file with original file. DO NOT EDIT THE CORE FILE DIRECTLY. Here is the ...


3

You can either move you controller file location or update you config.xml Method 1 : Move your controller file from MyApp\MyModule\controllers\ButtonController.php to MyApp\MyModule\controllers\Adminhtml\ButtonController.php Or Method 2 : change your config.xml and update your class definition <mymodule before="Mage_Adminhtml">...


3

Should be as simple as adding extra parts to the action node. <action>adminhtml/your_controller/your_action</action> Check out how the downloads part of the admin section works. <action>adminhtml/report_product/downloads</action> Here the controller is Mage_Adminhtml_Report_ProductController and the action is downloadsAction


3

You have to use the execute() method inside the controller. Each controller file has a single execute method. This execute method is responsible for returning a “result” object (i.e. an object that implements the Magento\Framework\Controller\ResultInterface interface). See the code below : namespace [NameSpace]\[ModuleName]\Controller\Adminhtml\[ModuleName]...


3

I have never seen an official answer from a Magento engineer on the matter, but to me it always appeared that this feature is to be used when you want users to be able to link to a page from outside a secure session, as otherwise clicking on a link referencing a secure admin URL will only redirect you to the dashboard after prompting you to log in. I always ...


3

In your config.xml Problem is this line <AppFactory_Basic after="Mage_Adminhtml">AppFactory_Basic_Adminhtml</AppFactory_Basic> should be <AppFactory_Basic before="Mage_Adminhtml">AppFactory_Basic_Adminhtml</AppFactory_Basic>


3

When attempting to access modules/functionality in the backend (Adminhtml), Magento checks for the presence of the secret Form Keys, and if/when someone does attempt to access an action and doesn't supply a valid FormKey and/or supplies an Invalid FormKey - the Adminhtml AbstractAction (Magento\Backend\App\AbstractAction) will route the user Admin UIX ...


3

You can pass param like this : $params = array('myname' => 'Nuno Sousa'); $resultRedirect->setPath('customer/index/new', ['params' => $params]); You can retrive using this : $this->getRequest()->getParams();


Only top voted, non community-wiki answers of a minimum length are eligible