Magento Forum

   
Manage custom additions to code…
 
jorries
Member
 
Avatar
Total Posts:  56
Joined:  2007-10-07
 

Does anyone have a good suggestion for maintaining custom code adhancments and changes to the magento store?

For example if you hack away inside the templates that will not break on upgrade I assume..
But the code does..

Could magento have a build in feature to maintain these custom changes better?
Perhaps a nice feature request for the near future

 
Magento Community Magento Community
Magento Community
Magento Community
 
iblastoff
Sr. Member
 
Total Posts:  252
Joined:  2007-08-31
 

this could only be possible by having this custom code within extensions/modules/plugins. i don’t see how future magento upgrades could possibly know how to maintain custom changes you’ve made???

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

All the customizations will be made as separate modules that stored separate, but override existing models, controllers and themes.

So as long as API doesn’t change the customizations will be working while not extended classes and methods will continue being upgraded and provide original functionality.

This process will be outlined when API will be finalized (soon smile ). If someone is interested in specific technical details of how it will be done, please ask.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Examples:

As you may have noticed, all the models are referred as Mage::getModel(’module/specific_class’). There are variations such as getSingleton and getResourceModel, but the idea stays the same.

Say you want to extend ‘catalog/product’ model. By default it refers to Mage_Catalog_Model_Product class. Which is declared in Mage/Catalog/etc/config.xml

<config>
   <global>
      <
models>
         <
catalog>
            <class>
Mage_Catalog_Model</class>

Our goal is to add a new method getDefaultCategory(). Steps are:
* Create new module Mage_MyCatalog
* class Mage_MyCatalog_Model_Product extends Mage_Catalog_Model_Product
* public function getDefaultCategory()
* create Mage/MyCatalog/etc/config.xml that contains:

<config>
  <global>
    <
models>
      <
catalog>
        <
rewrites>
          <
product>Mage_MyCatalog_Model_Product</product>

Now, all Mage::getModel(’catalog/product’) will create instances of Mage_MyCatalog_Model_Product with my custom method and all the original ones! Still, Mage_Catalog is upgradable.

It is possible to override the whole model group, and same goes for blocks, helpers and controllers.

With themes it’s similar but a bit different. We leave intact the original themes and create new ones for our customizations. When we use them, Magento will take the files that exist in there or fallback to the files in the original themes.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

it is possible to group all your local customizations into one package, that you can backup, or share with your friends or community.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jorries
Member
 
Avatar
Total Posts:  56
Joined:  2007-10-07
 

Great,

Would be nice if there would be a tutorial for this..
Your dev team needs more people, we all can’t wait wink

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