ZMCategories
I am (again, again, again) agonizing over ZMCategories.
As part of the database code changes I am reviewing all services and model classes and there is heaps that could be improved (from a coding point of view, most of this work won’t be visible to regular users that just mess with templates).
There are actually two things that make this rather tricky:
- Internal caching
The current implementation does a lot of internal caching in order to be fast. - The active flag on categories (via applyPath(..))
Initially caching was not a big issue until I added support for multiple languages. Now that I want to add support to create and update categories (for admin tools) there is a second dimentions: the status. Further complications are that the code builds a tree structure to support the category tree navigation.
The second is actually just something I’d rather implement differently as it depends enirely on the cPath request parameter and that shouldn’t interact with a service.
So, I plan to change two things:
- The meaning of the method isActive() in ZMCategory will change and be similar to the same method in ZMProduct.
Active categories are visible in the store, inactive aren’t.
This should actually not be a big issue as this method is used only in the default categroy rendering methodzm_build_category_tree_list(). - The whole logic currently done by ZMCategories::applyPath() will have to go somewhere else. Again, potentially the only code affected is
zm_build_category_tree_list().
Any objections? - let me know…
EDIT: As it turns out, changes are really confined to zm_build_category_tree_list(). That means unless your theme uses a custom version of zm_build_category_tree_list() there is nothing to fear ![]()
