Upgrade Craft v2 to v3. Simple Maps 1.8.2 to Mpas 3.9.0.2
Description
I performed the upgrade from craft v2 to v3 without a problem.
Steps to reproduce
Then I went to install all the related plugins via the app store. No problem, no errors.
BUT: all the maps are empty?
The table craft_maps is there and there are lots of entries (900).
I did run the migrations via the terminal. but there were no migrations to run.
What can I do to not re-enter 900 entries by hand?
Additional info
- Craft version: 3.6.7
- Maps version: 3.9.0.2
- PHP version: 7.4.15
I'm experiencing the same problem. I'm not entirely sure if the Craft 2 specific migration track is intending to handle the Craft 2 map data in full.
My alternative option that I have been considering is potentially looking at having the simple maps data from Craft 2 as a Element API endpoint and import the map data as JSON via FeedMe into Craft 3, using the ElementId as the key, given they wouldn't have changed between Craft 2 and 3.
Would be good to know what the Craft 2 -> 3 migration process is intending to handle by the devs though before I end up going down that road.
Personally, I would go down the JSON FeedMe road. FeedMe JSON Import in Craft 3 for Maps is great!
It would be great to hear from maps what's the best way to upgrade from craft 2 to craft 3 without loosing all the data. Every site that used maps in craft 2 failed to migrate the data to craft 3.
Btw: craft support sent me this craft 3 starter code, which came in handy: (obviously it's for craft 3, but easily adaptable)
{%- header "Content-Type:application/json" -%}
{%- set entries = craft.entries().section('yourSection').all() -%}
{
"entries" : [
{%- for entry in entries -%}
{
"import Id": "{{ entry.id }}",
"title": {{ entry.title|json_encode|raw }},
"slug": "{{ entry.slug }}",
"postDate": "{{ entry.postDate|atom }}",
"yourMapsField": [
{
"lat": "{{ entry.yourMapsField.lat }}",
"lng": "{{ entry.yourMapsField.lng }}",
"zoom": "{{ entry.yourMapsField.zoom }}",
"address": {{ entry.yourMapsField.address(['country'], ', ')|json_encode|raw }}
}
]
}{{ not loop.last ? ',' }}
{%- endfor -%}
]
}
Good luck
You should be able to use the ElementAPI to create the JSON format for you to do the heavy lifting with formatting, rather than using Twig potentially, but as long as you can have a valid JSON file for the map data at the end, it's the same outcome, as that's what's needed for FeedMe.
I think importing via JSON is the only alternative. I've also noticed map fields in matrix don't get migrated their fieldtype changed either, I think there are gaps in the Craft 2 -> 3 migration path. If you have small amounts of map fields it's probably fine to do manually, but like you and I, if you have a Craft 2 site that has hundreds, it's not realistic.
It would still be nice for official comment from the devs. Resaving a map field after migration manually works, but it seems to create two records in the maps table each time.
I believe, I've found the reason why the maps are blank from Craft 2. We know the map data is there but on the Craft content table the map field itself is null entirely, it's all missing on the Craft content table.
Map table:
ownerId - Corresponds to the elementId in the Craft content table
Content table:
elementId - Which is the ownerId in the map table
map field column - Whatever this is called in your Craft install in my case field_map. This contains the JSON data that should be present.
Essentially, the JSON data needs populating into the Craft content table, because it's missing. Potentially this can be regenerated by using linking the ownerId and elementId and resaving the map model. Although, regenerating the address data from this seems tricky with only lat and lng values.
Looking at FeedMe if you have map data in multiple entry channels that's a feed per channel, which is painful. Ultimately this would be a plugin migration issue, but potentially with some DB work or a content migration you could essentially relink the records in the map table back to the Craft content table.