here is a module to add all geozones. not sure if it will help
http://www.opencart.com/index.php?route ... order=DESC
http://www.opencart.com/index.php?route ... order=DESC
“Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.”
- Henry Ford
I have found another solution which does not require any modules. Basically what you are going to do is insert all the rows via sql.
To do I added the first country into geo zones.
Then I went into phpmyadmin and did a copy on the last entry of the oc_zone_to_geo_zone table. Instead of doing a copy I displayed the sql and copied the insert statement into excel.
Next I applied a left to the field to seperate out the string up until the country ID (=LEFT(Sheet2!A229,163))
Next I applied a right (=RIGHT(Sheet2!A229,60))
So with the above I have the mysql statement minus the country id
I created a column with numbers from 2 to 239 (to cover the rest of the countries)
I then did a (=CONCATENATE(B229,C229,D229)) to re-combine the mysql
I then pulled down the columns to auto-populate.
This give 238 lines of mysql. Simply copy the column and paste as a mysql query and all is done.
If anyone wants a sample xls please contact me.... (I'm not sure if this board lets me post my email address)
To do I added the first country into geo zones.
Then I went into phpmyadmin and did a copy on the last entry of the oc_zone_to_geo_zone table. Instead of doing a copy I displayed the sql and copied the insert statement into excel.
Next I applied a left to the field to seperate out the string up until the country ID (=LEFT(Sheet2!A229,163))
Next I applied a right (=RIGHT(Sheet2!A229,60))
So with the above I have the mysql statement minus the country id
I created a column with numbers from 2 to 239 (to cover the rest of the countries)
I then did a (=CONCATENATE(B229,C229,D229)) to re-combine the mysql
I then pulled down the columns to auto-populate.
This give 238 lines of mysql. Simply copy the column and paste as a mysql query and all is done.
If anyone wants a sample xls please contact me.... (I'm not sure if this board lets me post my email address)
Here is a php script I wrote that creates a geo zone for all countries except USA. just copy it into a text editor, add your db info, save the file with anynameyouwant.php load it to your server and run it. simple.
<?php
session_start();
#### you can find this information in your config file
$dbconfig ['host'] = ""; //your database host name goes here
$dbconfig ['user'] = ""; //your database user name goes here
$dbconfig ['pwd'] = ""; //your database password goes here
$dbconfig ['db'] = ""; //your database name goes here
$dbprefix ['prefix'] = ""; //your database prefix goes here
$link = mysql_connect ($dbconfig ['host'], $dbconfig ['user'], $dbconfig ['pwd'])or die ("could not connect");
mysql_select_db ($dbconfig ['db'], $link) or die ("could not select database");
####Sets up a new geo_zone called international####
$table1 = $dbprefix."geo_zone";
$name = "International";
$description = "International";
$now = date("Y-m-d H:i:s");
mysql_query("INSERT INTO '$table1' (name, description, date_modified, date_added ) VALUES ('$name', '$description', '$now', '$now')")or die(mysql_error());
$geo_zone_id = mysql_insert_id(); //gets the id of the geo zone just created
$table2 = $dbprefix."zone_to_geo_zone";
for ($i=1;$i<249;$i++)
{
$now = date("Y-m-d H:i:s");
$country_id = $i;
$zone_id = "0";
if ($country_id == "223"){ //this removes USA
}else{
mysql_query("INSERT INTO '$table2' (country_id, zone_id, geo_zone_id, date_added ) VALUES ('$country_id', '$zone_id', '$geo_zone_id', '$now')")or die(mysql_error());
echo "country_id=".$country_id." and time=".$now."<br>";
}
}
echo "Done!";
?>
<?php
session_start();
#### you can find this information in your config file
$dbconfig ['host'] = ""; //your database host name goes here
$dbconfig ['user'] = ""; //your database user name goes here
$dbconfig ['pwd'] = ""; //your database password goes here
$dbconfig ['db'] = ""; //your database name goes here
$dbprefix ['prefix'] = ""; //your database prefix goes here
$link = mysql_connect ($dbconfig ['host'], $dbconfig ['user'], $dbconfig ['pwd'])or die ("could not connect");
mysql_select_db ($dbconfig ['db'], $link) or die ("could not select database");
####Sets up a new geo_zone called international####
$table1 = $dbprefix."geo_zone";
$name = "International";
$description = "International";
$now = date("Y-m-d H:i:s");
mysql_query("INSERT INTO '$table1' (name, description, date_modified, date_added ) VALUES ('$name', '$description', '$now', '$now')")or die(mysql_error());
$geo_zone_id = mysql_insert_id(); //gets the id of the geo zone just created
$table2 = $dbprefix."zone_to_geo_zone";
for ($i=1;$i<249;$i++)
{
$now = date("Y-m-d H:i:s");
$country_id = $i;
$zone_id = "0";
if ($country_id == "223"){ //this removes USA
}else{
mysql_query("INSERT INTO '$table2' (country_id, zone_id, geo_zone_id, date_added ) VALUES ('$country_id', '$zone_id', '$geo_zone_id', '$now')")or die(mysql_error());
echo "country_id=".$country_id." and time=".$now."<br>";
}
}
echo "Done!";
?>
Hi there.
I had a similar requirement. I have a Geo Zone for Australia, and wanted one for "rest of the world".
So I created a new Geo Zone called "Elsewhere" and then ran the following the mysql script in phpMyAdmin.
This script basically assigns all countries other than Australia to the "Elsewhere" geo zone. By specifying a zero for zone_ids, I wasn't specifying states, counties, areas with a country.
insert into oc_zone_to_geo_zone (country_id, zone_id, geo_zone_id, date_added, date_modified)
select c.country_id, 0, g.geo_zone_id, now(), now()
from oc_geo_zone g, oc_country c
where upper(g.name) = 'ELSEWHERE'
and upper(c.name) <> 'AUSTRALIA';
I had a similar requirement. I have a Geo Zone for Australia, and wanted one for "rest of the world".
So I created a new Geo Zone called "Elsewhere" and then ran the following the mysql script in phpMyAdmin.
This script basically assigns all countries other than Australia to the "Elsewhere" geo zone. By specifying a zero for zone_ids, I wasn't specifying states, counties, areas with a country.
insert into oc_zone_to_geo_zone (country_id, zone_id, geo_zone_id, date_added, date_modified)
select c.country_id, 0, g.geo_zone_id, now(), now()
from oc_geo_zone g, oc_country c
where upper(g.name) = 'ELSEWHERE'
and upper(c.name) <> 'AUSTRALIA';
Here's a script that will insert all but one country into a geozone
First, create a geozone with no countries in it in your admin panel.
Next, upload the attached to the store root and run it in a browser. e.g. yourdomain.com/xxx.php
First, create a geozone with no countries in it in your admin panel.
Next, upload the attached to the store root and run it in a browser. e.g. yourdomain.com/xxx.php
Attachments
great solution and really I appreciate you for your post....much helpful and easyuksitebuilder wrote: ↑Thu Oct 17, 2019 5:37 pmHere's a script that will insert all but one country into a geozone
First, create a geozone with no countries in it in your admin panel.
Next, upload the attached to the store root and run it in a browser. e.g. yourdomain.com/xxx.php
Who is online
Users browsing this forum: No registered users and 283 guests