Suppose package:Learning and module: Custom
Module.xml looks like
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Learning_Custom" setup_version="2.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
And then create a layout xml following path -> app/code/Learning/Custom/view/frontend/layout/catalog_product_prices.xml
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd">
<referenceBlock name="render.product.prices">
<arguments>
<argument name="default" xsi:type="array">
<item name="prices" xsi:type="array">
<item name="tier_price" xsi:type="array">
<item name="render_template" xsi:type="string">Learning_Custom::product/price/tier_prices.phtml
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</layout>
Create template inside your module or copy base template file inside your module path should be ->
app/code/Learning/Custom/view/frontend/templates/product/price/tier_prices.phtml
To me, that main difference is that the Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider
uses the Search API.
The following classes are used in this class :
Magento\Framework\Api\FilterBuilder
Magento\Framework\Api\Search\ReportingInterface
Magento\Framework\Api\Search\SearchCriteria
Magento\Framework\Api\Search\SearchCriteriaBuilder
Magento\Framework\Api\Search\SearchResultInterface
Which are used for filtering / ordering / paging:
public function addFilter(\Magento\Framework\Api\Filter $filter)
{
$this->searchCriteriaBuilder->addFilter($filter);
}
public function addOrder($field, $direction)
{
$this->searchCriteriaBuilder->addSortOrder($field, $direction);
}
public function setLimit($offset, $size)
{
$this->searchCriteriaBuilder->setPageSize($size);
$this->searchCriteriaBuilder->setCurrentPage($offset);
}
And also obviously for the search:
public function getData()
{
return $this->searchResultToOutput($this->getSearchResult());
}
protected function searchResultToOutput(SearchResultInterface $searchResult)
{
$arrItems = [];
$arrItems['items'] = [];
foreach ($searchResult->getItems() as $item) {
$itemData = [];
foreach ($item->getCustomAttributes() as $attribute) {
$itemData[$attribute->getAttributeCode()] = $attribute->getValue();
}
$arrItems['items'][] = $itemData;
}
$arrItems['totalRecords'] = $searchResult->getTotalCount();
return $arrItems;
}
public function getSearchResult()
{
return $this->reporting->search($this->getSearchCriteria());
}
What's interesting if that the Magento/Ui/DataProvider/AbstractDataProvider
mentions the Search API but don't use it at all :
public function getSearchCriteria()
{
//TODO: Technical dept, should be implemented as part of SearchAPI support for Catalog Grids
return null;
}
public function getSearchResult()
{
//TODO: Technical dept, should be implemented as part of SearchAPI support for Catalog Grids
return $this->getCollection();
}
Now if you check the history of those files in GitHub here's what you get:
As you can see most of the commits for those two files are linked to the following internal ticket: MAGETWO-39905: UI components compatibility with Search API
Even if it has been done for the Magento/Framework
file it has never been done for the Magento/Ui
file.
Apart from that I don't see any difference between those files. One is working directly on the collection, the other one is using the Search API to generate the results.
Best Answer
So here what I did:
added to my di.xml
And in that Price.php file I override prepareDataSource function like this
I am not sure if this is the best way, but it worked