Hot answers tagged

169

[EDIT 3 Oct 2018] Update for links to devdocs: 2.0 - https://devdocs.magento.com/guides/v2.0/ui-components/ui-listing-grid.html and https://devdocs.magento.com/guides/v2.0/ui-components/ui-secondary.html 2.1 - https://devdocs.magento.com/guides/v2.1/ui_comp_guide/components/ui-listing-grid.html 2.2 - https://devdocs.magento.com/guides/v2.2/ui_comp_guide/...


88

What are exactly those sections ? A section is a piece of customer data grouped together. Each section is represented by key that is used to access and manage data and data itself. Magento loads sections by AJAX request to /customer/section/load/ and caches loaded data in the browser local storage under the key mage-cache-storage. Magento tracks when some ...


72

In more recent versions of Magento2, the remove method is now: <referenceBlock name="block_name" remove="true"/> Example: <?xml version="1.0"?> <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/...


65

Of course, it is possible: <referenceBlock name="copyright"> <action method="setTemplate"> <argument name="template" xsi:type="string">Dfr_Backend::page/copyright.phtml</argument> </action> </referenceBlock>


58

I think you messed up some closing / opening tags and amount of them this code works: <referenceBlock name="checkout.cart.shipping"> <arguments> <argument name="jsLayout" xsi:type="array"> <item name="components" xsi:type="array"> <item name="block-summary" xsi:type="array"> ...


55

