Reputation: 6003
I have a shipping community model that has a camel cased class/file witch I would like to override.
The original file/class is located under app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php and I would like to override a method of this file, or the whole class under app/code/local/Esmart/CorreiosImprovements/Model/Carrier/CorreiosMethod.php.
In the original module config file, I can see it's model declaration in config.xml as follows:
<global>
...
<models>
<pedroteixeira_correios>
<class>PedroTeixeira_Correios_Model</class>
</pedroteixeira_correios>
</models>
...
<sales>
<shipping>
<carriers>
<pedroteixeira_correios>
<class>PedroTeixeira_Correios_Model_Carrier_CorreiosMethod</class>
</pedroteixeira_correios>
</carriers>
</shipping>
</sales>
</global>
At my module config.xml I've declared the override this way:
<global>
<models>
<esmart_correiosimprovements>
<class>Esmart_CorreiosImprovements_Model</class>
</esmart_correiosimprovements>
<pedroteixeira_correios>
<rewrite>
<carrier_correiosMethod>Esmart_CorreiosImprovements_Model_Carrier_CorreiosMethod</carrier_correiosMethod>
</rewrite>
</pedroteixeira_correios>
</models>
</global>
Usually the model file isn't camel cased, so I guess it's easier. Or am I missing something here?
Any help is appreciated.
Upvotes: 2
Views: 631
Reputation: 23205
The class group (<pedroteixeira_correios>
) to use in your rewrite syntax depends on the class group declaration in the module's config.
The class ID (<carrier_correiosMethod>
) to use in your rewrite syntax depends entirely on how the class is invoked in the code. For your example, the following would all instantiate the original class instance on case-sensitive filesystems:
pedroteixeira_correios/carrier_correiosMethod
pedroteixeira_correios/Carrier_correiosMethod
pedroteixeira_correios/carrier_CorreiosMethod
pedroteixeira_correios/Carrier_CorreiosMethod
On case-insensitive filesystems, any combination of casing for the class ID part would yield the model instance. Hopefully the extension vendor followed a consistent pattern when specifying their class in code/markup, but you can specify multiple xpaths using the list above to handle all permutations.
Upvotes: 5