Hello,
For optimisation, the best is to perform a loop in order to collect all vendors.
$vendor_ids = [1 => 1];
foreach($cart->products as $product) {
$vendor_id = (int)$product->product_vendor_id;
if($vendor_id > 0)
$vendor_ids[$vendor_id] = $vendor_id;
}
Then load all vendors of your cart
$query = 'SELECT vendor_id, vendor_name, vendor_alias FROM '.hikamarket::table('vendor').' WHERE vendor_id IN ('.implode(',', $vendor_ids).')';
$db = JFactory::getDBO();
$db->setQuery($query);
$vendors = $db->loadObjectList('vendor_id');
Then in your listing you can retrieve the vendor
$vendor = $vendors[(int)$product->product_vendor_id ?? 1];
And display its name and generate the SEF URL with alias.
By doing that, you will have just one SQL query to load all vendors ; otherwise you are doing one SQL query per item in the cart.
Regards,