Insert SEO Keyword automatically in opencart
Insert SEO Keyword automatically in opencart

Hi, today I made the script that inserts the SEO keyword automatically in opencart for already inserted products.

Once done please don’t forget to delete the seourl.php

You can enable SEO URL’s in the OpenCart but inserting the SEO keyword for each product is quite tedious and time-consuming. Some time webmaster import large data and at this time inserting the  SEO keyword by editing each product will take a lot of time. So taking this into consideration I have made a script that takes the product name and replace the space with dashes (-).

You just have to upload the “seourl.php” file to the root directory where you admin and catalog folder is and run the following URL

This inserts the SEO keywords for the products.

Following is the main codes that play the role

// Configuration
if (is_file('config.php')) {
require_once(DIR_SYSTEM . 'library/config.php');
require_once(DIR_SYSTEM . 'library/db.php');
require_once(DIR_SYSTEM . 'library/db/mysqli.php');
require_once(DIR_SYSTEM . 'engine/registry.php');
// Registry
$registry = new Registry();
// Config
$config = new Config();
$registry->set('config', $config);
// Database
$db =  new DB($config->get('db_engine'), $config->get('db_hostname'), $config->get('db_username'), $config->get('db_password'), $config->get('db_database'), $config->get('db_port'));
    $limit= " limit 0, ".$_GET['limit'];
$query = $db->query("select * from " . DB_PREFIX . "product_description" );
$products = $query->rows;

foreach ($products as $product) {
    $name = $product['name'];
    $name = str_replace("'", '-', strtolower($name));
    $seoname = preg_replace('/s/', '-', $name);
    $seoname = str_replace([':', '\\', '/', '*', ' ','&', "'"], '-', $seoname);
    $seourl = "product_id=" . $product['product_id'];
    $query12 = $db->query("select * from " . DB_PREFIX . "seo_url where query='" . $seourl . "'");
    //echo "<pre>";
    if (!$query12->row) {
        $db->query("insert into " . DB_PREFIX . "seo_url set query='" . $seourl . "', keyword='" . $seoname . "'");
        echo "<br>Inserted " . $seoname;
echo "<br>Total products ".$pi;
echo "<br>Number of products seo title changed- ".$pc;

It retrieves the name from the product_description table and replace ‘,&,/, space with the dash (-) and check whether the URL already exit and if not then it inserts the SEO keyword. if you need to remove and then just add the replace statement again.

Insert SEO Keyword automatically in opencart
Insert SEO Keyword automatically in opencart


  1. Fatal error: Cannot instantiate abstract class VQMod in /home/jacobch/www/ipc_li/shop/seourl.php on line 13

    I use OpenShop v.1.7 (OC v.
    OpenShop has placed tthe VqMod Sub here:

    therefore, it does not work here.



Please enter your comment!
Please enter your name here