First you will need to create a module. Create the directory structure. In our case it is going to be app/code/Techflarestudio/Recently
First you will need to register the module:
In our example we have a custom product attribute ingredients and we are going to include this attribute to be loaded in the recently viewed widget list view. So lets start by including the attribute in the widget options:
As you can see the knockout.js template is fetching the description-area nodes and rendering each of them. The nodes are defined in vendor/magento/module-catalog/view/frontend/ui_component/widget_recently_viewed.xml
So the next step is for us to include our attribute as column in the widget definition.
Couple of things to note here.
we define our column name
we define the component that will be used to render the element - Techflarestudio_Recently/js/product/ingredients
we define the template for the column - Techflarestudio_Recently/product/ingredients
Once we have defined this the next step is to create the template and the component:
As you can in the component the value is being fetched from extension_attributes array. So before this can work we need to make sure that the data is loaded in the object. To do this define your extension attribute in xml:
Next pass in the data as an argument for productProviders:
You can see that we have defined a new class for DataProvider. We will use this to pass in the custom attribute data.
In the collect function we are first fetching an array of the existing extension attributes, then checking if our product attribute is set and pass it in to product renderer class. We are using core classes for ProductRender factories and making sure that the data is passed in correctly.
That is it. Make sure to
enable the new widget option
refresh generated content
If everything went well you should be able to see the newly added attribute in the recently viewed widget product description area.