Jump to content

Error: Invalid address layout Duplicate entry


Recommended Posts

Recientemente al intentar crear un nuevo país me arrojaba el siguiente error Invalid address layout Duplicate entry Esto se presenta ya que cuando eliminas un país previamente, Prestashop no borra el registro en la tabla ps_address_format Para solucionarlo solo debes seguir estos pasos:

 

1) En la clase country.php ubicate en la funcion public function delete()

	public function delete()
	{		
		if (!parent::delete())
			return false;
		return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'cart_rule_country WHERE id_country = '.(int)$this->id);
	}

2) luego remplaza esa funcion por esta:

public function delete()
{

Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'address_format WHERE id_country not in (SELECT id_country FROM '._DB_PREFIX_.'country)');
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'address_format WHERE id_country = '.(int)$this->id);

if (!parent::delete())
return false;

Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'address_format WHERE id_country = '.(int)$this->id);

return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'cart_rule_country WHERE id_country = '.(int)$this->id);
}

 

 

Esta se encargará de eliminar el formato de dirección de la tabla ps_address_format cada que elimines un pais 

Edited by sebasca5 (see edit history)

Share this post


Link to post
Share on other sites
  • nadie locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More