0

I am using the country query to retrieve information about a specific country. When I pass the country code as AU, in the available regions I am getting duplicate values as well as the code and name is showing as "-"

https://devdocs.magento.com/guides/v2.4/graphql/queries/directory-country.html#region

Below is the response I am getting:

{
    "data": {
        "country": {
            "id": "AU",
            "available_regions": [
                {
                    "id": 910,
                    "code": "AC",
                    "name": "Aust Capital Terr"
                },
                {
                    "id": 913,
                    "code": "NW",
                    "name": "New South Wales"
                },
                {
                    "id": 916,
                    "code": "QL",
                    "name": "Queensland"
                },
                {
                    "id": 919,
                    "code": "TA",
                    "name": "Tasmania"
                },
                {
                    "id": 922,
                    "code": "VC",
                    "name": "Victoria"
                },
                {
                    "id": 5127,
                    "code": "-",
                    "name": "-"
                },
                {
                    "id": 569,
                    "code": "ACT",
                    "name": "Australian Capital Territory"
                },
                {
                    "id": 570,
                    "code": "NSW",
                    "name": "New South Wales"
                },
                {
                    "id": 576,
                    "code": "NT",
                    "name": "Northern Territory"
                },
                {
                    "id": 572,
                    "code": "QLD",
                    "name": "Queensland"
                },
                {
                    "id": 573,
                    "code": "SA",
                    "name": "South Australia"
                },
                {
                    "id": 574,
                    "code": "TAS",
                    "name": "Tasmania"
                },
                {
                    "id": 571,
                    "code": "VIC",
                    "name": "Victoria"
                },
                {
                    "id": 575,
                    "code": "WA",
                    "name": "Western Australia"
                }
            ]
        }
    }
}

How can I remove the duplicate regions as well as the "-". Please help.

2 Answers 2

0

you just need to go phpmyadmin. open table directory_country_region

search country_id = AU

OR

Run this below query :-

> SELECT * FROM `directory_country_region` WHERE `country_id` LIKE '%AU%'

After run query or search country_id by AU you shown this type.

enter image description here

Then, you get all the record related to country Austaliya ,delete the record that you want.

After you delete your duplicate regions, the output will show as per the same as below in the graphql query.

enter image description here

If any query let me know.

THANKS.

0

You need to follow these steps:

=> Navigate to the admin panel.

=> From the main navigation menu, choose Stores.

=> Under Region & City Manager, select Manage Regions.

You can then explore all regions in the grid and delete the one mentioned {id: 5127, name: "_"} by selecting it from the Action coloumn, as shown in the attached image.

Then you can check the respose data again, for this query:

query {
    country(id: "AU") {
        id
        two_letter_abbreviation
        three_letter_abbreviation
        full_name_locale
        full_name_english
        available_regions {
            id
            code
            name
        }
    }
}

Notes:

  • Double-check the base URL for the GraphQL instance you're working on.
  • I am using Magento 2.4.6, so this answer is based on this version.

enter image description here

1
  • This does not look like a native Magento answer. I don't think such a menu exist. You might have some module installed on your Magento.
    – Cladiuss
    Oct 3, 2023 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.