Merchant Stories

Magento Class: How to Find a Class by Name

Sep 11, 2014 2 min read 599 views
Listen audio
Magento Class: How to Find a Class by Name

In order to change any, even the slightest parameter of a web stores functionality, you need to be a skilled programmer or at least be able to distinguish classes.

Let us review how a class can be found in Magento ® by name, how their names are formed and their basic characteristics.

What does a Magento Class name consist of?

Basically, a class name in Magento ® consists of capital letters and a lower dash (‘_’). You may see some examples below:

Test_Class _Name_ Magento

Df_1C_ Sample_Cml2_ Export _Processor_Product

A very important fact you should know about classes is that each class is only responsible for one file. Several different classes cannot have the same name or be responsible for several files – this would cause a web store to malfunction or be down at all. This fact is one of the main commandments for programmers of Magento ®, so if you have any problems with files and name distribution, you can contact GoMage specialists. We will perform correct configuration as soon as possible.

Why and how search for a class name?

As we have already mentioned, it is often necessary to change a class name or delete it at all, but first, you need to find it. It is very easy to do. You need to use the admin menu where the store administrator and editor have a possibility to search for files in the system folders.

In order to find the necessary section, you need to replace all lower dashes in the class name with slashes “/”. After that click ‘Enter’ and look for the necessary folder. Using the above examples, we will get the following:

Test/Class /Name/Magento

Df/1C/Sample/Cml2/Export/Processor/Product

Then you need to add .php to each path name. You will get this text:

Test/Class /Name/Magento.php

Df/1C/Sample/Cml2/Export/Processor/Product.php

These are relative paths used to search for the necessary information on a Magento ® site.

If you need to determine the full path of a file then you have to find where it is located. In Magento ® eCommerce Platform there are following class areas:

1. «lib»,

2. «core»,

3. «community»,

4. «local».

Despite all difficulty of the location determination, one and the same class may be in several areas at the same time. However, when you search for a specific class, the Magento ® system will first return the highest area in the system hierarchy which is very convenient and saves significant time during the search.

If you need to locate a class in a specific area, simply add its name at the beginning of the path:

Lib/Df/1C/Sample/Cml2/Export/Processor/Product.php

Core/Test/Class/Name/Magento.php

Local/Test/Class/Name/Magento.php

If you do not know where exactly the class is located but you suppose that is it in several areas, you can add the following line:

App/code/Df/1C/Sample/Cml2/Export/Processor/Product.php

App/code/Test/Class/Name/Magento.php

Before trying to change classes in your web store make sure that you have a backup copy of it. Otherwise, you may lose a significant part of your products for which one of the classes is responsible. Also, it is recommended to send a warning message to your customers that your store may be unavailable for some time due to repair work or maintenance.

If you do not have any experience in classes modification it would be better to ask GoMage specialists for assistance. You may contact us by email or through comments to this article, we will reply as soon as possible.

Also, check the Extensions for Magento ® which simplify different processes on your Magento ® store.

That's where you contact us!

    By submitting this form you agree to GoMage's Terms of Use and Privacy Policy
    woo-hoo! Now its time to keep checking your inbox, as we will be getting in touch soon. Promise :)
    oops! Thanks. But it seems like some kind of technical issues stop you from meeting GOMAGE. Could you try again?