Jump to content

How to set up an external link to a subcategory


MKZ Industries

Recommended Posts

Hi all,

I would like to set up a subcategory so that when the user clicks on it, they are redirected to an external web page (in a new tab if possible). 

For example, if I have the following category tree:

Mobile phones
- Motorola
- Samsung

I would like the subcategories to lead to the Motorola or Samsung page. 

Is this possible? I have seen some very old answers that involved modifying the file "modules/blocktopmenu/blocktopmenu.php", but I do not see that module or file in Prestashop 8.2.

Thank you very much and best regards!

Link to comment
Share on other sites

Based on my research in other answers, I have tried this in "modules\ps_mainmenu\ps_mainmenu.php" in the function "generateCategoriesmenu" and it seams it is working but only for the Main Meny bar, not for the category tree:

foreach ($categories as $key => $category) {
            $node = $this->makeNode([]);
            if ($category['level_depth'] > 1) {
                $cat = new Category($category['id_category']);
                if ((int)$cat ->id_category == 12) 
                    $link = "https://www.motorola.com";
                else
                    $link = $cat->getLink();
                // Check if customer is set and check access
                if (Validate::isLoadedObject($this->context->customer) && !$cat->checkAccess($this->context->customer->id)) {
                    continue;
                }
            } else {
                $link = $this->context->link->getPageLink('index');
            }    

Any ideas of how to make it work for the category tree?

Edited by MKZ Industries (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...