08.04.2025・Allgemein
08.04.2025・Allgemein
Magento 2 UIComponent doesn’t show template
Fabian Blechschmidt
Small hint from our daily life as developers: If your default template for your ui component doesn’t show up, it might be, because you overwrote it in your template 😉
So you defined your default template like this:
;define([
// ...
'Magento_Ui/js/form/element/select',
// ...
], function (/* ... */ select, /* ... */) {
'use strict';
let self;
return select.extend({
defaults: {
elementTmpl: 'Customer_Plugin/shipping-option-select-element'
}
// ...
});
});
But then you overwrite it in your layout xml, like view/frontend/layout/checkout_index_index.xml
I tried to cleanup the XML to make it easier readable but not remove the inheritance. Not an easy job.
<?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="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="steps" xsi:type="array">
<item name="children" xsi:type="array">
<item name="shipping-step" xsi:type="array">
<item name="children" xsi:type="array">
<item name="shippingAddress" xsi:type="array">
<item name="children" xsi:type="array">
<item name="shippingAdditional" xsi:type="array">
<item name="children" xsi:type="array">
<item name="shipping-option-wrapper" xsi:type="array">
<item name="children" xsi:type="array">
<item name="shipping-option" xsi:type="array">
<item name="children" xsi:type="array">
<item name="select-date" xsi:type="array">
<item name="component" xsi:type="string"> Customer_Plugin/js/view/shipping-option-select</item>
<item name="config" xsi:type="array">
<!-- HERE THE TEMPLATE IS OVERWRITTEN -->
<item name="elementTmpl" xsi:type="string">ui/form/element/select</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
Other articles from this category
ENABLE_SERVICES: the Shopware env var that quietly installs apps on your shop
I was grepping through vendor/shopware/core for the hidden-gems series and stumbled over Shopware\Core\Service\AllServiceInstaller. Two-argument constructor, twelve lines of logic, @internal. Nothing dramatic — until I read what it actually does: it installs apps on your shop. By itself. In production. Once a day. Unless you told it not to. So this one isn’t going to […]
Shopware 6 Hidden Gems #24: Lightning round — ten small gems that didn’t need their own post
Twenty-three parts into this series, my research folder still has a stack of finds that are real, useful, undocumented — and about two paragraphs big. Instead of stretching each into a full post, here’s the lightning round. One problem, one gem, one file reference. Go. 1. rawUrl() — URLs for mail templates that actually work […]
Shopware 6 Hidden Gems #23: Why your sitemap silently stopped updating (and sitemap:generate –force)
A slow-burn bug report, verbatim from memory: „Google Search Console shows our sitemap is three months old. New categories aren’t in it.“ Three months. No errors in the log worth noticing, the scheduled task looks healthy, and regenerating „worked“ — or seemed to. The cause turned out to be a mechanism that’s completely reasonable and […]