views:

720

answers:

3

Hiya,

I am familiar with theming and using template hints in the Magento back office to locate .phtml files.

What I am not really familiar with are the core files such as app/code/core/Mage/Catalog/Model

What I need to do is override a core file like I would a core phtml file by copying it to 'my theme'.

I basically want to amend some labels which appear on the order summary page of the Magento checkout process - domain.com/checkout/cart/

I followed the trail to the phtml files using template hints. Within the app/design/frontend/default/mytheme/template/checkout/cart I found the code

renderTotals(); ?>

Now I managed, by accident, to stumble upon two of the files I wanted to change:

/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Grand.php /httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Shipping.php

I made local copies of these files (http://www.magentocommerce.com/wiki/how%5Fto/how%5Fto%5Fcreate%5Fa%5Flocal%5Fcopy%5Fof%5Fapp%5Fcode%5Fcore%5Fmage) to override the default labels, like I would if I was overriding a template file.

My question is, how can you locate core files which pertain to the 'stuff' you want to change, located in function calls such as renderTotals(); ?> in the phtml files?

Not being able to pinpoint stuff like I can with template hints is slowing me down, and I am struggling to find a solution as I am not up on all the vocab surrounding Magento yet.

Hope this makes sense and thanks in advance!

A: 

From the same settings page where you turn on Template Path Hints, also turn on the "Add Block Names to Hints" setting. This will show you PHP class names such as: Mage_Sales_Model_Quote_Address_Total_Grand to which you can deduce the folder path (underscores represent a subfolder, and the last piece represents the file name).

If you're getting a block such as Mage_Sales_Model_Quote_Address_Total_Default then sometimes it just takes a little common sense to see that it's pulling in other files from the same folder (such as Grand.php and Shipping.php). But there are generally only a couple files in the same folder, so this is pretty easy to see.

As Sid Vel said, a good Search Project functionality is helpful. But if you find yourself looking at Abstract.php of some class, often you need to look in a subfolder in that directory with the proper name to find the concrete implementations. But still, it gets you very close to where you need to be.

philfreo
Lyndsey
First of all, I would always strongly recommend not getting very far behind in Magento versions. They fix a huge number of bugs each revision, and if you're doing you're theming and functionality changes properly (not changing core files) than updates should be very easy to do. I've updated my original answer to provide more detail based on your comment here.
philfreo
A: 

I always use Dreamweaver's site / directory search funtion. It will scan through all the files in the Core folder and tell you where the funtion is from. In your case, I would search for "renderTotals". You need to enable PHTML editing in Dreamweaver.

Most IDE's will allow this kind of search option. In Aptana you can Ctrl + Click on the funtion to open the file it is coming from. Magento takes ages to index itself on Aptana, due to its sheer size.

Sid Vel
I would suggest this as the best way to trace back to the file that contains the function that you are looking for.
Sid Vel
I love Aptana's Ctrl+Click (or hit F3 when the cursor is on the function name), however this actually fails quite frequently in the Magento framework. The reason is that it often it will open up the interface or abstract version of the class, when really you're wanting a concrete subclass or implementation. But it's still helpful to get you close, just remember often if it opens an Abstract.php to look for the concrete versions of the same class.
philfreo
A: 

Hi Yes thanks PhilFreo, common sense was used as I discovered the Grand.php and Shipping.php within the folders by following the general trail left by Magento, however I wouldn't say the actual path to the text I want to change '/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Grand.php' resembles the block hint 'Mage_Checkout_Block_Total_Default', unless I am missing something? (The block hint wasn't Mage_Sales_Model_Quote_Address_Total_Grand)

Sid Vel, thanks for your heads up on using Dreamweaver, I use find and replace in DW alot, but I thought as Magento provides template and block hints, there may have been a more surefire way to discover html contained within functions through Magento itself.

As for upgrading, this is on the agenda. This site is operational however, and cannot be upgraded as of yet.

Thanks for all your suggestions guys - I am now downloading the core folders form the server to create a local site to do a DW search. Happy hunting I guess!

Lyndsey