How to remove tags from short description programmatically in Magento 2?Description & Short description not updatingMove short description below page product detail title via XMLMagento 2: move the javascript to the end of the bodyShort Description / Description field, import Custom Attribute fieldRemove width=“” and height=“” from product imagesMagento 2 Product Short Description Truncate?Customize and override default magento meta tags in <head> for better SEOHow to set product Limit in cms page in Magento 1add product title into product tabsMagento 2 Configurable product radio button after need to short description show

Explicit song lyrics checker

TV show starring two men who develop various gadgets

In the US, can a former president run again?

Can a character with the Polearm Master feat make an opportunity attack against an invisible creature that enters their reach?

Is using Legacy mode is a bad thing to do?

Fibonacci sequence and other metallic sequences emerged in the form of fractions

How do I become a better writer when I hate reading?

I just entered the USA without passport control at Atlanta airport

Fill the maze with a wall-following Snake until it gets stuck

First occurrence in the Sixers sequence

...and then she held the gun

Regex version of strip() - Ch. 7 Automate the Boring Stuff

How can I ping multiple IP addresses at the same time?

Are there foreign customs agents on US soil?

Is this broken pipe the reason my freezer is not working? Can it be fixed?

How to sort human readable size

Are there any individual aliens that have gained superpowers in the Marvel universe?

Does knowing the surface area of all faces uniquely determine a tetrahedron?

Would a 7805 5v regulator drain a 9v battery?

How did the European Union reach the figure of 3% as a maximum allowed deficit?

Why can't I craft scaffolding in Minecraft 1.14?

Justifying Affordable Bespoke Spaceships

Right indicator flash-frequency has increased and rear-right bulb is out

What are the mechanical differences between Adapt and Monstrosity?



How to remove
tags from short description programmatically in Magento 2?


Description & Short description not updatingMove short description below page product detail title via XMLMagento 2: move the javascript to the end of the bodyShort Description / Description field, import Custom Attribute fieldRemove width=“” and height=“” from product imagesMagento 2 Product Short Description Truncate?Customize and override default magento meta tags in <head> for better SEOHow to set product Limit in cms page in Magento 1add product title into product tabsMagento 2 Configurable product radio button after need to short description show






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I am using Magento 2.3.1



I have 8000 products which are migrated from Magento 1. The issue is that the
tags are added in short and long description in Magento 2. Please see below content for reference:
enter image description here



This is how short description looks like in the front end. Below content is added in the product in admin:



This is the short description migrated from Magento 1<br><br>short description<br><br>• This is the point 1<br>• This is the point 2<br>• This is the point 3<br>• This is the point 4<br>• This is the point 5<br>•<b>This is the point 6</b>


I have used the below code:



<?php 
$short_description = strip_tags( $short_description, 'li' );
$short_description = "<ul><li>" . preg_replace( '/[rn]+/', '</li><li>',
$short_description ) . "</li></ul>";
$short_description = str_replace('<li></li>', '', $short_description );
?>
<?= $short_description ?>


But the whole content is displayed in one <li> tag after implementing the above code.



Now I want to add each bullet points in <li> tags and also I want to remove <br> tag from the content as well. how can I do this?










share|improve this question

















  • 1





    why are you remove <ul> <li> & <br> tag? If you are using editor in admin then you can get save formate value in frontend using function. $block->filterOutputHtml('yout field_name')

    – Chirag Patel
    Jun 10 at 8:28


















3















I am using Magento 2.3.1



I have 8000 products which are migrated from Magento 1. The issue is that the
tags are added in short and long description in Magento 2. Please see below content for reference:
enter image description here



This is how short description looks like in the front end. Below content is added in the product in admin:



This is the short description migrated from Magento 1<br><br>short description<br><br>• This is the point 1<br>• This is the point 2<br>• This is the point 3<br>• This is the point 4<br>• This is the point 5<br>•<b>This is the point 6</b>


I have used the below code:



<?php 
$short_description = strip_tags( $short_description, 'li' );
$short_description = "<ul><li>" . preg_replace( '/[rn]+/', '</li><li>',
$short_description ) . "</li></ul>";
$short_description = str_replace('<li></li>', '', $short_description );
?>
<?= $short_description ?>


But the whole content is displayed in one <li> tag after implementing the above code.



Now I want to add each bullet points in <li> tags and also I want to remove <br> tag from the content as well. how can I do this?










share|improve this question

















  • 1





    why are you remove <ul> <li> & <br> tag? If you are using editor in admin then you can get save formate value in frontend using function. $block->filterOutputHtml('yout field_name')

    – Chirag Patel
    Jun 10 at 8:28














3












3








3


1






I am using Magento 2.3.1



I have 8000 products which are migrated from Magento 1. The issue is that the
tags are added in short and long description in Magento 2. Please see below content for reference:
enter image description here



This is how short description looks like in the front end. Below content is added in the product in admin:



This is the short description migrated from Magento 1<br><br>short description<br><br>• This is the point 1<br>• This is the point 2<br>• This is the point 3<br>• This is the point 4<br>• This is the point 5<br>•<b>This is the point 6</b>


I have used the below code:



<?php 
$short_description = strip_tags( $short_description, 'li' );
$short_description = "<ul><li>" . preg_replace( '/[rn]+/', '</li><li>',
$short_description ) . "</li></ul>";
$short_description = str_replace('<li></li>', '', $short_description );
?>
<?= $short_description ?>


But the whole content is displayed in one <li> tag after implementing the above code.



Now I want to add each bullet points in <li> tags and also I want to remove <br> tag from the content as well. how can I do this?










share|improve this question














I am using Magento 2.3.1



I have 8000 products which are migrated from Magento 1. The issue is that the
tags are added in short and long description in Magento 2. Please see below content for reference:
enter image description here



