Post by Kartoffelz » Wed Sep 07, 2011 5:41 pm

Trying to create SEO-urls? Fed up with manually needed to fill in a SEO-keyword? This script is ideal for you when already have already have populated your database with products, categories and information pages. It's not an extension, it's a simple tool that generates all SEO-keywords for your products, categories and information pages if you wish so. It uses the same SEO-keyword technique used in my previous topic about automate SEO-keyword. Now it came to me that it might be a bit of struggle if you already have a populated database with a lot of products/categories.
That's what this script is for. Deal with the data that has not yet a URL-alias. It's an addition to my previous topic. I am aware that there are extensions also capable of doing the same trick, but I found this more simple and effective - no need to install an extension, if you can populate the URL-alias with a simple trick. I do recommend you have either a auto-SEO generator to will handle this in the future.
Afterwards, feel free to delete it from your server. No need to pollute your admin directory with files you won't use more than once. :)

How it works?
It has three functions:
  1. products - creates SEO-keywords for all products in your database
    categories - creates SEO-keywords for all categories in your database
    information - creates SEO-keywords for all information pages in your database
The script will handle all your products and tries to find a match in the URL-alias table. If there is, no action will be taken. If not, it will convert your product-name, category-name or information pagetitle to a SEO-friendly URL.

Code
Paste the following code in a file and call it "seo-links.php". Upload it to your admin directory and acces it directly, meaning: http://www.yourdomain.com/admin/seo-links.php
From there it explains itself.

Code: Select all

<?php

require_once('config.php');
require_once(DIR_SYSTEM . 'startup.php');

// Registry
$registry = new Registry();

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);

function seoURL($str) {
    $str = preg_replace('/[^a-zA-Z0-9]+/', '-', $str);
    $str = trim($str, '-');
    $str = strtolower($str);
            
    return $str;
}

?>
<html>
    <head>
        <title>Create SEO-links</title>
    </head>
    <style type="text/css">
        body {
            font-family: "Arial";
            font-size: 12px;
        }
    </style>
    <body>
        <center>
        <h2>Script by Kartoffelz</h2>
<?php

if(isset($_GET['products'])) {
$products   = $db->query("SELECT * FROM " . DB_PREFIX . "product");
$products   = $products->rows;

foreach($products as $product) {
    
    $url = $db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE query = 'product_id=" . (int)$product['product_id'] . "'");
    $url = $url->rows;
    
    if(!empty($url)) {
        echo 'Match found for ' . $product['product_id'] . '). No action taken.<br>---------------<br>';
    } else {
        echo 'URL needed for ' . $product['product_id'] . '. Fetching information...<br>';
        $info = $db->query("SELECT * FROM " . DB_PREFIX . "product_description WHERE product_id = '" . $product['product_id'] . "' LIMIT 1");
        $info = $info->rows;
        
        foreach($info as $data) {        
            echo 'Name: ' . $data['name'] . ' | Converting to: ' . seoURL($data['name']);
            $data['name'] = seoURL($data['name']);
            sleep(1);
            $db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'product_id=" . (int)$product['product_id'] . "', keyword = '" . $db->escape($data['name']) . "'");
            echo '<br>Inserted!<br>---------------<br>';
        }
    }
}

echo '<br><br>All done! <a href="seo-links.php">Back</a>';
}
elseif(isset($_GET['categories'])) {
$categories   = $db->query("SELECT * FROM " . DB_PREFIX . "category");
$categories   = $categories->rows;

foreach($categories as $category) {
    
    $url = $db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE query = 'category_id=" . (int)$category['category_id'] . "'");
    $url = $url->rows;
    
    if(!empty($url)) {
        echo 'Match found for ' . $category['category_id'] . '). No action taken.<br>---------------<br>';
    } else {
        echo 'URL needed for ' . $category['category_id'] . '. Fetching information...<br>';
        $info = $db->query("SELECT * FROM " . DB_PREFIX . "category_description WHERE category_id = '" . $category['category_id'] . "' LIMIT 1");
        $info = $info->rows;
        
        foreach($info as $data) {        
            echo 'Name: ' . $data['name'] . ' | Converting to: ' . seoURL($data['name']);
            $data['name'] = seoURL($data['name']);
            sleep(1);
            $db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'category_id=" . (int)$category['category_id'] . "', keyword = '" . $db->escape($data['name']) . "'");
            echo '<br>Inserted!<br>---------------<br>';
        }
    }
}

echo '<br><br>All done! <a href="seo-links.php">Back</a>';
} elseif(isset($_GET['information'])) {
$informationp    = $db->query("SELECT * FROM " . DB_PREFIX . "information");
$informationp    = $informationp->rows;

foreach($informationp as $information) {
    
    $url = $db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE query = 'information_id=" . (int)$information['information_id'] . "'");
    $url = $url->rows;
    
    if(!empty($url)) {
        echo 'Match found for ' . $information['information_id'] . '. No action taken.<br>---------------<br>';
    } else {
        echo 'URL needed for ' . $information['information_id'] . '. Fetching information...<br>';
        $info = $db->query("SELECT * FROM " . DB_PREFIX . "information_description WHERE information_id = '" . $information['information_id'] . "' LIMIT 1");
        $info = $info->rows;
        
        foreach($info as $data) {        
            echo 'Name: ' . $data['title'] . ' | Converting to: ' . seoURL($data['title']);
            $data['title'] = seoURL($data['title']);
            sleep(1);
            $db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'information_id=" . (int)$information['information_id'] . "', keyword = '" . $db->escape($data['title']) . "'");
            echo '<br>Inserted!<br>---------------<br>';
        }
    }
}
echo '<br><br>All done! <a href="seo-links.php">Back</a>';
    
}
else {
    echo '<p><a href="?products">Products</a> - Create product-URLs</p>';
    echo '<p><a href="?categories">Categories</a> - Create category-URLs</p>';
    echo '<p><a href="?information">Information</a> - Create information-URLs</p>';
}

