magento2.2 – How to change the behavior of Upsell products in mageto 2

All I want to do is show products for sales according to my phtml file

I've already done this for cross-selling and it's working well I've written a view / layout file



    
         
        
        
        
        
    
    
        
            
                
                    cross selling
                
                
                    
                
            

        
        
    

Now, I want to do the same thing for sales products that I've already done a block for upsells

use Vendo  ModuleName  Help  Data as ModuleNameHelper;

The UpSells class extends  Magento  Catalog  Block  Product  AbstractProduct implements  Magento  Framework  DataObject  IdentityInterface {
protected $ _sliderType = & # 39; up-sells & # 39 ;;
protected $ _itemCollection;
protected $ _storeManager;
protected $ _sliderfactory;
protected $ _helper;
protected $ _customerSession;
protected $ _customerGroupCollection;
public service __construct (
 Magento  Catalog  Block  Product  Background $,
 Magento  Framework  Stdlib  DateTime  DateTime $ date,
 Magento  Client  Model  Session $ customerSession,
 Magento  Client  Template  Group $ clientGroupCollection,
 Magento  Store  Model  StoreManagerInterface $ storeManager,
 Vendo  ModuleName  Template  ResourceTemplate  ProductSliders  CollectionFactory $ slidefactory,
ModuleNameHelper $ helper,
$ data array []
    ) {
$ this -> _ sliderfactory = $ slidefactory;
$ this-> date = $ date;
$ this -> _ customerSession = $ customerSession;
$ this -> _ storeManager = $ storeManager;
$ this -> _ registry = $ context-> getRegistry ();
$ this -> _ customerGroupCollection = $ customerGroupCollection;
$ this -> _ helper = $ helper;
parent :: __ construct (
$ context,
$ data
)
}

protected function _prepareData ()
{
$ date = $ this-> date-> gmtDate ();

$ rules = $ this -> _ sliderfactory-> create ()
-> addStatusFilter ()
-> addTypeFilter ($ this -> _ sliderType)
-> addCurrentSlider ($ date)
-> addStoreFilter ($ this-> getStoreId ())
-> addCostumerGroupFilter ($ this -> _ helper-> getCustomerGroupId ());



$ item = $ rules-> getFirstItem ();
$ product = $ this -> _ registry-> registry (& # 39; current_product & # 39;);
$ this -> _ itemCollection = $ product-> getUpSellProductCollection () -> addAttributeToSelect (
$ this -> _ catalogConfig-> getProductAttributes ()
) -> setPositionOrder () -> addStoreFilter ();
$ this -> _ itemCollection-> load ();
foreach ($ this -> _ itemCollection as $ product) {
$ product-> setDoNotUseCategoryId (true);

}
return $ this;

}

protected function _beforeToHtml ()
{
$ this -> _ prepareData ();
returns parent :: _ beforeToHtml ();
}
public function getItems ()
{

return $ this -> _ itemCollection;
}
public function getStoreId ()
{
return $ this -> _ storeManager-> getStore () -> getId ();
}
public function getItemCount () {
return number ($ this-> getItems ());
}
public service getIdentities ()
{

$ identities = [];
foreach ($ this-> getItems () as $ item) {
$ identities = array_merge ($ identities, $ item-> getIdentities ());
}
returns $ identities
}
}