This is how short description looks like in the front end. Below content is added in the product in admin:



This is the short description migrated from Magento 1<br><br>short description<br><br>• This is the point 1<br>• This is the point 2<br>• This is the point 3<br>• This is the point 4<br>• This is the point 5<br>•<b>This is the point 6</b>


I have used the below code:



<?php 
$short_description = strip_tags( $short_description, 'li' );
$short_description = "<ul><li>" . preg_replace( '/[rn]+/', '</li><li>',
$short_description ) . "</li></ul>";
$short_description = str_replace('<li></li>', '', $short_description );
?>
<?= $short_description ?>


But the whole content is displayed in one <li> tag after implementing the above code.



Now I want to add each bullet points in <li> tags and also I want to remove <br> tag from the content as well. how can I do this?







magento2 product product-attribute






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 10 at 6:56









Chintan KaneriyaChintan Kaneriya

413214




413214







  • 1





    why are you remove <ul> <li> & <br> tag? If you are using editor in admin then you can get save formate value in frontend using function. $block->filterOutputHtml('yout field_name')

    – Chirag Patel
    Jun 10 at 8:28













  • 1





    why are you remove <ul> <li> & <br> tag? If you are using editor in admin then you can get save formate value in frontend using function. $block->filterOutputHtml('yout field_name')

    – Chirag Patel
    Jun 10 at 8:28








1




1





why are you remove <ul> <li> & <br> tag? If you are using editor in admin then you can get save formate value in frontend using function. $block->filterOutputHtml('yout field_name')

– Chirag Patel
Jun 10 at 8:28






why are you remove <ul> <li> & <br> tag? If you are using editor in admin then you can get save formate value in frontend using function. $block->filterOutputHtml('yout field_name')

– Chirag Patel
Jun 10 at 8:28











1 Answer
1






active

oldest

votes


















1














<?php
$short_description= "This is the short description migrated from Magento 1<br><br>short description<br><br>• This is the point 1<br>• This is the point 2<br>• This is the point 3<br>• This is the point 4<br>• This is the point 5<br>•<b>This is the point 6</b>";
$strArray = explode('•',$short_description);
$newShortDescription = strip_tags($strArray[0]);
$newShortDescription .="<ul>";
for($i=1; $i<count($strArray);$i++)
$newShortDescription .="<li>".strip_tags($strArray[$i])."</li>";

$newShortDescription .="</ul>";
?>
<?= $newShortDescription ?>





share|improve this answer








New contributor



Abdul Pathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277766%2fhow-to-remove-br-tags-from-short-description-programmatically-in-magento-2%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    <?php
    $short_description= "This is the short description migrated from Magento 1<br><br>short description<br><br>• This is the point 1<br>• This is the point 2<br>• This is the point 3<br>• This is the point 4<br>• This is the point 5<br>•<b>This is the point 6</b>";
    $strArray = explode('•',$short_description);
    $newShortDescription = strip_tags($strArray[0]);
    $newShortDescription .="<ul>";
    for($i=1; $i<count($strArray);$i++)
    $newShortDescription .="<li>".strip_tags($strArray[$i])."</li>";

    $newShortDescription .="</ul>";
    ?>
    <?= $newShortDescription ?>





    share|improve this answer








    New contributor



    Abdul Pathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1














      <?php
      $short_description= "This is the short description migrated from Magento 1<br><br>short description<br><br>• This is the point 1<br>• This is the point 2<br>• This is the point 3<br>• This is the point 4<br>• This is the point 5<br>•<b>This is the point 6</b>";
      $strArray = explode('•',$short_description);
      $newShortDescription = strip_tags($strArray[0]);
      $newShortDescription .="<ul>";
      for($i=1; $i<count($strArray);$i++)
      $newShortDescription .="<li>".strip_tags($strArray[$i])."</li>";

      $newShortDescription .="</ul>";
      ?>
      <?= $newShortDescription ?>





      share|improve this answer








      New contributor



      Abdul Pathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





















        1












        1








        1







        <?php
        $short_description= "This is the short description migrated from Magento 1<br><br>short description<br><br>• This is the point 1<br>• This is the point 2<br>• This is the point 3<br>• This is the point 4<br>• This is the point 5<br>•<b>This is the point 6</b>";
        $strArray = explode('•',$short_description);
        $newShortDescription = strip_tags($strArray[0]);
        $newShortDescription .="<ul>";
        for($i=1; $i<count($strArray);$i++)
        $newShortDescription .="<li>".strip_tags($strArray[$i])."</li>";

        $newShortDescription .="</ul>";
        ?>
        <?= $newShortDescription ?>





        share|improve this answer








        New contributor



        Abdul Pathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        <?php
        $short_description= "This is the short description migrated from Magento 1<br><br>short description<br><br>• This is the point 1<br>• This is the point 2<br>• This is the point 3<br>• This is the point 4<br>• This is the point 5<br>•<b>This is the point 6</b>";
        $strArray = explode('•',$short_description);
        $newShortDescription = strip_tags($strArray[0]);
        $newShortDescription .="<ul>";
        for($i=1; $i<count($strArray);$i++)
        $newShortDescription .="<li>".strip_tags($strArray[$i])."</li>";

        $newShortDescription .="</ul>";
        ?>
        <?= $newShortDescription ?>






        share|improve this answer








        New contributor



        Abdul Pathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        share|improve this answer



        share|improve this answer






        New contributor



        Abdul Pathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        answered Jun 10 at 8:16









        Abdul PathanAbdul Pathan

        513




        513




        New contributor



        Abdul Pathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




        New contributor




        Abdul Pathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277766%2fhow-to-remove-br-tags-from-short-description-programmatically-in-magento-2%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form