?>
</center>
</body>
</html>

New member

Posts

Joined
Fri Apr 04, 2008 10:44 pm
Location - The Netherlands

Post by onlinephilately » Wed Sep 07, 2011 8:36 pm

Hi, this is a great tool. Thx!

But, when I am about to update all my products I get an error:

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 24 bytes) in ../system/database/mysql.php on line 29

Also, would it be possible to change so that it fetches 'name' with a different language?

New member

Posts

Joined
Thu Jan 27, 2011 3:14 am

Post by Kartoffelz » Wed Sep 07, 2011 11:28 pm

Change your memory limit in your php.ini file. I've already added the sleep-function. Afterwards, change it back to its default.
I am not sure how many products you're storing, but if you could tell me that, I could try and simulating it and if needed, come with a proper adjustment. :)

New member

Posts

Joined
Fri Apr 04, 2008 10:44 pm
Location - The Netherlands

Post by Dubblicious » Tue Oct 18, 2011 6:43 am

Nice tool, worked really well. Inserted everything correctly and quickly. I am surprised that this post does not have more comments. Thanks for sharing.

User avatar
New member

Posts

Joined
Tue Jun 14, 2011 2:35 pm

Post by dony_b » Wed Oct 19, 2011 9:45 pm

Can this be done for these pages as well ?

Site Map
Extras
Brands
Gift Vouchers
Affiliates
Specials
My Account
My Account
Order History
Wish List
Newsletter

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by andrew222 » Wed Oct 19, 2011 11:42 pm

Hey Kartoffelz,

Many thanks for this ;D

New member

Posts

Joined
Wed Nov 17, 2010 12:30 pm

Post by pharoah3d » Mon Oct 24, 2011 12:23 am

dony_b wrote:Can this be done for these pages as well ?

Site Map
Extras
Brands
Gift Vouchers
Affiliates
Specials
My Account
My Account
Order History
Wish List
Newsletter
I loved this code it saved me so much time!

I would also like it if you were able to update it for the above pages as that would just tidy up the last few urls on my list.

Great work again!

Alan

Newbie

Posts

Joined
Sun Oct 23, 2011 10:57 pm

Post by Kartoffelz » Mon Oct 24, 2011 12:30 am

It's real nice getting some great support - even it took quite some while. :)
It's most certainly possible, but it gets a little bit more complicated with all the different actions Opencart uses.

