Questions tagged [xml]
Denotes questions about XML files and XML processing.
1,209
questions
49
votes
3
answers
104k
views
Remove block from layout XML in Magento 2
In Magento 1 I could remove a block added by a layout file by adding this in my layout-block
<remove ="block_id_here" />
How can I do the same for Magento 2?
As a practical exercise, let's say ...
38
votes
4
answers
19k
views
Magento 2 xml validation
For a while Magento 2 had a way to validate (and autocomplete) any xml by using an XSD file.
For examplemodule.xml looked like this:
<?xml version="1.0">
<config xmlns:xsi="http://www.w3.org/...
37
votes
6
answers
43k
views
Debugging layout XML loading
TL;DR: is there a way I can debug the loading of the layout? As I believe one module's layout is conflicting with another.
Related to a previous question I made: How to make a module layout to be ...
36
votes
9
answers
40k
views
Admin config error: Undefined index: id in Iterator.php on line 59
Can someone please explain this error to me?
Exception #0 (Exception): Notice: Undefined index: id in /home/staging/vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php on line 59
...
34
votes
3
answers
35k
views
Conditionally show/hide blocks in layout XML
How to conditionally add a block (depending on the configuration in the admin panel) in Magento's layout XML?
We can check if config is true on actions. In the example below, if sample/config/...
30
votes
8
answers
71k
views
Magento 2: Call a static block using xml
How i include a static block in a page using xml. For example i created a static block with identifier promo. In magento 1 we include a static block using below code
<block type="cms/block" ...
23
votes
2
answers
21k
views
What are all the allowed `xsi:type` values in the xml's from Magento2
In Magento 2 (almost) all arguments listed in xml files have an attribute xsi:type that determine how the value of the argument is iterpreted.
For example, in di.xml file of the backend module there ...
23
votes
1
answer
4k
views
How can I have a custom XML file in modules merged as one in Magento 2? (MageStackDay mystery question 2)
MageStackDay bonus question for 500pts Bounty AND a the possibility of winning a free Z-Ray license for a year. More info can be found >> here <<
The questions are provided/inspired by Magento ...
22
votes
4
answers
4k
views
Extending the complexType named "imageType" with a custom image type
The goal of a module I'm currently developing is to add a custom image type called "opengraph_image". I added a new EAV attribute though my InstallData.php script which works fine. When I now login ...
21
votes
2
answers
23k
views
Magento 2 - ifconfig in layout xml
I'm working with magento 2.
I can use ifconfig attribute in the block code, and it works well.
<block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="...
17
votes
2
answers
12k
views
Setting up an Admin Route in Magento 2
Looking at the core Magento 2 code, there seems to be two ways of setting up an admin route.
The first
#File: vendor/magento/module-media-storage/etc/adminhtml/routes.xml
<config xmlns:xsi="...
15
votes
6
answers
34k
views
Find out the "name" for a referenceBlock in Magento 2
I want to remove some blocks from my page. Say for example that I want to remove the container for the logo.
Then I create /app/design/frontend/MYVENDORNAME/MYTHEMENAME/Magento_Theme/layout/default....
15
votes
6
answers
23k
views
How can i hide Discount Code form checkout payment page in Magento 2?
I tried to hide the Discount Code field from checkout payment page, but i can't find anything in xml files.
For cart page, i found this field in checkout_cart_index.xml, and i was able to hide like ...
15
votes
2
answers
20k
views
How to get data from config.xml of a module
In the module A I need to get some data from file config.xml of modules B and C.
Are there any methods or classes dedicated for this?
Especialy I need to get XML structure and values of node <...
15
votes
2
answers
17k
views
What is <update handle="customer_account"/>?
What is the Handler?
Can someone explain the below code?
<update handle="customer_account"/>
or same code like above for example :
<update handle="default"/>
and how it worked !?
14
votes
4
answers
40k
views
Add new tab on product detail page Magento 2 [duplicate]
I want to add an extra tab on product detail page just like review tab, It will look like a product question tab. How can I do this?
My block file:
namespace Example\ProductQuestion\Block;
use ...
14
votes
1
answer
3k
views
Improving error messages for XML compilation errors
Magento is fairly protective (as it should be) regarding the display of errors. When developer mode is enabled (as it should be during development), the application allows runtime error feedback to ...
13
votes
3
answers
16k
views
Magento2: Default to sort by price descending not ascending
Ok so I have my categories sorting by price. Magento 2 defaults this to price ascending. But I would prefer it to be by price descending.
Pretty sure I can do this by customising ...
12
votes
1
answer
20k
views
Magento 2: How to add text within container via XML
I am attempting to render a single line of text prior to a Link list in the footer. Creating a template file to do this seems to be a waste of resources for this task. As I understood it, I could ...
12
votes
1
answer
25k
views
Using the default Magento 2 template block class in a Module
I'm tying to add a simple block to the header using the default template class with the following code
<block class="Magento\Framework\View\Element\Template" name="test.trigger" template="trigger....
12
votes
3
answers
30k
views
Magento new custom block module
I'm using Magento version 1.8.1.0.
I'm trying to create a new custom block module, which I'll use for creating a new home page.
Namespace: Crusader
Module: CLHomePage
Block Type: crusade home
Class:...
12
votes
1
answer
3k
views
What's your way of debugging xml related exceptions?
I'm coding with Magento 2 in gvim and I am new to Magento 2.
There were many times i struggled to debug xml-related errors, well, each time with only luck.
But situations like this makes me really ...
11
votes
1
answer
9k
views
Magento 2 checkout index xml is not overriding
I am creating Magento 2 theme using the blank theme as the base. Now the problem is Magento 2 blank theme removing the top header, search bar, mini cart on http://www.yourdomain/checkout page
vendor\...
11
votes
1
answer
2k
views
Magento 2 - block name vs as name
I've been doing some work in Magento 2 and have been overwriting some modules i've installed ( on the frontend ).
However today i've just come across something that I've not encountered before. The ...
10
votes
4
answers
24k
views
Magento 2 - How to add custom css files into the head?
In Magento 1.x, I can add the CSS files into the head using the helper
like below code.
<reference name="head">
<action method="addCss"><stylesheet helper="module/helperclass/...
10
votes
1
answer
20k
views
How to remove reference container block from layout?
I want to remove the block from referenceContainer. I have gone through the below link:
Remove block from layout in Magento 2
And tried to remove as per the above answer:
<referenceBlock name="...
10
votes
2
answers
466
views
Override header Content and adding block
I have extended LUMA theme and want to customize header.
I want to add static block before logo and want to move logo to center of page which is on left side.
Final result will be
[1] static ...
10
votes
1
answer
10k
views
How to prevent module rewrite class conflict in Magento
I have a class rewrite problem in Magento Onepage Checkout as I have a custom module in the local code pool and a third party extension in the community code pool both extending the same class...
I'...
10
votes
3
answers
6k
views
XML Parsing Errors
I believe I have a syntax error or something? I'm confident it's either something to do with xml or syntax. Everything appears to be in order when i look into the file. This error is dealing with the ...
10
votes
1
answer
5k
views
Updating ui_bookmark Table When Adding Columns via ui_component XML
In Magento 2, the ui_component based grids allow you to reorder columns and Magento will remember your settings the next time you log in. This is accomplished by Magento saving data in the ...
9
votes
4
answers
7k
views
Magento 2: How to use the Layout Handle customer_logged_in?
Does Magento 2 have such handle as customer_logged_in? If yes how can I use it?
I tried to create
../view/frontend/layout/customer_logged_in.xml
and added there <referenceBlock name="content" ...
9
votes
3
answers
28k
views
Remove Specific Top Links
I need to edit the Magento Top Links in a specific way and only need to show three links in below order
Login Register Cart
This would result in following
Remove only Checkout Link and not Cart ...
9
votes
1
answer
4k
views
Magento 2 Add text in checkout page via XML
I'm trying to add custom text in checkout page via XML. I have my custom checkout_index_index.xml file with this inside:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="...
9
votes
2
answers
6k
views
Magento 2 - How to reset XML block arguments such as CSS
I'm wondering how to unset CSS that has been set through the XML, for example:
<block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::...
9
votes
1
answer
3k
views
Magento 2.1: how to remove argument and/or argument item from block?
I need to remove "from - to" price in bundle product page.
So the question is how to remove item from argument?
Block is created in
magento2/vendor/magento/module-bundle/view/base/layout/...
9
votes
1
answer
2k
views
Magento 2 - Move the afterMethods item (Discount and Gift Card Code) to the Order Summary sidebar
I would like to move the afterMethods xml item which contains the Discount Code and Gift Card code under the billing-step in the module-checkout/view/frontend/web/checkout_index_index.xml so that it ...
8
votes
7
answers
12k
views
Magento2 How to move toolbar
Anyone have any idea about How to move toolbar before left and right sidebar in magento2 using XML?
Currently it is showing in Right side-bar.
8
votes
5
answers
36k
views
Magento 2 - Add a new container
I'm trying to add a new container according to the Magento 2 documentation, but it isn't working. Here is what I'm trying:
<container name="some.container" as="someContainer" label="Some ...
8
votes
3
answers
9k
views
Magento 2 | Add NOINDEX, NOFOLLOW to CMS page using Layout Update XML
How do I add the following robots META tag to a CMS page in Magento 2 using the Layout Update XML field?
<meta name="robots" content="noindex,nofollow"/>
I have tried the suggestions in the ...
8
votes
2
answers
2k
views
Magento 2: What's the `ui_component` folder for?
In addition to containing familiar folders like layout, and templates, a Magento 2 module's view folder also contains a ui_component sub-folder.
view/adminhtml/ui_component
What is this folder for? ...
8
votes
1
answer
4k
views
Remove Title suffix from home page only
I have give Title suffix in magento system configuration like | Magento site. So this 'll add Title to every page in the store as suffix.
But when i goto home page title shows like Home | Magento ...
8
votes
1
answer
2k
views
Magento 2 custom xml schema validation
This is a follow up of Magento 2 xml validation:
I understood how to map xsi:noNamespaceSchemaLocation in my IDE so I will get real time validation of my xmls.
But what if I have to create my own ...
8
votes
3
answers
3k
views
Magento Google sitemap Generation
I have generate google sitemap through Magento adminpanel.
I have set Product URL Suffix(html) and Category URL Suffix(html) in the configuration.
This suffix are not showing in sitemap.xml.
It ...
8
votes
5
answers
1k
views
move module's external .js file code to template [phtml] file
We have a custom module with below code
app/design/frontend/rwd/Theme1/layout/aitcg.xml
<action method="addJs"><script>aitoc/aitcg/Aitcg/View/Abstract.js</script></action>
...
8
votes
2
answers
8k
views
Generate xml file programmatically
I need to generate an .xml file from my extension. Inside Namespace/Module/view/adminhtml/ui_component/ folder,
I need to do this pro-grammatically because the .xml file will be generated based on ...
8
votes
0
answers
1k
views
How to extend core UI Component in Magento 2
I've tried to bring the Sales -> Shipments grid into my extension. It works fine when I use this in my layout file .xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3....
7
votes
4
answers
17k
views
Magento 2 - How to move the product price block before addtocart button?
I am using custom theme and trying to move the "product.info.price" block before the addtocart button.
I have tried, direct into addtocart.phtml file but not working.
<?php echo $this->...
7
votes
2
answers
20k
views
Removing Welcome message from magento 2 - just xml
I've started to work on Magento 2 and get my head around it, I'm really familiar with Magento 1 and removing the welcome message was no big deal.
However all I've found the location of the welcome ...
7
votes
1
answer
3k
views
How do you use the API to add products to a bundle?
I'm developing a system that integrates an existing Django application with a Magento store. I've managed, using this library, to create bundle-type products, along with attributes and categories as ...
7
votes
2
answers
6k
views
Layout xml naming convention format magento 2
Can u confirm if the layout xml file im using is of the proper format
routerfrontname_controllerfrontname_controlleraction.xml
Eg:
routes.xml
<router id="standard">
<route id="...