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.

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

http://www.YOURURL.com/seourl.php

This inserts the SEO keywords for the products.

Following is the main codes that play the role

$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('&', '-', strtolower($seoname));
$seoname=str_replace('/', '-', strtolower($seoname));
$seourl="product_id=".$product['product_id'];
$query12=$db->query("select * from " . DB_PREFIX . "url_alias where query='".$seourl."'");
if(!$query12->row){
$db->query("insert into " . DB_PREFIX . "url_alias set query='".$seourl."', keyword='".$seoname."'");
echo "<br>Inserted".$seoname;
}

}

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

2 COMMENTS

  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.1.5.6.1-4)
    OpenShop has placed tthe VqMod Sub here:
    /shop/vqmod/xml/

    therefore, it does not work here.

    Ernie

LEAVE A REPLY

Please enter your comment!
Please enter your name here