Right now I am bit overloaded with work and studies. If one reads this, he/she is welcome to add the code needed for this.

Once again, I truly appreciate the support and it should motivate me in the near future to work something out. :)

New member

Posts

Joined
Fri Apr 04, 2008 10:44 pm
Location - The Netherlands

Post by ZER0 » Tue Feb 21, 2012 8:58 am

wow thank you so much for this I had to create an account to say thanks!!! you saved me hours and hours of searching to find a solution to this! :banana: :banana:

* Just out of curiosity I have everything in working order i think and something seems to stop the url from making it's was into my browser url bar..

I can see the url generated by the vqmod in admin > product > data > seo keywaord - (autoseolinks.xml installed) which i always leave blank as it's a life saver for creating automatic seo url...

But for some reason I had to come searching for something like this as the urls were not being written to the db for some random reason.. I susspect the vqmod is to blame but no updates or additions to the site could have caused the urls to revert back to (id=21) ratehr than the seo url they were when the vqmod was working... Any ideas guys?

User avatar
Newbie

Posts

Joined
Tue Feb 21, 2012 8:57 am

Post by Aco » Wed Apr 04, 2012 2:00 pm

Just in case anyone is interested, I've uploaded a (commercial) extension that I built for a client a while ago that does a very similar thing.

It also has a few nice extras, such as:
  • Increments keywords in the event of duplicate names to prevent problems with collisions.
  • Generates keywords for Manufacturers.
  • Replaces ampersand symbols (&) with "and", rather than just stripping them out.
  • It installs as a proper module, so you (or your client) can use it as often as is needed.
Hopefully these bits make it worth paying a small price for :).
You can download it from the official extension store: http://www.opencart.com/index.php?route ... on_id=5758

Any feedback/comments/questions appreciated.

Aco
Newbie

Posts

Joined
Fri Sep 09, 2011 2:08 pm
Location - UK

Post by logicPwn » Sat Aug 04, 2012 2:50 am

Hi Kartoffelz,

I downloaded your script and loved it. It worked brilliantly and not to mention saved me what could of been hours manually inputting the seo url for each product.

Now on to what I came here for. I have heavily modified the script for several purposes.

First off I wanted to make the script more intuitive and easy to navigate.
Second I wanted to add updating URL aliases for products with changed names
Lastly I wanted to format it with tables and make it pretty

I am well over half way done and will be posting shortly.

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding


Newbie

Posts

Joined
Fri Jul 06, 2012 6:11 am
Location - Fresno, CA

Post by logicPwn » Wed Aug 08, 2012 1:28 am

Ok I finished it, check it out at http://valleyhardwareinc.com/admin/seo-links.php

Main difference from original is that I formatted it to make it nicer looking and added a table. Also it will update url_aliases if the product/category/information name has changed. (Not everyone will like this, I can remove but it's just for me mainly). Also added support for Manufacturers and changing & to and.

Code: Select all

<?php
require_once('config.php');
require_once(DIR_SYSTEM . 'startup.php');

// Registry
$registry = new Registry();

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);

