PhiLho Posted January 6, 2013 Share Posted January 6, 2013 (edited) I am importing a Zen Cart shop into PrestaShop 1.5.3.1, and after some trial & errors & adjustments, it works quite well. I went to the stage of importing the addresses. First, I want to point out a little inconsistency: the Force identifiers check box isn't here (why not, as the base doesn't refers directly to these rows), but the gray explanation line of the check box (present for other kinds of imports) is still there. I was uneasy at the idea to import the countries by their names, as one can expect some small discrepancies in the names (eg. dash vs. space or similar). So I exported my data with the ISO2 country code (like FR for France, US for United-States, etc.), but I found out that PS wasn't recognizing the codes. So I made a little hack to fix this missing feature. Still uneasy with the overrides, I directly hacked the source code... I post here in the hope it can be useful to somebody, or, even better, if it can be integrated to PrestaShop itself (the hack is small and safe). I can make a Pull request later, if time permits, otherwise just feel free to take it as it is. classes/Country.php: /** * Get a country id with its ISO2 code. * * @param string $code ISO2 code * @return intval Country id */ public static function getIdByIsoCode($code) { $sql = ' SELECT `id_country` FROM `'._DB_PREFIX_.'country` WHERE `iso_code` = \''.pSQL($code).'\''; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return (int)$result['id_country']; } controllers/admin/AdminImportController.php: -> addressImport() if ($id_country = Country::getIdByName(null, $address->country)) $address->id_country = (int)$id_country; else if ($id_country = Country::getIdByIsoCode($address->country)) $address->id_country = (int)$id_country; else { $country = new Country(); // [...] That's all. Edited January 9, 2013 by PhiLho (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now