Move plain text metafield with some tags to html body

Solved

Move plain text metafield with some tags to html body

LottieKing
Visitor
2 0 2

I am in the middle of a rebuild and trying to move all my product descriptions across in bulk from a multi line text metafield back into the main description body html.

 

The data for the multi-line text metafield is only stored in Shopify as plain text data. When I use the app Matrixify to export this metafield it comes into an excel spreadsheet as plain text but with all line breaks present, in the same structure it appears on Shopify.

 

I can then import this plain text data through Matrixify into the body html and it will generate the line break tags for me. This works perfectly but I’m running into some trouble as the app Matrixify will not auto generate the line break tags if there are any html tags included in the plain text file.

 

Some of these plain text descriptions in my spreadsheet have html tags written into them, as my old theme would render these on my site.

 

Does anyone have a work around for moving plain text data with some written html into body html without loosing the line break information?

Accepted Solution (1)

Renars
Shopify Partner
309 32 367

This is an accepted solution.

Hi @LottieKing 

Renars here from Matrixify app. Thank you for using our app for this task and mentioning it here.

 

Found one solution which would be to use the Excel SUBSTITUTE formula to bulk replace the line breaks in the text with HTML `<br>` tags.

 

An example of the process could look like this:

  1. You have a file with this Metafield where you have new line rows in the Metafields value. In the column next to the Metafield (add new one if there is already data in there), in row 2 add formula `=SUBSTITUTE(F2,CHAR(10),"<br>")`. This formula will change any occurrence of a specific text within cells value with another text.
    There are 3 parts of this formula (see also my example screenshot below):
    • F2 - is the column and row of the metafields text (you would need to change the F to your Metafield columns letter/s).
    • CHAR(10) - is the formula for a new line character.
    • <br> - Replace with <br> for HTML line break.
  2. Fill that formula till the end of the file's data and you have generated the same metafield values but only with <br> tags where there was a line break in the text.

 

Renars_1-1715774772129.png

 

Then you can use this within the Body HTML column to add the value to the description but without line breaks.

 

Hope this helps!

Matrixify | Bulk Import Export Update | https://apps.shopify.com/excel-export-import | https://matrixify.app

View solution in original post

Replies 6 (6)

StephensWorld
Shopify Partner
1400 174 369

The only way I know of doing this for large amount of texts is via this tool: 

 

https://www.gillmeister-software.com/online-tools/text/remove-line-breaks.aspx

 

However, I don't think that'll work great for bulk editing products. When you do the original export via Matrixify, to get all of the metafields in a spreadsheet, you'd probably have to do a bunch of copy and pasting, where you run one cell at a time, via the link above, then paste the results back into the respective cell on the sheet. I don't think it'll handle splitting things up based on cells for you. 

★ Did my post help? If yes, then please like and accept solution. ★

https://stephens.world
support@stephensworld.ca

Renars
Shopify Partner
309 32 367

This is an accepted solution.

Hi @LottieKing 

Renars here from Matrixify app. Thank you for using our app for this task and mentioning it here.

 

Found one solution which would be to use the Excel SUBSTITUTE formula to bulk replace the line breaks in the text with HTML `<br>` tags.

 

An example of the process could look like this:

  1. You have a file with this Metafield where you have new line rows in the Metafields value. In the column next to the Metafield (add new one if there is already data in there), in row 2 add formula `=SUBSTITUTE(F2,CHAR(10),"<br>")`. This formula will change any occurrence of a specific text within cells value with another text.
    There are 3 parts of this formula (see also my example screenshot below):
    • F2 - is the column and row of the metafields text (you would need to change the F to your Metafield columns letter/s).
    • CHAR(10) - is the formula for a new line character.
    • <br> - Replace with <br> for HTML line break.
  2. Fill that formula till the end of the file's data and you have generated the same metafield values but only with <br> tags where there was a line break in the text.

 

Renars_1-1715774772129.png

 

Then you can use this within the Body HTML column to add the value to the description but without line breaks.

 

Hope this helps!

Matrixify | Bulk Import Export Update | https://apps.shopify.com/excel-export-import | https://matrixify.app
LottieKing
Visitor
2 0 2

Thanks Renars, the substitute formula in excel worked perfectly for this. I appreciate the help. 

morojp82
Tourist
10 0 3

Hi Renars, came across this post as I have a similar issue. I have two different rich text shopify metafields that I need to reformat as an unordered list type.  I had previously manually added bullet points but this is not correct hence why I need to change the formatting.

 