function seoURL($str) {
    $str = str_replace("&", "and", html_entity_decode($str));
    return trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($str)), '-');
}
?>
<html>
    <head>
        <title>Create SEO-friendly OpenCart URLs</title>
				<style type="text/css">
            body {
                font-family: "Arial";
                font-size: 12px;
						    text-align: center;
            }
						#page {
						    width: 960px;
								margin: 30px auto 10px auto;
						}
						#page #header { margin-bottom: 20px; }
						#page #header h1 a { text-decoration: none; }
				    #page #header h3 { margin-bottom: 20px; }
						.links { font-weight: bold; }
						table { text-align: center; margin-bottom: 10px; }
						th, td { border: 1px solid black; }
        </style>
    </head>
    <body>
				<div id="page">
				    <div id="header">
								<h1><a href="seo-links.php">Create SEO-friendly OpenCart URLs</a></h1>
								<h2>Original script by Kartoffelz</h2>
								<h3>Updated by <a href="http://www.logicpwn.com">logicPwn</a> - 8/2/12</h3>
								<span class="links">Create SEO-friendly: <a href="?action=products">Product URLs</a> | <a href="?action=categories">Category URLs</a> | <a href="?action=information">Information URLs</a> | <a href="?action=manufacturers">Manufacturer URLs</a></span>
						</div>
						<?php if (isset($_GET['action'])) {
						$action = strtolower($_GET['action']); ?>
						<table>
								<tr>
										<th width="40">ID</th>
										<th width="440">Name</th>
										<th width="480">Message</th>
								</tr>
								<?php
								if ($action == "products") {
										$products = $db->query("SELECT * FROM ".DB_PREFIX."product");
										$products = $products->rows;
										foreach ($products as $product) {
												$url = $db->query("SELECT * FROM ".DB_PREFIX."url_alias WHERE query='product_id=".$product['product_id']."' LIMIT 1");
												$url = $url->rows;
												$url = $url[0];
												$info = $db->query("SELECT * FROM ".DB_PREFIX."product_description WHERE product_id='".$product['product_id']."' LIMIT 1");
												$info = $info->rows;
												$info = $info[0];
												$new_keyword = seoURL($info['name']);
												if (!empty($url)) {
														if ($url['keyword'] != $new_keyword) {
																$db->query("UPDATE ".DB_PREFIX."url_alias SET keyword='".$new_keyword."' WHERE url_alias_id='".$url['url_alias_id']."'"); ?>
																<tr>
																		<td><?php echo $product['product_id']; ?></td>
																		<td><?php echo $info['name']; ?></td>
																		<td>Updated from "<?php echo $url['keyword']; ?>" to "<?php echo $new_keyword; ?>"</td>
																</tr>
														<?php } else { ?>
														<tr>
																<td><?php echo $product['product_id']; ?></td>
																<td><?php echo $info['name']; ?></td>
																<td>Match found, no action taken</td>
														</tr>
												<?php } } else {
														$db->query("INSERT INTO ".DB_PREFIX."url_alias SET query='product_id=".$product['product_id']."', keyword='".$db->escape($new_keyword)."'"); ?>
														<tr>
																<td><?php echo $product['product_id']; ?></td>
																<td><?php echo $info['name']; ?></td>
																<td>Inserted URL alias "<?php echo $new_keyword; ?>"</td>
														</tr>
												<?php }
										}
								} elseif ($action == "categories") {
										$categories = $db->query("SELECT * FROM ".DB_PREFIX."category");
										$categories = $categories->rows;
										foreach ($categories as $category) {
												$url = $db->query("SELECT * FROM ".DB_PREFIX."url_alias WHERE query = 'category_id=".$category['category_id']."' LIMIT 1");
												$url = $url->rows;
												$url = $url[0];
												$info = $db->query("SELECT * FROM ".DB_PREFIX."category_description WHERE category_id='".$category['category_id']."' LIMIT 1");
												$info = $info->rows;
												$info = $info[0];
												$new_keyword = seoURL($info['name']);
												if (!empty($url)) {
														if ($url['keyword'] != $new_keyword) {
																$db->query("UPDATE ".DB_PREFIX."url_alias SET keyword='".$new_keyword."' WHERE url_alias_id='".$url['url_alias_id']."'"); ?>
																<tr>
																		<td><?php echo $category['category_id']; ?></td>
																		<td><?php echo $info['name']; ?></td>
																		<td>Updated from "<?php echo $url['keyword']; ?>" to "<?php echo $new_keyword; ?>"</td>
																</tr>
														<?php } else { ?>
														<tr>
																<td><?php echo $category['category_id']; ?></td>
																<td><?php echo $info['name']; ?></td>
																<td>Match found, no action taken</td>
														</tr>
												<?php } } else {
												$db->query("INSERT INTO ".DB_PREFIX."url_alias SET query = 'category_id=".$category['category_id']."', keyword = '".$db->escape($new_keyword)."'"); ?>
														<tr>
																<td><?php echo $category['category_id']; ?></td>
																<td><?php echo $info['name']; ?></td>
																<td>Inserted URL alias "<?php echo $new_keyword; ?>"</td>
														</tr>
												<?php }
										}
								} elseif ($action == "information") {
										$informationp = $db->query("SELECT * FROM ".DB_PREFIX."information");
										$informationp = $informationp->rows;
										foreach ($informationp as $information) {
												$url = $db->query("SELECT * FROM ".DB_PREFIX."url_alias WHERE query='information_id=".$information['information_id']."' LIMIT 1");
												$url = $url->rows;
												$url = $url[0];
												$info = $db->query("SELECT * FROM ".DB_PREFIX."information_description WHERE information_id = '".$information['information_id']."' LIMIT 1");
												$info = $info->rows;
												$info = $info[0];
												$new_keyword = seoURL($info['title']);
												if (!empty($url)) {
														if ($url['keyword'] != $new_keyword) {
																$db->query("UPDATE ".DB_PREFIX."url_alias SET keyword='".$new_keyword."' WHERE url_alias_id='".$url['url_alias_id']."'"); ?>
																<tr>
																		<td><?php echo $information['information_id']; ?></td>
																		<td><?php echo $info['title']; ?></td>
																		<td>Updated from "<?php echo $url['keyword']; ?>" to "<?php echo $new_keyword; ?>"</td>
																</tr>
														<?php } else { ?>
																<tr>
																		<td><?php echo $information['information_id']; ?></td>
																		<td><?php echo $info['title']; ?></td>
																		<td>Match found, no action taken</td>
																</tr>
												<?php } } else {
														$db->query("INSERT INTO ".DB_PREFIX."url_alias SET query='information_id=".$information['information_id']."', keyword='".$db->escape($new_keyword)."'"); ?>
														<tr>
																<td><?php echo $information['information_id']; ?></td>
																<td><?php echo $info['title']; ?></td>
																<td>Inserted URL alias "<?php echo $new_keyword; ?>"</td>
														</tr>
												<?php }
										}
								} else if ($action == "manufacturers") {
										$manufacturers = $db->query("SELECT * FROM ".DB_PREFIX."manufacturer");
										$manufacturers = $manufacturers->rows;
										foreach ($manufacturers as $manufacturer) {
												$url = $db->query("SELECT * FROM ".DB_PREFIX."url_alias WHERE query='manufacturer_id=".$manufacturer['manufacturer_id']."' LIMIT 1");
												$url = $url->rows;
												$url = $url[0];
												$new_keyword = seoURL($manufacturer['name']);
												if (!empty($url)) {
														if ($url['keyword'] != $new_keyword) {
																$db->query("UPDATE ".DB_PREFIX."url_alias SET keyword='".$new_keyword."' WHERE url_alias_id='".$url['url_alias_id']."'"); ?>
																<tr>
																		<td><?php echo $manufacturer['manufacturer_id']; ?></td>
																		<td><?php echo $manufacturer['name']; ?></td>
																		<td>Updated from "<?php echo $url['keyword']; ?>" to "<?php echo $new_keyword; ?>"</td>
																</tr>
														<?php } else { ?>
														<tr>
																<td><?php echo $manufacturer['manufacturer_id']; ?></td>
																<td><?php echo $manufacturer['name']; ?></td>
																<td>Match found, no action taken</td>
														</tr>
												<?php } } else {
														$db->query("INSERT INTO ".DB_PREFIX."url_alias SET query='manufacturer_id=".$manufacturer['manufacturer_id']."', keyword='".$db->escape($new_keyword)."'"); ?>
														<tr>
																<td><?php echo $manufacturer['manufacturer_id']; ?></td>
																<td><?php echo $manufacturer['name']; ?></td>
																<td>Inserted URL alias "<?php echo $new_keyword; ?>"</td>
														</tr>
												<?php }
										}
								} ?>
						</table>
						<span class="links" style="font-size: 18px;"><a href="seo-links.php">Back</a></span>
						<?php } ?>
				</div>
    </body>
