Find backoffice controller
-
29-03-2021 - |
Вопрос
I have a javascript call to this url : https://mysite/admin/admin/export/export/key/b7c4bdb5a1b9f5147f498741adc99/entity/catalog_product/file_format/csv
From this url how can I find where is located the action ?
I already know the 3 part in url...but here seems to be different. Which module I should look into, which action I should search ?
If this can help this is the main dashboard url after login
https://sysite/admin/admin/dashboard/index/key/276e1bbcbff57306/
Решение
Your URLs come from Magento 2's router system, which can be configured per module. This means that not all the admin controllers are in one place, example:
https://mysite/admin/admin/export/export/key/xxx/entity/catalog_product/file_format/csv
comes from modulemagento/module-import-export
https://sysite/admin/admin/dashboard/index/key/xxx/
comes from modulemagento/module-backend
Both of these have their frontName and area defined by their module's etc/adminhtml/routes.xml
, like the one for the ImportExport being this:
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento: framework:App/etc/routes.xsd">
<router id="admin">
<route id="adminhtml">
<module name="Magento_ImportExport" before="Magento_Backend" />
</route>
</router>
</config>
Then from there you find the Controller in the module's Controller/Adminhtml/
directory. Example, https://sysite/admin/admin/dashboard/index/key/xxx/
is at Controller/Adminhtml/Dashboard/Index.php
relative to the magento/module-backend
module