I have a simple example. Say my system is messed up and I want to disable the cache
manually because my admin panel is not working. How do I go from figuring out what
component is run, and what php I should manually run to figure out the task.
What are the steps, from A to Z?
Thanks.
Best Answer
Here are the steps, in order, to follow through the process of a Magento route to internals:
Mage_Adminhtml
. You'll probably want to start there.Mage/Adminhtml/etc/config.xml
there is aroute
definition. That route has afrontName
. This frontName is the equivalent to the first part of your URL in Magento. For instance, /customer/account/login references the customer route, the AccountController.php and the method in that controller called loginAction./admin/cache/index/key/2030239fjaosjdg0a9sjd09guad0gua0s9dgu0a9sudg
. Admin is the route (as we discovered in the last step). Cache is the next part, so we'll look in the CacheController.php file. And then we see index, which means we should look in theindexAction
method.Here's what the indexAction looks like (1.8CE/1.13EE):
So it's loading a layout and setting system/cache as the active menu. Let's find where the layout is being rendered. Unfortunately - and you'll just have to know this - originally Magento had some of the admin concerns in Mage_Admin, which defines a file called
admin.xml
in the adminhtml layout folder:Therein you'll see the layout definition for the route in question. All future changes to layouts will be defined within the adminhtml route or in a custom module adding the admin layout files. Here is that definition:
So now we see two block types to review and a phtml template file to take a look at.
Firstly the
adminhtml/cache
. The shortcode for the block was set in theetc/config.xml
under<global>
and that maps toMage_Adminhtml_Block
. That means we should look atMage_Adminhtml_Block_Cache
:Bingo. That's information that we can work with. Things are being set like page title. Notice this little tidbit:
That is Magento's way of saying "I have a grid that should be rendered and it's located in the
cache
folder under the block definitions. I know. It's strange. They throw together the grid container on the fly and set it as a child block. They expect it to always be called Grid.php. This is then located withinMage_Adminhtml_Block_Cache_Grid
:If you've made it this far, congratulations. You deserve a medal. In that grid block we see a few things happening:
And that's it! As homework, explore what the layout definition for
admin/cache_additional
!