</html>

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding


Newbie

Posts

Joined
Fri Jul 06, 2012 6:11 am
Location - Fresno, CA

Post by crissyb » Fri Oct 19, 2012 4:18 pm

Thanks ;D Amazing Script i re done my who open cart with this thanks 4000+

New member

Posts

Joined
Thu Jan 05, 2012 2:04 am
Location - Middlesbrough UK

Post by willem@aquadeco » Thu Oct 25, 2012 5:43 pm

I have edited product seo link part of the script, and added a quick way to avoid duplicate product seo url's, it tries to find the model and puts that after the name if it and find it, otherwise it will use a number.

Code: Select all

<?php

require_once('config.php');
require_once(DIR_SYSTEM . 'startup.php');

// Registry
$registry = new Registry();

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);

function seoURL($str) {
    $str = preg_replace('/[^a-zA-Z0-9]+/', '-', $str);
    $str = trim($str, '-');
    $str = strtolower($str);

    return $str;
}

?>
<html>
<head>
    <title>Create SEO-links</title>
</head>
<style type="text/css">
    body {
        font-family: "Arial";
        font-size: 12px;
    }
</style>
<body>
<center>
    <h2>Script by Kartoffelz</h2>

    <?php

    if(isset($_GET['products'])) {
        $products   = $db->query("SELECT * FROM " . DB_PREFIX . "product");
        $products   = $products->rows;

        foreach($products as $product) {

            $url = $db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE query = 'product_id=" . (int)$product['product_id'] . "'");
            $url = $url->rows;

            if(!empty($url)) {
                echo 'Match found for ' . $product['product_id'] . '). No action taken.<br>---------------<br>';
            } else {
                echo 'URL needed for ' . $product['product_id'] . '. Fetching information...<br>';
                $info = $db->query("SELECT * FROM " . DB_PREFIX . "product_description WHERE product_id = '" . $product['product_id'] . "' LIMIT 1");
                $info = $info->rows;

                foreach($info as $data) {
                    echo 'Name: ' . $data['name'] . ' | Converting to: ' . seoURL($data['name']);
                    $DT_obj = $db->query("SELECT *  FROM url_alias WHERE keyword LIKE '" . seoURL($data['name']) . "'");
                    $DT_var = get_object_vars($DT_obj);
                    if ((int)$DT_var['num_rows'] >= 1) {
                        if (isset($product['model']) && $product['model' != ""]) {
                            echo '<br>Duplicate found, change url to' . seoURL($data['name']) . ($product['model']);
                            $data['name'] = seoURL($data['name']) . ($product['model']);
                        } else {
                            echo '<br>Duplicate found, change url to' . seoURL($data['name']) . "_" . ($DT_var['num_rows']);
                            $data['name'] = seoURL($data['name']) . ($DT_var['num_rows'] + 1);
                        }
                    } else {
                        $data['name'] = seoURL($data['name']);
                    }
                    sleep(1);
                    $db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'product_id=" . (int)$product['product_id'] . "', keyword = '" . $db->escape($data['name']) . "'");
                    echo '<br>Inserted!<br>---------------<br>';
                }
            }
        }

        echo '<br><br>All done! <a href="seo-links.php">Back</a>';
    }
    elseif(isset($_GET['categories'])) {
        $categories   = $db->query("SELECT * FROM " . DB_PREFIX . "category");
        $categories   = $categories->rows;

        foreach($categories as $category) {

            $url = $db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE query = 'category_id=" . (int)$category['category_id'] . "'");
            $url = $url->rows;

            if(!empty($url)) {
                echo 'Match found for ' . $category['category_id'] . '). No action taken.<br>---------------<br>';
            } else {
                echo 'URL needed for ' . $category['category_id'] . '. Fetching information...<br>';
                $info = $db->query("SELECT * FROM " . DB_PREFIX . "category_description WHERE category_id = '" . $category['category_id'] . "' LIMIT 1");
                $info = $info->rows;

                foreach($info as $data) {
                    echo 'Name: ' . $data['name'] . ' | Converting to: ' . seoURL($data['name']);
                    $data['name'] = seoURL($data['name']);
                    sleep(1);
                    $db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'category_id=" . (int)$category['category_id'] . "', keyword = '" . $db->escape($data['name']) . "'");
                    echo '<br>Inserted!<br>---------------<br>';
                }
            }
        }

        echo '<br><br>All done! <a href="seo-links.php">Back</a>';
    } elseif(isset($_GET['information'])) {
        $informationp    = $db->query("SELECT * FROM " . DB_PREFIX . "information");
        $informationp    = $informationp->rows;

        foreach($informationp as $information) {

            $url = $db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE query = 'information_id=" . (int)$information['information_id'] . "'");
            $url = $url->rows;

            if(!empty($url)) {
                echo 'Match found for ' . $information['information_id'] . '. No action taken.<br>---------------<br>';
            } else {
                echo 'URL needed for ' . $information['information_id'] . '. Fetching information...<br>';
                $info = $db->query("SELECT * FROM " . DB_PREFIX . "information_description WHERE information_id = '" . $information['information_id'] . "' LIMIT 1");
                $info = $info->rows;

                foreach($info as $data) {
                    echo 'Name: ' . $data['title'] . ' | Converting to: ' . seoURL($data['title']);
                    $data['title'] = seoURL($data['title']);
                    sleep(1);
                    $db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'information_id=" . (int)$information['information_id'] . "', keyword = '" . $db->escape($data['title']) . "'");
                    echo '<br>Inserted!<br>---------------<br>';
                }
            }
        }
        echo '<br><br>All done! <a href="seo-links.php">Back</a>';

    }
    else {
        echo '<p><a href="?products">Products</a> - Create product-URLs</p>';
        echo '<p><a href="?categories">Categories</a> - Create category-URLs</p>';
        echo '<p><a href="?information">Information</a> - Create information-URLs</p>';
    }

    ?>
