gaminn Posted November 11, 2024 Share Posted November 11, 2024 (edited) Hi, is it possible to change "Home" to "All products" and its link to /2-products, not to /? Edited November 27, 2024 by gaminn (see edit history) Link to comment Share on other sites More sharing options...
endriu107 Posted November 11, 2024 Share Posted November 11, 2024 Yes, home is main category so you can change it name friendly url too. Link to comment Share on other sites More sharing options...
gaminn Posted November 11, 2024 Author Share Posted November 11, 2024 Can you please show me a section where I can change this in prestashop administration? Link to comment Share on other sites More sharing options...
endriu107 Posted November 11, 2024 Share Posted November 11, 2024 In category settings. Link to comment Share on other sites More sharing options...
gaminn Posted November 11, 2024 Author Share Posted November 11, 2024 Where exactly? These are my categories. No idea where to change the Home label and link. Link to comment Share on other sites More sharing options...
endriu107 Posted November 11, 2024 Share Posted November 11, 2024 In your screen I see that you already changed it name and friendly url probably too? Last step is go to themes translation and there you must change Home to Products it is in International > Translations > Front > Office Trnslations > Your theme or Core > select language > click on Modify > go to Shop > Theme > Global. 1 Link to comment Share on other sites More sharing options...
gaminn Posted November 11, 2024 Author Share Posted November 11, 2024 (edited) Thanks. That's rather a hack. Hopefully the word "Home" is not used elsewhere in prestashop. Anyway, I translated "Home" as "Products", but still it points to the homepage/index (./). How can I change the link of Home (or Products now for me) to the root category? Edited November 11, 2024 by gaminn (see edit history) Link to comment Share on other sites More sharing options...
endriu107 Posted November 11, 2024 Share Posted November 11, 2024 I'm not sure what you want to achive. Is that you want to set root category as your store homepage? This is not possible in default that need code changes. Link to comment Share on other sites More sharing options...
gaminn Posted November 11, 2024 Author Share Posted November 11, 2024 (edited) Please have a look at my first post. I wanted to change "Home" (in the red circle) to "Products". That is possible via the translation hack. I also wanted to change the link "Home" (now "Products") points to. When I click it it gets me to the homepage of my store (./). I want to change the link to point to my root products category which is ./2-products . EDIT: Now I see the translation hack is not good. I also have other pages in my store (contact us, terms and conditions etc) where "Home" was also translated to "Products" which is obviously non sense. To further explain what I want: My root category is Products, it contains sub-categories, e.g. Drives. When I browse my store's catalog, the path under the logo of my store say e.g. Home / Drives when I'm in Drives category. It never contains my root category "Products", instead it contains "Home" which, when clicked, makes you leave catalog, it points to the homepage. I would like the path to by like Products / Drives, or Home / Products/ Drives would also be possible. Edited November 11, 2024 by gaminn (see edit history) Link to comment Share on other sites More sharing options...
WebDesk Solution Posted November 12, 2024 Share Posted November 12, 2024 @gaminn To change the root category label and URL in your PrestaShop breadcrumbs, follow these steps:Step 1: In your PrestaShop installation, navigate to override/controllers/front/. (If these folders do not exist, create them.) Inside this folder, create a new PHP file named FrontController.php if it does not already exist.Step 2: Paste the following code into the FrontController.php file: <?php class FrontController extends FrontControllerCore { protected function getBreadcrumbLinks() { // Replace '2' with the desired category ID $categoryId = 2; // Load the category based on ID and current language $category = new Category($categoryId, $this->context->language->id); $breadcrumb = []; $breadcrumb['links'][] = [ 'title' => $category->name, 'url' => $this->context->link->getCategoryLink($category), ]; return $breadcrumb; } } ?> Step 3: Go to Advanced Parameters > Performance in your PrestaShop admin panel and click Clear Cache.Step 4: Visit the front end to check the breadcrumb. Review the screenshot for reference if needed. We hope this solution works for you! Link to comment Share on other sites More sharing options...
gaminn Posted November 12, 2024 Author Share Posted November 12, 2024 Thanks. This almost works, but the label should not change for pages like contact us, terms and conditions etc. It should only change for catalog (pages where user browses products available in the shop). For contact us, T&C etc page, it should be like this: Home -> Contact Us , Home -> Terms and conditions For products catalog, it should be like this Root category -> Child category 1 -> etc.... or this is also acceptable: Home -> Root category -> Child category 1 -> etc.... To be honest I'm wondering why prestashop omits the root category in the labels, it doesn't make any sense to display Home -> Child category 1 so you have no chance to get back to the root category and instead, if you click Home, it brings you to the homepage. Link to comment Share on other sites More sharing options...
WebDesk Solution Posted November 12, 2024 Share Posted November 12, 2024 @gaminn Thank you for your reply. To meet your requirements, please update the code as follows: <?php class FrontController extends FrontControllerCore { protected function getBreadcrumbLinks() { // Replace '2' with the desired category ID $categoryId = 2; // Load the category based on ID and the current language $category = new Category($categoryId, $this->context->language->id); $breadcrumb = []; // Check if the current page is a category, product, manufacturer, or search page if (in_array($this->php_self, ['category', 'product', 'manufacturer', 'search'])) { // Replace "Home" with the custom category link $breadcrumb['links'][] = [ 'title' => $category->name, 'url' => $this->context->link->getCategoryLink($category), ]; } else { // Default "Home" breadcrumb link for other pages, such as CMS pages $breadcrumb['links'][] = [ 'title' => $this->getTranslator()->trans('Home', [], 'Shop.Theme.Global'), 'url' => $this->context->link->getPageLink('index', true), ]; } return $breadcrumb; } } ?> 1 Link to comment Share on other sites More sharing options...
gaminn Posted November 13, 2024 Author Share Posted November 13, 2024 Hi, thank you so much, that is the solution I wanted. Link to comment Share on other sites More sharing options...
Divine Posted November 13, 2024 Share Posted November 13, 2024 Hello, don't forget to edit your first post and to add [Solved] in the title Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now