Magento 2 delete specific product categoriesGet specific categories Name and URL to itShow Specific Categories On Magento Home PageHow to get product ids of specific category and not in other categories in Magento?How to Delete All Products Within a CategoryMagento get product current subcategory of specific parent categoryExcluding products from multiple categories in collectionI can not delete or modify a product categoryMagento 2: Display list of specific categories on Home PageHow to load only the children categories that belong to the current product (magento)Specific view for specific category in Magento 2

My employer faked my resume to acquire projects

Is "cool" appropriate or offensive to use in IMs?

Best material to absorb as much light as possible

Why did the person in charge of a principality not just declare themself king?

Defining the standard model of PA so that a space alien could understand

How can I tell if I'm being too picky as a referee?

How did NASA Langley end up with the first 737?

What is a fully qualified name?

How to deal with a colleague who is being aggressive?

Can a person survive on blood in place of water?

Website returning plaintext password

What could a self-sustaining lunar colony slowly lose that would ultimately prove fatal?

Sankey diagram: not getting the hang of it

I know that there is a preselected candidate for a position to be filled at my department. What should I do?

Is it legal to meet with potential future employers in the UK, whilst visiting from the USA

When the Torah was almost lost and one (or several) Rabbis saved it?

Access to the path 'c:somepath' is denied for MSSQL CLR

Ethical issue - how can I better document what is happening?

How to politely tell someone they did not hit "reply to all" in an email?

Count Even Digits In Number

Efficient Algorithm for the boundary of a set of tiles

Question in discrete mathematics about group permutations

Pirate democracy at its finest

What does $!# mean in Shell scripting?



Magento 2 delete specific product categories


Get specific categories Name and URL to itShow Specific Categories On Magento Home PageHow to get product ids of specific category and not in other categories in Magento?How to Delete All Products Within a CategoryMagento get product current subcategory of specific parent categoryExcluding products from multiple categories in collectionI can not delete or modify a product categoryMagento 2: Display list of specific categories on Home PageHow to load only the children categories that belong to the current product (magento)Specific view for specific category in Magento 2






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








0















how can I delete specific categories for a product in Magento 2.Forex: I have a product with a,b,c categories, I have some conditions if the conditions meet my categories remains same but if those conditions fail I need to remove b, the category only not a,c categories. How can I achieve that?










share|improve this question
























  • Let me know whether you would like to remove programmatically? or manually

    – Nagaraju Kasa
    May 19 at 4:14











  • programmatically @NagarajuKasa

    – Prasanth
    May 19 at 4:31


















0















how can I delete specific categories for a product in Magento 2.Forex: I have a product with a,b,c categories, I have some conditions if the conditions meet my categories remains same but if those conditions fail I need to remove b, the category only not a,c categories. How can I achieve that?










share|improve this question
























  • Let me know whether you would like to remove programmatically? or manually

    – Nagaraju Kasa
    May 19 at 4:14











  • programmatically @NagarajuKasa

    – Prasanth
    May 19 at 4:31














0












0








0








how can I delete specific categories for a product in Magento 2.Forex: I have a product with a,b,c categories, I have some conditions if the conditions meet my categories remains same but if those conditions fail I need to remove b, the category only not a,c categories. How can I achieve that?










share|improve this question
















how can I delete specific categories for a product in Magento 2.Forex: I have a product with a,b,c categories, I have some conditions if the conditions meet my categories remains same but if those conditions fail I need to remove b, the category only not a,c categories. How can I achieve that?







magento2 product category delete






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 20 at 8:31









Muhammad Anas

1,0663525




1,0663525










asked May 19 at 3:46









PrasanthPrasanth

278




278












  • Let me know whether you would like to remove programmatically? or manually

    – Nagaraju Kasa
    May 19 at 4:14











  • programmatically @NagarajuKasa

    – Prasanth
    May 19 at 4:31


















  • Let me know whether you would like to remove programmatically? or manually

    – Nagaraju Kasa
    May 19 at 4:14











  • programmatically @NagarajuKasa

    – Prasanth
    May 19 at 4:31

















Let me know whether you would like to remove programmatically? or manually

– Nagaraju Kasa
May 19 at 4:14





Let me know whether you would like to remove programmatically? or manually

– Nagaraju Kasa
May 19 at 4:14













programmatically @NagarajuKasa

– Prasanth
May 19 at 4:31






programmatically @NagarajuKasa

– Prasanth
May 19 at 4:31











1 Answer
1






active

oldest

votes


















0














You need to build a category collection of the categories you want to delete.



Then it's just the case of something like this:



try 
$category->delete();
echo 'Category Removed';
catch (Exception $e)
echo 'Failed to remove category ' . $category->getId();
echo $e->getMessage();



I cant be more specific without knowing more about the conditions which means delete.






share|improve this answer























    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%2f275146%2fmagento-2-delete-specific-product-categories%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









    0














    You need to build a category collection of the categories you want to delete.



    Then it's just the case of something like this:



    try 
    $category->delete();
    echo 'Category Removed';
    catch (Exception $e)
    echo 'Failed to remove category ' . $category->getId();
    echo $e->getMessage();



    I cant be more specific without knowing more about the conditions which means delete.






    share|improve this answer



























      0














      You need to build a category collection of the categories you want to delete.



      Then it's just the case of something like this:



      try 
      $category->delete();
      echo 'Category Removed';
      catch (Exception $e)
      echo 'Failed to remove category ' . $category->getId();
      echo $e->getMessage();



      I cant be more specific without knowing more about the conditions which means delete.






      share|improve this answer

























        0












        0








        0







        You need to build a category collection of the categories you want to delete.



        Then it's just the case of something like this:



        try 
        $category->delete();
        echo 'Category Removed';
        catch (Exception $e)
        echo 'Failed to remove category ' . $category->getId();
        echo $e->getMessage();



        I cant be more specific without knowing more about the conditions which means delete.






        share|improve this answer













        You need to build a category collection of the categories you want to delete.



        Then it's just the case of something like this:



        try 
        $category->delete();
        echo 'Category Removed';
        catch (Exception $e)
        echo 'Failed to remove category ' . $category->getId();
        echo $e->getMessage();



        I cant be more specific without knowing more about the conditions which means delete.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 19 at 18:09









        Dominic XigenDominic Xigen

        54811




        54811



























            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%2f275146%2fmagento-2-delete-specific-product-categories%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