How to configure Magento 2 Theme/Design via the Command-Line?












1















I'm doing some server configuration related tasks and was looking for a way to configure the theme of a store/website via the command-line.



I'm setting up a store with a custom theme (e.g. "Vendor/code") and I would like to activate it without entering the adminhtml website but set the theme on the command-line / in the shell / bash script.










share|improve this question

























  • Created custom theme, you want to set for store ?

    – Suresh Chikani
    Oct 24 '16 at 10:19











  • @SHPatel: Yes, created a custom theme and then doing semi/automated deployments. Edited the question to reflect this better and have a bit more context.

    – hakre
    Oct 24 '16 at 11:07
















1















I'm doing some server configuration related tasks and was looking for a way to configure the theme of a store/website via the command-line.



I'm setting up a store with a custom theme (e.g. "Vendor/code") and I would like to activate it without entering the adminhtml website but set the theme on the command-line / in the shell / bash script.










share|improve this question

























  • Created custom theme, you want to set for store ?

    – Suresh Chikani
    Oct 24 '16 at 10:19











  • @SHPatel: Yes, created a custom theme and then doing semi/automated deployments. Edited the question to reflect this better and have a bit more context.

    – hakre
    Oct 24 '16 at 11:07














1












1








1








I'm doing some server configuration related tasks and was looking for a way to configure the theme of a store/website via the command-line.



I'm setting up a store with a custom theme (e.g. "Vendor/code") and I would like to activate it without entering the adminhtml website but set the theme on the command-line / in the shell / bash script.










share|improve this question
















I'm doing some server configuration related tasks and was looking for a way to configure the theme of a store/website via the command-line.



I'm setting up a store with a custom theme (e.g. "Vendor/code") and I would like to activate it without entering the adminhtml website but set the theme on the command-line / in the shell / bash script.







magento2 theme configuration cli linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 mins ago









Himanshu

930521




930521










asked Oct 24 '16 at 10:18









hakrehakre

1,40221435




1,40221435













  • Created custom theme, you want to set for store ?

    – Suresh Chikani
    Oct 24 '16 at 10:19











  • @SHPatel: Yes, created a custom theme and then doing semi/automated deployments. Edited the question to reflect this better and have a bit more context.

    – hakre
    Oct 24 '16 at 11:07



















  • Created custom theme, you want to set for store ?

    – Suresh Chikani
    Oct 24 '16 at 10:19











  • @SHPatel: Yes, created a custom theme and then doing semi/automated deployments. Edited the question to reflect this better and have a bit more context.

    – hakre
    Oct 24 '16 at 11:07

















Created custom theme, you want to set for store ?

– Suresh Chikani
Oct 24 '16 at 10:19





Created custom theme, you want to set for store ?

– Suresh Chikani
Oct 24 '16 at 10:19













@SHPatel: Yes, created a custom theme and then doing semi/automated deployments. Edited the question to reflect this better and have a bit more context.

– hakre
Oct 24 '16 at 11:07





@SHPatel: Yes, created a custom theme and then doing semi/automated deployments. Edited the question to reflect this better and have a bit more context.

– hakre
Oct 24 '16 at 11:07










2 Answers
2






active

oldest

votes


















2














I was not able to find a direct Magento CLI command so far, I could work around with a Bash and Magerun:



$ THEME_ID="$(n98-magerun2.phar dev:theme:list --format=csv 
| grep 'Vendor/code' | cut -d, -f1)"
; test -n "${THEME_ID}"
&& n98-magerun2.phar config:set design/theme/theme_id "${THEME_ID}"


