Tamade Posted October 10, 2020 Share Posted October 10, 2020 How should I put in Seo and Urls so that when I click on the categories it shows me all the previous categories? I want it to put: / Bedrooms / tables currently out: / tables in the products it puts it well: / bedrooms / tables / table without legs classic v1.7.6.5 Thank you Link to comment Share on other sites More sharing options...
musicmaster Posted October 11, 2020 Share Posted October 11, 2020 In Shop Parameter-> Traffic&SEO -> Scheme of Urls you can define how the url should look. In older version you could write here {categories} instead of {category}. I am not sure whether that still works in this version. Link to comment Share on other sites More sharing options...
Guest Posted October 11, 2020 Share Posted October 11, 2020 No, it doesn't work. However, you can edit the ./classes/Link.php file getCategoryLink function. Link to comment Share on other sites More sharing options...
Tamade Posted October 13, 2020 Author Share Posted October 13, 2020 I have managed to show two categories, but I am missing a third, I will continue testing. Thanks for the help Link to comment Share on other sites More sharing options...
Guest Posted October 13, 2020 Share Posted October 13, 2020 (edited) PRESTASHOP 1.7 I see you're worried about it. ./classes -> Link.php public function getCategoryLink( $category, $alias = null, $idLang = null, $selectedFilters = null, $idShop = null, $relativeProtocol = false ) { $dispatcher = Dispatcher::getInstance(); if (!$idLang) { $idLang = Context::getContext()->language->id; } $url = $this->getBaseLink($idShop, null, $relativeProtocol) . $this->getLangLink($idLang, null, $idShop); // Set available keywords $params = array(); if (!is_object($category)) { $params['id'] = $category; } else { $params['id'] = $category->id; } // Selected filters is used by the module ps_facetedsearch $selectedFilters = null === $selectedFilters ? '' : $selectedFilters; if (empty($selectedFilters)) { $rule = 'category_rule'; } else { $rule = 'layered_rule'; $params['selected_filters'] = $selectedFilters; } if (!$alias) { $category = $this->getCategoryObject($category, $idLang); } $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; if ($dispatcher->hasKeyword($rule, $idLang, 'meta_keywords', $idShop)) { $category = $this->getCategoryObject($category, $idLang); $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); } if ($dispatcher->hasKeyword($rule, $idLang, 'meta_title', $idShop)) { $category = $this->getCategoryObject($category, $idLang); $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); } /* added subcategories */ $cats = array(); $categ = new Category($params['id']); foreach ($categ->getParentsCategories($idLang) as $cat){ if (!in_array($cat['id_category'], array(1, 2, $categ->id))) $cats[] = $cat['link_rewrite']; } $params['subcategories'] = implode('/', array_reverse($cats)); return $url . Dispatcher::getInstance()->createUrl($rule, $idLang, $params, $this->allow, '', $idShop); } Dispatcher.php public $default_routes = array( 'category_rule' => array( 'controller' => 'category', 'rule' => '{subcategories:/}{id}-{rewrite}', // added categories 'keywords' => array( 'id' => array('regexp' => '[0-9]+', 'param' => 'id_category'), 'rewrite' => array('regexp' => self::REWRITE_PATTERN), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'subcategories' => array('regexp' => '[_a-zA-Z0-9-\/\pL]*'), // added regexp ), ), ... ... ... SEO & URL Edited October 13, 2020 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted October 13, 2020 Share Posted October 13, 2020 (edited) 1. add this two file to ./override/classes/ folder Link.php Link.php Dispatcher.php Dispatcher.php 2. Admin -> Shop parameters -> Traffic & SEO a) add {subcategories:/} Route to category b) disable Friendly URL c) enable Friendly URL DONE ! Thank you for giving me a like clicking on the gray heart below the posts 😉 Edited October 13, 2020 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Tamade Posted October 13, 2020 Author Share Posted October 13, 2020 Yes!!! Now all the categories and subcategories come out in url. Many thanks !! 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