Kolopsia Posted April 19, 2018 Share Posted April 19, 2018 Hello, I need to import products descriptions into products meta descriptions, so i executed this query and it did work UPDATE ps_product_lang SET ps_product.meta_description=(SELECT ps_product_lang_description FROM ps_product_lang but i need to strip the description of HTML tags, so what should i add to the query to get only simple text, no html tags? Any help appreciated Link to comment Share on other sites More sharing options...
tuk66 Posted April 20, 2018 Share Posted April 20, 2018 This article can help you. https://www.sitepoint.com/community/t/phps-strip-tags-equivalent-mysql-function/5817/2 Link to comment Share on other sites More sharing options...
Kolopsia Posted April 20, 2018 Author Share Posted April 20, 2018 unfortunately i have no knowledge i php ( only familiar with how some SQL queries works) so any idea how to add that function to the sql query? Link to comment Share on other sites More sharing options...
tantan199 Posted April 22, 2018 Share Posted April 22, 2018 (edited) You can create function to achieve it, see there: https://stackoverflow.com/questions/2627940/remove-html-tags-from-record and https://forums.mysql.com/read.php?52,177343,177985 Edited April 22, 2018 by tantan199 (see edit history) Link to comment Share on other sites More sharing options...
Kolopsia Posted April 23, 2018 Author Share Posted April 23, 2018 I have no knowledge of PHP, so, unfortunately, I don't know how to achieve this, can you recreate the SQL query with the function? Link to comment Share on other sites More sharing options...
selectshop.at Posted April 23, 2018 Share Posted April 23, 2018 So what you need is not a SQL query, but a simple csv import. If you don't know SQL and php, so please refrain to make any manual manipulation on the database. It is not good, if you don't know what exaclty you are doing. 1) Use the native import function on your back-office for to import your csv. If your products are already added to database, than export them from back-office. Before you import the csv again, you simply save it as UTF-8. In this case you will change encoding and strip all HMTL-tags. Export your products from back-office product site. On right top of site you will find some grey buttons. One is for export. For to reimport the products the only thing what you need is ID, product name and product description. Take this csv and save it with UTF-8 encoding. You can use the free editor PSPad for this. Simply open your csv with PSPAD, go on top to Format, check UTF-8 and save your file. After this, import your file with Prestashop native csv import. Back-office Tab "Advanced Parameters -> csv import 2) Another possibility is to use an online HTML Stripping tool like this: http://www.striphtml.com/ or https://www.browserling.com/tools/html-strip Add your text there and copy the plain text. Link to comment Share on other sites More sharing options...
Kolopsia Posted April 25, 2018 Author Share Posted April 25, 2018 On 4/23/2018 at 3:14 PM, selectshop.at said: So what you need is not a SQL query, but a simple csv import. If you don't know SQL and php, so please refrain to make any manual manipulation on the database. It is not good, if you don't know what exaclty you are doing. 1) Use the native import function on your back-office for to import your csv. If your products are already added to database, than export them from back-office. Before you import the csv again, you simply save it as UTF-8. In this case you will change encoding and strip all HMTL-tags. Export your products from back-office product site. On right top of site you will find some grey buttons. One is for export. For to reimport the products the only thing what you need is ID, product name and product description. Take this csv and save it with UTF-8 encoding. You can use the free editor PSPad for this. Simply open your csv with PSPAD, go on top to Format, check UTF-8 and save your file. After this, import your file with Prestashop native csv import. Back-office Tab "Advanced Parameters -> csv import 2) Another possibility is to use an online HTML Stripping tool like this: http://www.striphtml.com/ or https://www.browserling.com/tools/html-strip Add your text there and copy the plain text. But this method will only strip html tags on products description it will not copy products descriptions into the meta descriptions, right? Link to comment Share on other sites More sharing options...
selectshop.at Posted April 26, 2018 Share Posted April 26, 2018 On metas you are using html-tags ? This make no sense... Did you copied the text from somewhere ? Also for metas the html-tags should be stripped by UTF-8 encondig before you import your new prepared and saved utf-8 encoding csv file. So you must prepare a file with both. Link to comment Share on other sites More sharing options...
Kolopsia Posted April 26, 2018 Author Share Posted April 26, 2018 12 hours ago, selectshop.at said: On metas you are using html-tags ? This make no sense... Did you copied the text from somewhere ? Also for metas the html-tags should be stripped by UTF-8 encondig before you import your new prepared and saved utf-8 encoding csv file. So you must prepare a file with both. I think you misunderstood my question, i dont need to strip products description of html tags but i need to run sql query to import products descriptions into meta-descriptions, because if you see the screenshot, somehow despite having products description on all pages the seo inspector cant find any description on the page and im not sure why so i need to at least have the meta-description on the page but need it without html tags. Link to comment Share on other sites More sharing options...
selectshop.at Posted April 26, 2018 Share Posted April 26, 2018 Than simply map on your csv the field you have as meta-description to the meta-description field on csv import tool from your back-office. It's quite simple to import what you need by csv import. Again: If you don't know SQL and php, so please refrain to make any manual manipulation on the database. It is not good, if you don't know what exactly you are doing. You can import these data you need by csv import.You don't need any SQL query for that. Link to comment Share on other sites More sharing options...
Kolopsia Posted April 26, 2018 Author Share Posted April 26, 2018 Thank you. You can mark the post as solved. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now