Jump to content

Can't add or change any states.


balaomais

Recommended Posts

Hi,

This is not a configuration issue , it’s a bug in PrestaShop 9.0.2.

Your screenshot shows this error:

AddStateCommand::__construct(): Argument #1 ($countryId) must be of type int, string given

So when you save a State, the form sends country_id as a string, but the command expects an int, and the back office crashes.

The real fix :

Update PrestaShop to the latest 9.0.x patch (9.0.3 / 9.0.4+). This issue is typically fixed in a patch release.

Quick workaround (if you can’t update right now)

Patch the core to cast the country id to int in:

src/Core/Form/IdentifiableObject/DataHandler/StateFormDataHandler.php

Before creating the command, cast it:

$countryId = (int) $data['country_id'];

Then use $countryId when building AddStateCommand.

Note: this is a core change and will be overwritten by the next update, so upgrading is the clean solution.

Edited by wepresta (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...