</center>
</body>
</html>


Posts

Joined
Wed Oct 24, 2012 6:17 pm

Post by jbcul » Sat Oct 05, 2013 4:11 am

Does this code work for the latest releases ( 1.5.5.1 and 1.5.6)? The date of the latest post is one year old and I seemed to get errors when I tried it on 1.5.5.1. Using the code submitted by willem on 10/25/2012 I got a 4,000+ line results on products all looking like this:

Match found for 2731). No action taken.
---------------
Match found for 2732). No action taken.
---------------
Match found for 2733). No action taken

I had similar results on categories.

Active Member

Posts

Joined
Fri Feb 01, 2013 9:18 am

Post by timparnell » Tue Nov 12, 2013 9:07 pm

Thanks for this. I was planning to write a script to do something similar tonight.
Now I don't need to. Maybe I can use the time to make something else to contribute as a free mod instead - any suggestions? What would help someone out?? Sensible suggestions only, please... :laugh:
Tim

tim@pointreddesign.co.uk | http://www.pointreddesign.co.uk


User avatar
New member

Posts

Joined
Wed Feb 01, 2012 11:03 pm
Location - Norwich, Norfolk, UK

Post by divilati » Fri Dec 06, 2013 6:38 pm

First of all I must say great thanks for the effort to all of you!