This sequence sets the configuration path for the theme_id to the one of the named theme (by it's code, which is "Vendor/code" in the example).



In case the operation fails, this has a non-zero status.






share|improve this answer































    -1














    The only command related to themes out of the box in Magento 2 is php bin/magento theme:uninstall which can be used to uninstall a theme.



    I suggest you create your own command following the example in the sample module so you can develop your custom code to configure themes properly.



    Also I suggest you read the official documentation to create your own command: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/cli-cmds/cli-howto.html






    share|improve this answer
























    • I would consider creating a CLI command off-topic in the light of an answer (yes it's possible, and programming it yourself is always the solution of everything, and so its kinda superfluous for an answer here) - and consider that more a comment. But thanks for your efforts and your commentary.

      – hakre
      Oct 24 '16 at 10:25











    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%2f142315%2fhow-to-configure-magento-2-theme-design-via-the-command-line%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    I was not able to find a direct Magento CLI command so far, I could work around with a Bash and Magerun:



    $ THEME_ID="$(n98-magerun2.phar dev:theme:list --format=csv 
    | grep 'Vendor/code' | cut -d, -f1)"
    ; test -n "${THEME_ID}"
    && n98-magerun2.phar config:set design/theme/theme_id "${THEME_ID}"


    This sequence sets the configuration path for the theme_id to the one of the named theme (by it's code, which is "Vendor/code" in the example).



    In case the operation fails, this has a non-zero status.






    share|improve this answer




























      2














      I was not able to find a direct Magento CLI command so far, I could work around with a Bash and Magerun:



      $ THEME_ID="$(n98-magerun2.phar dev:theme:list --format=csv 
      | grep 'Vendor/code' | cut -d, -f1)"
      ; test -n "${THEME_ID}"
      && n98-magerun2.phar config:set design/theme/theme_id "${THEME_ID}"


      This sequence sets the configuration path for the theme_id to the one of the named theme (by it's code, which is "Vendor/code" in the example).



      In case the operation fails, this has a non-zero status.






      share|improve this answer


























        2












        2








        2







        I was not able to find a direct Magento CLI command so far, I could work around with a Bash and Magerun:



        $ THEME_ID="$(n98-magerun2.phar dev:theme:list --format=csv 
        | grep 'Vendor/code' | cut -d, -f1)"
        ; test -n "${THEME_ID}"
        && n98-magerun2.phar config:set design/theme/theme_id "${THEME_ID}"


        This sequence sets the configuration path for the theme_id to the one of the named theme (by it's code, which is "Vendor/code" in the example).



        In case the operation fails, this has a non-zero status.






        share|improve this answer













        I was not able to find a direct Magento CLI command so far, I could work around with a Bash and Magerun:



        $ THEME_ID="$(n98-magerun2.phar dev:theme:list --format=csv 
        | grep 'Vendor/code' | cut -d, -f1)"
        ; test -n "${THEME_ID}"
        && n98-magerun2.phar config:set design/theme/theme_id "${THEME_ID}"


        This sequence sets the configuration path for the theme_id to the one of the named theme (by it's code, which is "Vendor/code" in the example).



        In case the operation fails, this has a non-zero status.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 24 '16 at 10:22









        hakrehakre

        1,40221435




        1,40221435

























            -1














            The only command related to themes out of the box in Magento 2 is php bin/magento theme:uninstall which can be used to uninstall a theme.



            I suggest you create your own command following the example in the sample module so you can develop your custom code to configure themes properly.



            Also I suggest you read the official documentation to create your own command: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/cli-cmds/cli-howto.html






            share|improve this answer
























            • I would consider creating a CLI command off-topic in the light of an answer (yes it's possible, and programming it yourself is always the solution of everything, and so its kinda superfluous for an answer here) - and consider that more a comment. But thanks for your efforts and your commentary.

              – hakre
              Oct 24 '16 at 10:25
















            -1














            The only command related to themes out of the box in Magento 2 is php bin/magento theme:uninstall which can be used to uninstall a theme.



            I suggest you create your own command following the example in the sample module so you can develop your custom code to configure themes properly.



            Also I suggest you read the official documentation to create your own command: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/cli-cmds/cli-howto.html






            share|improve this answer
























            • I would consider creating a CLI command off-topic in the light of an answer (yes it's possible, and programming it yourself is always the solution of everything, and so its kinda superfluous for an answer here) - and consider that more a comment. But thanks for your efforts and your commentary.

              – hakre
              Oct 24 '16 at 10:25














            -1












            -1








            -1







            The only command related to themes out of the box in Magento 2 is php bin/magento theme:uninstall which can be used to uninstall a theme.



            I suggest you create your own command following the example in the sample module so you can develop your custom code to configure themes properly.



            Also I suggest you read the official documentation to create your own command: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/cli-cmds/cli-howto.html






            share|improve this answer













            The only command related to themes out of the box in Magento 2 is php bin/magento theme:uninstall which can be used to uninstall a theme.



            I suggest you create your own command following the example in the sample module so you can develop your custom code to configure themes properly.



            Also I suggest you read the official documentation to create your own command: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/cli-cmds/cli-howto.html







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 24 '16 at 10:22









            Raphael at Digital PianismRaphael at Digital Pianism

            54k21118273




            54k21118273













            • I would consider creating a CLI command off-topic in the light of an answer (yes it's possible, and programming it yourself is always the solution of everything, and so its kinda superfluous for an answer here) - and consider that more a comment. But thanks for your efforts and your commentary.

              – hakre
              Oct 24 '16 at 10:25



















            • I would consider creating a CLI command off-topic in the light of an answer (yes it's possible, and programming it yourself is always the solution of everything, and so its kinda superfluous for an answer here) - and consider that more a comment. But thanks for your efforts and your commentary.

              – hakre
              Oct 24 '16 at 10:25

















            I would consider creating a CLI command off-topic in the light of an answer (yes it's possible, and programming it yourself is always the solution of everything, and so its kinda superfluous for an answer here) - and consider that more a comment. But thanks for your efforts and your commentary.

            – hakre
            Oct 24 '16 at 10:25





            I would consider creating a CLI command off-topic in the light of an answer (yes it's possible, and programming it yourself is always the solution of everything, and so its kinda superfluous for an answer here) - and consider that more a comment. But thanks for your efforts and your commentary.

            – hakre
            Oct 24 '16 at 10:25


















            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%2f142315%2fhow-to-configure-magento-2-theme-design-via-the-command-line%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

            What other Star Trek series did the main TNG cast show up in?

            Berlina muro

            Berlina aerponto