While this code working in Joomla 3x with PHP 8, it is not working in Joomla 4x -- it is showing error class to undefined method
public function display($tpl = null)
{
$app = Factory::getApplication();
$db = Factory::getDBO();
$user = Factory::getUser();
$this->state = $this->get('State');
$this->item = $this->get('Data');
$this->params = $app->getParams('com_car');
$model = $this->getModel();
$modelcar = $this->getModel( 'product' );
$id = $app->input->get('id','','default','int');
$vid = $app->input->get('vid','','default','int');
$prodDet = $modelcar->loadProduct($id,$vid);
$this->assignRef('prodDet' , $prodDet);
$CatName = $modelcar->getCatName($id);
$this->assignRef('CatName' , $CatName);
Here this line is the problem area:
$prodDet = $modelcar->loadProduct($id,$vid);
$this->assignRef('prodDet' , $prodDet);
$CatName = $modelcar->getCatName($id);
$this->assignRef('CatName' , $CatName);