Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Naming Class names
 
number25
Member
 
Total Posts:  64
Joined:  2008-07-12
 

I notice that everytime when someone creates a class, they name it after the path name it stays in like this

class MyCompany_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_Abstract

which would be located in a directory like this

app/code/local/MyCompany/Catalog/Block/Product/Featured.php

if you notice the MyCompany_Catalog_Block_Product_Featured resembles the path MyCompany/Catalog/Block/Product/Featured.php

one has an underscore and one has slashes. Now my question to that is Do they name it just for good naming convention ? or do they name it that way because magento parses the text to find out where it is ???

Could I name it something like this

class MyCompany_Product_Featured extends Mage_Catalog_Block_Product_Abstract

or this

class Featured extends Mage_Catalog_Block_Product_Abstract

Im not saying that I want to, Im just asking to get a better feel on how magento works. thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

Magento needs this kind of name, otherwise your classes will not be found.

I think this is because of Zend Framework.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top