L
L
lagudal2020-10-07 15:38:19
Magento
lagudal, 2020-10-07 15:38:19

How to overwrite ui component of magento catalog module?

It was necessary to make changes to the product template from recently viewed - "last viewed".
I was surprised to understand that the implementation here differs from the usual layout - templates - rendering here is implemented in the ui component.
The xml file to be edited is vendor/magento/module-catalog/view/frontend/ui_component/widget_recently_viewed.xml.

Here is the part of the xml code that needs to be changed
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
// вот сюда хочу внести изменения
        <column name="addtocart-button" component="Magento_Catalog/js/product/addtocart-button" displayArea="action-primary-area">
            <settings>
                <label translate="true">Add To Cart</label>
                <bodyTmpl>Magento_Catalog/product/addtocart-button</bodyTmpl>
            </settings>
        </column>
        <column name="addtocompare-button" component="Magento_Catalog/js/product/addtocompare-button" sortOrder="2" displayArea="action-secondary-area">
            <settings>
                <label translate="true">Add To Compare</label>
                <bodyTmpl>Magento_Catalog/product/addtocompare-button</bodyTmpl>
            </settings>
        </column>
        <column name="learn-more" component="Magento_Catalog/js/product/learn-more" displayArea="description-area">
            <settings>
                <label translate="true">Learn more</label>
                <bodyTmpl>Magento_Catalog/product/link</bodyTmpl>
            </settings>
        </column>
    </columns>
</listing>

Since editing this file directly is impractical, I copy this xml to my theme directory -
/vendor/myTheme/Magento_Catalog/ui_component/widget_recently_viewed.xml
And everything seems to be correct, but the price is not immediately displayed. If I use the default, then the price is displayed normally.
In general, it is necessary to add only one line between the price and the "add to cart" button, more precisely, a link, by clicking on which a modal window opens. All this is implemented in the product template, but how to add it correctly as a component, and even rewrite the default xml?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question