You can log the compiled layout XML directives which are used to generate blocks. Create an observer on controller_action_layout_generate_blocks_before, and in the observer method log the update XML from the transported layout object: public function logCompiledLayout($o) { $req = Mage::app()->getRequest(); $info = sprintf( "\nRequest: %...


48

Full list of customer account XML removal for M2. It will be helpful for other developers who try to remove other links. I think it's a good idea to keep it has extra information for other developers. <?xml version="1.0"?> <!-- /** * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:...


45

Action node is deprecated, but you can use block arguments <referenceBlock name="block_to_change"> <arguments> <argument name="template" xsi:type="string">[Vendor]_[Module]::/path/to/template.phtml</argument> </arguments> </referenceBlock>


43

Check your DB. There is a table called theme that stores a reference to all the themes that have ever been installed in your store. If the type of the theme is set to 1, that means Magento sees the theme are virtual (what ever that means) and will no longer load your xml files. If that is the case, just change it to 0. I don't know the why of this issue, but ...


39

basically containers are the equivalent of the core/text_list blocks in magento 1. "philosophically" they work the same, the only difference is that containers are predefined blocks that only support other child blocks. Some examples are content, after.body.start, header-wrapper. You can see all defined containers for example in the Magento/Theme/view/base/...


39

Add new layout handle to one of places: If creating new module: VendorName/ModuleName/view/frontend/layout/customer_account.xml If creating new theme, 2 similar layout handles should be created to declare removal of each block separately: app/design/frontend/VendorName/themeName/Magento_Wishlist/layout/customer_account.xml (and similar layout for billing ...


37

There is a new move node in the layout XML that we have access to in M2. This node sets the declared block or container element as a child of another element in the specified order. Example: <move element="name.of.an.element" destination="name.of.destination.element" as="new_alias" after="name.of.element.after" before="name.of.element.before"/> In ...


33

In Magento 2 to apply the new tab in product detail page is very easy task. Use below steps and check it out. It will display the tab in your theme. Create file catalog_product_view.xml in the app/design/frontend/{vender name}/{theme name}/Magento_Catalog/layout In the file write the below code: <?xml version="1.0"?> <page layout="1column" xmlns:...


31

To understand the difference between <arguments> and <action> you must understand how the constructors of Magento 2 objects work. If you override a constructor in Magento, you'll always get a $data-parameter which is an array. This is the data as provided in the XML files and translated to the internal $_data-array of \Magento\Framework\...


28

I would like to add my option as opposed to benmarks' answer. My approach is to use the append action: <block type="core/template" name="my_block" template="my/block.phtml" /> <reference name="head"> <action method="append" ifconfig="myblock/general/enabled"><block>my_block</block></action> </...


28

These relate to the position in which the product's custom options are displayed. See app/code/core/Mage/Catalog/etc/config.xml: <design> <options_container> <option1 translate="label"> <value>container1</value> <label>Product Info Column</label> </option1> ...


27

getBlockHtml('block_name_here') get's you the html of the block with name block_name_here if it finds it in the layout...anywhere. getChildHtml('block_name_here') get's you the html of the block with name block_name_here only if that block is a child of the current block. Here is an example. Consider the next layout section <block type="core/template" ...


27

If you need to change every category page to 2column-left, then use this layout update File : app/design/frontend/<package>/<theme>/layout/local.xml <layout> <catalog_category_layered> <reference name="root"> <action method="setTemplate"> <template>page/2columns-left.phtml</template&...


27

not 100% sure about this, but I think you can add code to the head using this: <body> <referenceBlock name="head.additional"> <block class="Pulsestorm\Test\Block\Head" name="pulsestorm.head" as="pulsestorm.head" template="pulsestorm/head.phtml"/> </referenceBlock> </body> I know, it sounds strange to add code ...


26

1 ) Add below code in your extended default.xml file to remove Account tabs links. app/design/frontend/vendorname/themename/Magento_Theme/layout/default.xml Here is list of code to remove account tabs as needed. Will helpful to you and other users as well <!-- Address link --> <referenceBlock name="customer-account-navigation-...


25

Finally I got the solution. You can call static block using following way. <referenceContainer name="footer"> <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" after="footer_links" template="switch/stores.phtml"/> <block class="Magento\Cms\Block\Block" name="test"> <arguments> ...


25

for me after adding referenceBlock then worked. Tested <referenceBlock name="top.links"> <referenceBlock name="register-link" remove="true" /> <!--for Create Account Link--> <referenceBlock name="authorization-link" remove="true" /> <!--for Sign In Link --> <referenceBlock name="...


25

have you tried in cms_index_index.xml something like this? <?xml version="1.0"?> <!-- /** * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/...


23

You can retrieve all the layout handles in your controller by doing this: var_dump($this->getLayout()->getUpdate()->getHandles()); Or anywhere (as long as the layout has been initialized) using this: var_dump(Mage::app()->getLayout()->getUpdate()->getHandles()); Perhaps that will help you debug. EDIT Have you set your config.xml to ...


23

This may sound stupid, but I'll ask anyway: did you double-check that the main template file (e.g. 1column.phtml) of your theme does echo $this->getChildHtml('before_body_end')? On a vanilla CE 1.7.0.2, this code <?xml version="1.0"?> <layout version="0.1.0"> <default> <reference name="after_body_start"> &...


23

The "white page" error comes because Magento\Framework\View\Element\Template have not a getProduct() method. So I think that the "cleanest" way to do it is create a custom module with a custom block, layout and template (don't worry this just take a few minutes and you have done some parts) Module Files: (I will skip /etc/module.xml and registration.php ...


23

We can read the document here: http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_customize.html. In your case: we can apply this guide: <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> &...


23

Copy the file: vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml to app/design/frontend/{{Vender_Namespace}}/{{Theme_Name}}/Magento_Catalog/layout/catalog_category_view.xml into your theme and add this to the file: <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-...


22

It depends on your request. For instance, lastly, I had been removed all Prototype scripts from the Homepage of the Magento store which I didn't face any problem. But as I said, it depends on your theme, extensions etc. To moving the script : Find the following line in page.xml of your theme <block type="core/text_list" name="before_body_end" as="...


22

My approach is a little different but probably more future proof, in case of adding new tabs later on and changing the priority/order of these tabs. I passed an argument for each tab via XML File in my themes XML file ... <arguments> <argument name="priority" xsi:type="string">REPLACE WITH SOME NUMBER</argument> </arguments> ... ...


Only top voted, non community-wiki answers of a minimum length are eligible