Magento 2, how to know the names of the blocks?

1

I'm looking for a way to know the names of the blocks to be able to modify them, if I want to change the location to the blocks.

I'm working on Magento_catalog .

Those who have good knowledge of Magento 2, how to completely change the design of the theme but using Magento's resources, would help me a lot, thank you.

    
asked by Sebastian Suarez 18.09.2016 в 20:16
source

1 answer

0

To know the names of the blocks there is no simple form included in Magento, you should install an extension like this:

link

One way I use to determine the names of the blocks without using this extension is:

  • Show the paths of the templates of each block, activating:
      

    Stores > Configuration > Advanced > Developer > Debug > Enable Template Path Hints for Storefront > Yes

  • After finding the name of the template of the block I am looking for, I search the path of said template among all the Magento files, by means of the command line or in your IDE (PhpStorm, Sublime Text, etc. .).

    Example: product / view / attributes.phtml

  • Then among those results I should see some (or at least one) that comes from an XML, which defines the Magento layouts. Possibly in the example that I give, the catalog_product_view.xml result appears in the base module Magento_Catalog.

  • Next I look at the XML file where the line where this block is defined and therefore I will find its name or name, in the following line:

    <block class="Magento\Catalog\Block\Product\View\Attributes" 
      name="product.attributes" as="additional" 
      template="product/view/attributes.phtml" group="detailed_info">
    
  • The name of the block in this case is product.attributes .

    Although you should keep in mind that when you move an element, in your theme or in another extension with the <move> tag you can redefine the alias of it:

    <move element="product.attributes" as="nuevo.alias" destination="product.media"/>
    

    You can check the official documentation of Magento 2 regarding the common layout tasks in the following link:

    link

        
    answered by 18.09.2016 / 20:32
    source