Below is an example of a metafield I manually updated to the correct format:

 

{"type":"root","children":[{"type":"paragraph","children":[{"type":"text","value":" Sensorless GPS computer with Glonass\n Simple setup via smartphone with programmable 3-row display\n Bluetooth® enabled for connectivity with popular speed, cadence and heart rate sensors\n Backlight (Night mode)\n Stores up to 80 hours of ride data\n Import ride data to CatEye Cycling™\n Upload ride data to CatEye Atlas™, Strava™ and TrainingPeaks™\n Battery alert of connected sensors\n OF-100 Out-Front Bracket (26-31 mm)"}]}]}

 

The following is a current (incorrectly) formatted rich text metafield that I need to format:

 

{"type":"root","children":[{"type":"paragraph","children":[{"type":"text","value":" Sensorless GPS computer with Glonass\n Simple setup via smartphone with programmable 3-row display\n Bluetooth® enabled for connectivity with popular speed, cadence and heart rate sensors\n Backlight (Night mode)\n Stores up to 80 hours of ride data\n Import ride data to CatEye Cycling™\n Upload ride data to CatEye Atlas™, Strava™ and TrainingPeaks™\n Battery alert of connected sensors\n OF-100 Out-Front Bracket (26-31 mm)"}]}]}

 

Every sentence that starts with "\n" should be a new line like:

 

Sensorless GPS computer with Glonass
Simple setup via smartphone with programmable 3-row display

etc...

 

I've exported the data via matrixify into excel but not sure how to correctly reformat thru excel.

 

Any help is greatly appreciated!

Renars
Shopify Partner
309 32 367

Hello @morojp82 

This is a bit tricky one as rich text field is a JSON code and it would not have such new lines in the code itself. Newlines are expressed in Rich text as "/n" which you already have so the value you have should work already as is.

I copied the incorrect example from your post and it look like this in Shopify Admin, so the values seem to be correct:

 

Renars_0-1722977650187.png

 

 

Could it be that you might have sent incorrect example for the metafields value that is not correct?

Matrixify | Bulk Import Export Update | https://apps.shopify.com/excel-export-import | https://matrixify.app
morojp82
Tourist
10 0 3

 

The issue originally is that I didn't correctly format the bullet points as the unordered list type as indicated in the attached screenshot and that caused a display issue in the collapsible block used to display this data.

 

Screenshot 2024-08-07 at 8.45.46 AM.jpg

I double checked and I sent you the wrong example of the correctly formatted metafield. 

 

Here is the desired format that outputs to individual lines w bullet points:

 

{"type":"root","children":[{"type":"list","listType":"unordered","children":[{"type":"list-item","children":[{"type":"text","value":"Sensorless GPS computer with Glonass"}]},{"type":"list-item","children":[{"type":"text","value":"Simple setup via smartphone with programmable 3-row display"}]},{"type":"list-item","children":[{"type":"text","value":"Bluetooth® enabled for connectivity with popular speed, cadence and heart rate sensors"}]},{"type":"list-item","children":[{"type":"text","value":"Backlight (Night mode)"}]},{"type":"list-item","children":[{"type":"text","value":"Stores up to 80 hours of ride data"}]},{"type":"list-item","children":[{"type":"text","value":"Import ride data to CatEye Cycling™"}]},{"type":"list-item","children":[{"type":"text","value":" Upload ride data to CatEye Atlas™, Strava™ and TrainingPeaks™"}]},{"type":"list-item","children":[{"type":"text","value":"Battery alert of connected sensors"}]},{"type":"list-item","children":[{"type":"text","value":"FlexTight™ universal bracket"}]}]}]}

 

The incorrect format is below where I had manually added the bullet points:

 

{"type":"root","children":[{"type":"paragraph","children":[{"type":"text","value":" • Sensorless GPS computer with Glonass\n • Simple setup via smartphone with programmable 3-row display\n • Bluetooth® enabled for connectivity with popular speed, cadence and heart rate sensors\n • Backlight (Night mode)\n • Stores up to 80 hours of ride data\n • Import ride data to CatEye Cycling™\n • Upload ride data to CatEye Atlas™, Strava™ and TrainingPeaks™\n • Battery alert of connected sensors\n • OF-100 Out-Front Bracket (26-31 mm)"}]}]}

 

I went ahead and spent yesterday manually updating it thru shopify but it would be great if there was a way I could bulk export and correct formatting issues like this in the future.

 

Any suggestions?

 

Thanks!