0

We have a well-established instance of Magento 1.4 running, though guys before me have modified core files which is unfortunate.

For a category, under Catalog > Manage All Categories > General Information, if I set "Is Active = yes", then the catalog/category list page is rendered.

If I set "Active = no", then a "404" page is rendered.

I want to modify the logic (by extending core) that does that just slightly, to say this:

if('category is active OR a special viewing cookie is set'){
    //render the list page
}else{
    //show the 404 page as you normally do.
}

Where is this located? I would think it's pretty deep inside core.

== EDIT ==

Just wanted to re-state my comment to the accepted answer, the canShow() method leading to getIsActive() is where the decision is made. Override that, and it appears the category page will show exactly as it otherwise would if the category was active. Magento appears to make no further checks beyond that point.

I can't vouch for that in every instance or if category relationships are more complex though.

1

According to Magento 1.4:

Goto app/code/core/Mage/Catalog/controllers/CategoryController.php Inside _initCatagory has following check


protected function _initCatagory()
    {
        -----
        if (!Mage::helper('catalog/category')->canShow($category)) {
            return false;
        }
        ----

        return $category;
    }

Following line is responsible for going 404 page


Mage::helper('catalog/category')->canShow($category)

So if you need to change logic then go to following file and function: app/code/core/Mage/Catalog/Helper/Category.php


public function canShow($category)
    {
        if (is_int($category)) {
            $category = Mage::getModel('catalog/category')->load($category);
        }

        if (!$category->getId()) {
            return false;
        }
        // here you can change your logic
        if (!$category->getIsActive()) {
            return false;
        }
        if (!$category->isInRootCategoryList()) {
            return false;
        }

        return true;
    }

NB: Don't modify core file. You should go with rewrite according to magento way.

  • Thanks for the thorough answer. Yes, the canShow() function is where it happens, cascading down to getIsActive(). Surprisingly, but just overriding that status, the page displays as it would if the category were ACTUALLY active. Magento appears to make no further checks on active state to show the products related. – Oliver Williams Jun 16 '16 at 20:03

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.