Masino Sinaga Posted June 4, 2009 Share Posted June 4, 2009 Dear PrestaShop Developer Team,I have been using PrestaShop for about two months and everything seems okay.Currently, the iso_code field length in ps_state table is VarChar(3), whereas the maximum length character in this field only 2. There are 52 records belong to US country. I am from Indonesia. When I added my country's state, it has a limitation, since our country has the same iso_code with one of US state.Let's see the state example between US and Indonesia below.In US, the Kansas state has the iso_code = KSIn Indonesia, the Kalimantan Selatan state has the iso_code = KSMy questions/suggestions to PrestaShop Developer Team are:1) In my humble opinion, this iso_code field should be changed from VarChar(3) at least become VarChar(4) for the next stable release (1.2) version. Therefore, from that case above, Kansas' iso_code become: USKS, and Kalimantan Selatan's iso_code become: IDKS. Obviously, this will avoid duplicate iso_code with another countries' state. ;-)2) I am still using version 1.1 since the 1.2 has not been released, yet. Is it possible if I altered this iso_code field length from VarChar(3) become VarChar(4) ? Do you think this table change will not generate an error? Actually, I had altered this table in order to avoid duplicate iso_code in ps_state.Your feedback, please? Thank you very much. Link to comment Share on other sites More sharing options...
Damien Metzger Posted June 4, 2009 Share Posted June 4, 2009 I already changed it to char(4) if I remember well.Check the 1.2. Link to comment Share on other sites More sharing options...
Patric Posted June 4, 2009 Share Posted June 4, 2009 I already changed it to char(4) if I remember well.Check the 1.2. Yes, this is the case on 1.2. Link to comment Share on other sites More sharing options...
Masino Sinaga Posted June 4, 2009 Author Share Posted June 4, 2009 Dear Damien and Zendik,Thanks so much for your quick response.Actually, I am having trouble after implemented the change on version 1.2 to version 1.1.I edit the related code at these files:1) \admin\tabs\AdminStates:2) \classes\State.php3) \classes\Validate.phpAfter that, I added a new state, and when I clicked on the Save button, there was no confirmation message appear whether it succedded or not. I checked the table, that new record was never been saved.Did I miss something? :-S Link to comment Share on other sites More sharing options...
Masino Sinaga Posted June 4, 2009 Author Share Posted June 4, 2009 Hi again,After several times trial and error (lol), I succeeded doing this modification.All that I have done (in 1.1 version based on 1.2 Alpha version) is:1) Alter ps_state by changing iso_code field from varchar(3) become varchar(4).2) Open \classes\Validate.php, added this function: static public function isStateIsoCode($isoCode) { return preg_match('/^[a-z]{1,4}$/ui', $isoCode); } below this function: static public function isLanguageIsoCode($isoCode) { return preg_match('/^[a-z]{2,3}$/ui', $isoCode); } 3) Open \classes\State.php, replace this: protected $fieldsSize = array('iso_code' => 3, 'name' => 32); protected $fieldsValidate = array('id_country' => 'isUnsignedId', 'id_zone' => 'isUnsignedId', 'iso_code' => 'isLanguageIsoCode', 'name' => 'isGenericName', 'tax_behavior' => 'isUnsignedInt', 'active' => 'isBool'); with this: protected $fieldsSize = array('iso_code' => 4, 'name' => 32); protected $fieldsValidate = array('id_country' => 'isUnsignedId', 'id_zone' => 'isUnsignedId', 'iso_code' => 'isStateIsoCode', 'name' => 'isGenericName', 'tax_behavior' => 'isUnsignedInt', 'active' => 'isBool'); 4) Open \{admindir}\tabs\AdminStates.php, replace this: <input type="text" size="4" maxlength="3" name="iso_code" with this: <input type="text" size="5" maxlength="4" name="iso_code" 5) Clear compile directory content6) Test again, and it works good!Hope this helpful. Link to comment Share on other sites More sharing options...
Recommended Posts