Is it possible to use a small function without creating an entire module to use a helper? I don't have a lot of experience with that, and I would prefer if I could just use the function without having to do all that.

For example this answer:

Do I have to create a module to use that function in a phtml file?

public function getCustomMenuCategory($categoryId) {

    try {            
            $categoryChild = Mage::getModel('catalog/category')->load($categoryId)->getChildrenCategories();
            if (count($categoryChild) > 0) {
                return $categoryChild;
            } else {
                $parentcategories = Mage::getModel('catalog/category')->load($categoryId)->getParentCategory()->getChildrenCategories();
                return $parentcategories;
    } catch (Exception $ex) {
        Mage::log($ex, null, 'subcategory.log');

^ that is what I want to use in a phtml file.


You can use helper class of core magento helper class using overriding the magento core helper into your local and put this code into core magento helper class.

In your local create directory like Mage -> Catalog -> Helper and put Data helper inside that folder/directory.

Put your code at the end of file.

You can call your function using catalog helper.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.