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
Create a new class called Wundercarparts\Makeanoffer\Model\ResourceModel\Offers\Grid\Collection
(place it in the proper file to match the file path).
The class should look like this
<?php
namespace Wundercarparts\Makeanoffer\Model\ResourceModel\Offers\Grid;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
use Magento\Framework\Data\Collection\EntityFactoryInterface;
use Magento\Framework\Event\ManagerInterface as EventManagerInterface;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Api\Search\AggregationInterface;
use Psr\Log\LoggerInterface;
use Wundercarparts\Makeanoffer\Model\ResourceModel\Offers\Collection as OffersCollection;
class Collection extends OffersCollection implements SearchResultInterface
{
/**
* Aggregations
*
* @var AggregationInterface
*/
protected $aggregations;
/**
* constructor
*
* @param EntityFactoryInterface $entityFactory
* @param LoggerInterface $logger
* @param FetchStrategyInterface $fetchStrategy
* @param EventManagerInterface $eventManager
* @param string $mainTable
* @param string $eventPrefix
* @param string $eventObject
* @param string $resourceModel
* @param AdapterInterface $connection
* @param AbstractDb $resource
* @param $model
*/
public function __construct(
EntityFactoryInterface $entityFactory,
LoggerInterface $logger,
FetchStrategyInterface $fetchStrategy,
EventManagerInterface $eventManager,
$mainTable,
$eventPrefix,
$eventObject,
$resourceModel,
AdapterInterface $connection = null,
AbstractDb $resource = null,
$model = 'Magento\Framework\View\Element\UiComponent\DataProvider\Document'
)
{
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
$this->_eventPrefix = $eventPrefix;
$this->_eventObject = $eventObject;
$this->_init($model, $resourceModel);
$this->setMainTable($mainTable);
}
/**
* @return AggregationInterface
*/
public function getAggregations()
{
return $this->aggregations;
}
/**
* @param AggregationInterface $aggregations
* @return $this
*/
public function setAggregations($aggregations)
{
$this->aggregations = $aggregations;
}
/**
* Retrieve all ids for collection
* Backward compatibility with EAV collection
*
* @param int $limit
* @param int $offset
* @return array
*/
public function getAllIds($limit = null, $offset = null)
{
return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
}
/**
* Get search criteria.
*
* @return \Magento\Framework\Api\SearchCriteriaInterface|null
*/
public function getSearchCriteria()
{
return null;
}
/**
* Set search criteria.
*
* @param SearchCriteriaInterface $searchCriteria
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setSearchCriteria(SearchCriteriaInterface $searchCriteria = null)
{
return $this;
}
/**
* Get total count.
*
* @return int
*/
public function getTotalCount()
{
return $this->getSize();
}
/**
* Set total count.
*
* @param int $totalCount
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setTotalCount($totalCount)
{
return $this;
}
/**
* Set items list.
*
* @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setItems(array $items = null)
{
return $this;
}
}
then replace in di.xml
this
<item name="offers_ui_listing_data_source" xsi:type="string">Wundercarparts\Makeanoffer\Model\ResourceModel\Offers\Collection</item>
with this
<item name="offers_ui_listing_data_source" xsi:type="string">Wundercarparts\Makeanoffer\Model\ResourceModel\Offers\Grid\Collection</item>
and this line
<type name="Wundercarparts\Makeanoffer\Model\ResourceModel\Offers\Collection">
with
<type name="Wundercarparts\Makeanoffer\Model\ResourceModel\Offers\Grid\Collection">
For this last line, if your Offers collection expects the parameters mainTable
and others, instead of changing the line, duplicate the section that starts with <type name="Wundercarparts\Makeanoffer\Model\ResourceModel\Offers\Collection">
and then replace the line for the one you just cloned.
Best Answer
You could use a plugin on
Magento/Framework/View/Element/UiComponent/DataProvider/Reporting
and itssearch()
method.Just create
di.xml
in your custom moduleVendor/Module/etc/adminhtml/di.xml
and plugin