I wanted to know is there a chance to modify the script a bit so it works for other languages too? e.g. Latvian?
like this engine http://speakingurl.com/#tryme
to convert non english letters to english letters

because from: sildoša-sega
I get sildo-sa-sega instead of sildosa-sega

Newbie

Posts

Joined
Thu Jul 04, 2013 8:11 pm

Post by Samrd » Mon Aug 25, 2014 4:15 pm

Can any one know how to remove auto building h2 in the product description.
Last edited by Samrd on Thu Nov 12, 2015 8:59 pm, edited 1 time in total.

Newbie

Posts

Joined
Wed Aug 06, 2014 11:57 pm

Post by joakimaolsson » Sun Aug 31, 2014 9:36 pm

Thanks for a great script!

I will add to the above posts about needing to generate multi-language urls or at least in a different language than english. I run with Swedish as default but the urls were anyway generated in English.

Should be a quick-fix in the code right?

thanks

Newbie

Posts

Joined
Mon Aug 11, 2014 9:59 pm

Post by Dhaupin » Wed Sep 10, 2014 2:16 am

Awesome! Does this still work in 1.5.6.x? I don't really wanna try it if there are known issues :)

Thanks a bunch

https://creadev.org | support@creadev.org - Opencart Extensions, Integrations, & Development. Made in the USA.


User avatar
Active Member

Posts

Joined
Tue May 13, 2014 3:45 am
Location - PA
Who is online

Users browsing this forum: No registered users and 97 guests