skip to Main Content

I am learning Magento 2 and hence, I saw one major issue with Magento 2 is the theme optimization. As we all are facing same issue that Magento 2 theme is not optimized so may I know what steps? what precautions? or what changes and optimization can be done in templating level because rest of the things like default configuration I can do but I don’t know the optimization for templating..

2

Answers


  1. What type of optimization are you required? Like layout changes, theme color changes, or some new element want to add home page or category page. banner adding etc.

    You can add image banners, product slider or text etc. from Magento admin Content >> Elements >> Pages page.

    Regarding, color css changes you can go app/design/frontend/yourthemepackage/yourtheme/web/css/styles.css or you can add your custom theme also. if you add new custom css you need to define this css in default app/design/frontend/yourthemepackage/yourtheme/Magento_Theme/layout/default.xml

    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
     <head>
        <!------- under head  ------------>
        <css src="css/Custome.css" />
        <!------- under head  ------------>
     </head>
      
    </page>
    

    if you want to learn more about the magento you can follow up my youtube channel and if you have any issue you can also comment me. I will defiantly help you to learn.

    blog: https://php-scripts-form.blogspot.com/
    youtube channel : https://www.youtube.com/channel/UChb7DM9SspzrUVh4hnWL50A

    Login or Signup to reply.
  2. As per our discussion i got what you want to do.

    you can remove elements and block, containers via xml and also via phtml.

    for remove block you can add

    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    <referenceBlock name="block.name" remove="true" />
    </body>
    </page>
    

    And if you want to remove from phtml you can copy template from core theme. vendor/magento/{whichlementyouwanttoreoveendterspecifcmodule}/view/frontend/yourtemeplate.phtml

    and copy it in your theme

    app/design/frontend/yourthemepackage/yourtheme/yourelement/template/yourtemaplate.phtml

    and you can manipulate your content. below i give you a real example for product detail page.

    copy core file into your theme :
    vendor/magento/module-catalog/view/frontend/templates/product/view/gallery.phtml
    
    your theme path
    app/design/frontend/Magento/luma/Magento_Catalog/templates/product/view/gallery.phtml
    
    And after that remove content from gallery.phtml you can see in product detail page gallery will be reomve. 
    

    if you understand then good if not so you can connect with me real-time on Skype i will show you via screen share.

    Please subscribe my youtube channel. https://www.youtube.com/channel/UChb7DM9SspzrUVh4hnWL50A

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search