1

I can see the following function in my template's minicart.phtml:

<?php echo Mage::helper("ves_tempcp/framework")->getMinicartBlock(); ?>

But on the FTP I can not find the folders ves_tempcp/framework. Where do I have to look for the path Mage::helper is looking for?

Thanks!

3 Answers 3

2

You are possibly looking for app/code/community/Ves/Tempcp/Helper/Framework.php Next time you can also use get_class() to see the object class name and then infer the location. For example

echo get_class(Mage::helper("ves_tempcp/framework")) 

should return something like Ves_Tempcp_Helper_Framework telling you that the file should be in app/code/[local][community]/Ves/Tempcp/Helper/Framework.php if the correct naming conventions were used.

6

What you're seeing is Magento's class alias system. What you're asking for is how to translate a class alias into a class name, and subsequently how a class name translates to a file path.

TL;DR: The class you're looking for might be in app/code/local/Ves/Tempcp/Helper/Framework.php

Continue reading for more background about this.


Class Aliases

Magento uses a concept called a "class alias" that every module in app/code/* should define. See some examples below:

# File: app/code/core/Mage/Catalog/etc/config.xml
...
<global>
    <models>
        <catalog>
            <class>Mage_Catalog_Model</class>
            <resourceModel>catalog_resource</resourceModel>
        </catalog>
...

See the node <catalog> and its child <class> - "catalog" is the alias that Magento will use to resolve to the class prefix "Mage_Catalog_Model." This is defined in the context of models, and you will see a similar definition for blocks and helpers.

So when you want to call a helper with Mage::helper('module/helper') Magento will consult the configuration XML to lookup that alias. If found, it will replace it with the class name prefix, followed by a transformed version of everything after the / in the alias.

Your above call for a helper in the template translates something like this:

ves_tempcp/framework ==> Namespace_Module_Helper_Framework

Where Namespace_Module will be derived from what this module's config.xml declares as its alias.

Class - File Path Relationship

It can roughly be said that a class name approximates the file path if you replace underscores with directory separators, ie:

class Mage_Catalog_Model_Category ==> [app/code/core/]Mage/Catalog/Model/Category.php

The path part in brackets is defined as part of Magento autoloading system.

There are some good resources by Alan Storm that touches on how the alias system works, and how Magento uses it to locate files:

http://alanstorm.com/magento_config http://alanstorm.com/magento_class_abstration_autoload

2
  • Rick - thanks for the great answer and background information. I can only mark one answer as the right one and I did with the one which I saw first...
    – Torben
    Commented Jun 18, 2015 at 16:05
  • 1
    No problem @Torben. It's a game of speed around here, and that answer is correct :) Commented Jun 18, 2015 at 23:45
1

it will be located in

app/code/local  

or

app/code/community

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.