http://webshop.start...ontent/about-us instead of http://webshop.start...tent/4-about-us
http://www.prestasho...post__p__883380
Here is what i got:
1st file: ./controllers/ProductController.php
update the function preProcess()
public function preProcess()
{
if ($id_product = (int)Tools::getValue('id_product'))
{ $this->product = new Product($id_product, true, self::$cookie->id_lang); }
else //remove link id by Ha!*!*y
{
$id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_lang`
WHERE `link_rewrite` = \''.Tools::getValue('product_name_seo').'\'');
$this->product = new Product($id_product, true, self::$cookie->id_lang);
} //remove link id by Ha!*!*y
if (!Validate::isLoadedObject($this->product))
{
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
}
else
$this->canonicalRedirection();
parent::preProcess();
}
2nd file: ./classes/Link.php
update the function getProductLink()
public function getProductLink($id_product, $alias = NULL, $category = NULL, $ean13 = NULL, $id_lang = NULL)
{
global $cookie;
if (is_object($id_product))
{
$link = '';
if ($this->allow == 1)
{
$link .= (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang));
if (isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home')
$link .= $id_product->category.'/';
else
$link .= '';
//remove link id by Ha!*!*y
//$link .= (int)$id_product->id.'-';
if (is_array($id_product->link_rewrite))
$link.= $id_product->link_rewrite[(int)$cookie->id_lang];
else
$link.= $id_product->link_rewrite;
if ($id_product->ean13)
$link .='-'.$id_product->ean13;
else
$link .= '';
$link .= '.html';
}
else
{
$link .= (_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product->id);
}
return $link;
}
else if ($alias)
{
$link = '';
if ($this->allow == 1)
{
$link .= (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang));
if ($category AND $category != 'home')
$link .= $category.'/';
else
$link .= '';
//remove link id by Ha!*!*y
//$link .= (int)$id_product.'-'.$alias;
$link .= $alias;
if ($ean13)
$link .='-'.$ean13;
else
$link .= '';
$link .= '.html';
}
else
$link .=(_PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product);
return $link;
}
else
return _PS_BASE_URL_.__PS_BASE_URI__.'product.php?id_product='.(int)$id_product;
}
3rd file: ./classes/Tools.php
update the function generateHtaccess()
find inside the function
if ($multilang)
{
$tab['RewriteRule']['content']['^([a-z]{2})/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
$tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$2&isolang=$1 [QSA,L]';
and add the following lines:
//remove link id by Ha!*!*y
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/[a-zA-Z0-9-]*/([a-zA-Z0-9-]*)\.html product.php?product_name_seo=$2&isolang=$1 [QSA,L]';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/([a-zA-Z0-9-]*)\.html product.php?product_name_seo=$2&isolang=$1 [QSA,L]';
//remove link id by Ha!*!*y
also look for inside the function:
$tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1 [QSA,L]'; $tab['RewriteRule']['content']['^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html'] = 'product.php?id_product=$1 [QSA,L]';
and than add the following lines:
//remove link id by Ha!*!*y
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)\.html product.php?product_name_seo=$1 [QSA,L]';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^[a-zA-Z0-9-]*/([a-zA-Z0-9-]*)\.html product.php?product_name_seo=$1 [QSA,L]';
//remove link id by Ha!*!*y
also look for inside the function:
// Classic URL rewriting if ($rewrite_settings) foreach ($tab['RewriteRule']['content'] as $rule => $url) fwrite($writeFd, 'RewriteRule '.$rule.' '.__PS_BASE_URI__.$url."\n");
add this after:
//remove link id by Ha!*!*y
if ($rewrite_settings){
fwrite($writeFd, "\n");
foreach ($tab['RewriteEngine']['content_no_id'] as $line => $rule){
fwrite($writeFd, $rule."\n");
}
}
//remove link id by Ha!*!*y
Edited by HA!*!*Y, 06 August 2012 - 02:04 AM.
This solution has side effects:
All product metadata don't appearing and the title of page products show a default shop title.
You can fix this?, apart from this problem everything works fine
Thanks
Rysiu
http://www.prestasho...post__p__883380
i am look into it right now
this is a temporary solutions to the problem
Add this at the end of file: ./config/config.inc.php
//remove link id by Ha!*!*y
if (Tools::getValue('product_name_seo'))
{
$id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_lang`
WHERE `link_rewrite` = \''.Tools::getValue('product_name_seo').'\'');
$_GET['id_product'] = $id_product;
}
Edited by HA!*!*Y, 06 August 2012 - 02:05 AM.
It removes the ID's from product URL's, but it doesn't update all my URL's automatically, so all my links to products are broken.
Do I need to do something to my htaccess file to do that?
http://www.prestasho...post__p__883380
Will_Authentic_Style, on 14 June 2012 - 04:43 PM, said:
It removes the ID's from product URL's, but it doesn't update all my URL's automatically, so all my links to products are broken.
Do I need to do something to my htaccess file to do that?
Yes Go to:
Back Office > Tools > Generators
Generate your ".htaccess" file by clicking the button
Edited by HA!*!*Y, 06 August 2012 - 02:05 AM.
http://www.prestasho...post__p__883380
C.Perez, on 06 June 2012 - 09:13 AM, said:
C.Perez, i did not update the code to remove IDs from categories or CMS link ill try to post that some time
Edited by HA!*!*Y, 06 August 2012 - 02:06 AM.
HA!*!*Y, on 15 June 2012 - 07:58 AM, said:
Back Office > Tools > Generators
Generate your ".htaccess" file by clicking the button
Thanks for your reply HA!*!*Y.
I did try regenerating my htaccess file from the back-office, but it didn't work.
Could that be due to permissions on the file on the server? If I CHMOD the htaccess file to 777 will that work?
edit - Just realised it's the CategoryController file that needs editing, not ProductController of course. Unfortunately still not working so must be missing something?
Edited by emma_w, 23 June 2012 - 06:02 PM.
http://www.prestasho...post__p__883380
To remove number from Category URL
1st file: ./controllers/CategoryController.php
update the function preProcess()
public function preProcess()
{
if ($id_category = (int)Tools::getValue('id_category'))
{ $this->category = new Category($id_category, self::$cookie->id_lang); }
else //remove link id by Ha!*!*y
{
$id_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `link_rewrite`
FROM `'._DB_PREFIX_.'category_lang`
WHERE `link_rewrite` = \''.Tools::getValue('category_name_seo').'\'');
$this->category = new Category($id_category, self::$cookie->id_lang);
} //remove link id by Ha!*!*y
....
2nd file: ./classes/Link.php
update the function getCategoryLink
I removed (int)($id_category->id).'-'. from the functions in 2 places
public function getCategoryLink($id_category, $alias = NULL, $id_lang = NULL)
{
if (is_object($id_category))
return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)($id_lang)).$id_category->link_rewrite) :
(_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category->id));
if ($alias)
return ($this->allow == 1) ? (_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)($id_lang)).$alias) :
(_PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category));
return _PS_BASE_URL_.__PS_BASE_URI__.'category.php?id_category='.(int)($id_category);
}
3rd file: ./classes/Tools.php
update the function generateHtaccess()
find inside the function
if ($multilang)
{
.....
....
$tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$2&isolang=$1&noredirect=1 [QSA,L]';
$tab['RewriteRule']['content']['^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$2&isolang=$1 [QSA,L]';
....
....
Add the following lines:
//remove link id by Ha!*!*y
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/([a-zA-Z0-9-])(/[a-zA-Z0-9-]*)+ category.php?category_name_seo=$2&isolang=$1&noredirect=1 [QSA,L]';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-z]{2})/([a-zA-Z0-9-]*) category.php?category_name_seo=$2&isolang=$1&noredirect=1 [QSA,L]';
//remove link id by Ha!*!*y
Find
// Notice : the id_category rule has to be after product rules. // If not, category with number in their name will result a bug $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+'] = 'category.php?id_category=$1&noredirect=1 [QSA,L]'; $tab['RewriteRule']['content']['^([0-9]+)\-[a-zA-Z0-9-]*'] = 'category.php?id_category=$1 [QSA,L]';
Add the following lines:
//remove link id by Ha!*!*y
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)(/[a-zA-Z0-9-]*) category.php?category_name_seo=$1&noredirect=1 [QSA,L]';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*) category.php?category_name_seo=$1 [QSA,L]';
//remove link id by Ha!*!*y
Add this at the end of file: ./config/config.inc.php
//remove link id by Ha!*!*y
if (Tools::getValue('product_name_seo'))
{
$id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_lang`
WHERE `link_rewrite` = \''.Tools::getValue('product_name_seo').'\'');
$_GET['id_product'] = $id_product;
}
Than Go to:Back Office > Tools > Generators
Generate your ".htaccess" file by clicking the button
Edited by HA!*!*Y, 06 August 2012 - 02:06 AM.
There is 1 error :
Missing category ID
you will have to do the fallowing
Change in /classes/Tools.php (just remove the "+" sign before the filename)
FROM
//remove link id by Ha!*!*y
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)(/[a-zA-Z0-9-]*)+ category.php?category_name_seo=$1&noredirect=1 [QSA,L]';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)+ category.php?category_name_seo=$1 [QSA,L]';
//remove link id by Ha!*!*y
TO
//remove link id by Ha!*!*y
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*)(/[a-zA-Z0-9-]*) category.php?category_name_seo=$1&noredirect=1 [QSA,L]';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-f';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteCond %{REQUEST_FILENAME} !-d';
$tab['RewriteEngine']['content_no_id'][] = 'RewriteRule ^([a-zA-Z0-9-]*) category.php?category_name_seo=$1 [QSA,L]';
//remove link id by Ha!*!*y
Add at the end of /config/config.inc.php
if (Tools::getValue('category_name_seo'))
{
$id_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_category`
FROM `'._DB_PREFIX_.'category_lang`
WHERE `link_rewrite` = \''.Tools::getValue('category_name_seo').'\'');
$_GET['id_category'] = $id_category;
}
and regenerate you htaccess
Thanks
./controllers/ProductController.php
./controllers/CategoryController.php
./classes/Link.php
./classes/Tools.php
./config/config.inc.php
..AND generated a new htaccess file through your admin?
Contact (9am-6pm EST) +1-888-947-6543

Back to top









