Hi,
Why a vendor custom field ?
You vendors just have one single category ?
A product custom fields could not be better ?
In the listing page, you can load and display a product custom field:
if(!empty($this->rows)){
// Load the product custom fields
// (in the beginning of the file)
$fieldsClass = hikashop_get('class.field');
$productfields = $fieldsClass->getFields('frontcomp',$this->rows,'product');
}
// Display a custom field value for the product
// (in a cell of the listing table)
$fieldName = 'my_custom_field_name';
if(!empty($productfields[$fieldName]) && !empty($row->$fieldName))
echo $this->fieldsClass->show($productfields[$fieldName], $row->$fieldName);
You can do quite same thing for loading and displaying a vendor custom field but the code is a little bit different because you have to load the vendors before.
if(!empty($this->rows)) {
// Load the vendors in the current listing
//
$vendorIds = array();
foreach($this->rows as $row) {
$vendorIds[$row->product_vendor_id] = $row->product_vendor_id;
}
if(!empty($vendorIds)) {
$query = 'SELECT * FROM '.hikamarket::table('vendor').' WHERE vendor_id IN ('.implode(',',$vendorIds).')';
$db = JFactory::getDBO();
$db->setQuery($query);
$vendors = $db->loadObjectList('vendor_id');
} else {
$vendors = array();
}
// Load the vendor custom fields
//
$fieldsClass = hikashop_get('class.field');
$null = null;
$vendorFields = $fieldsClass->getFields('frontcomp', $null, 'plg.hikamarket.vendor');
}
if(!empty($vendors[ $row->product_vendor_id ])) {
$currentVendor = $vendors[ $row->product_vendor_id ];
$fieldName = 'vendor_category_for_product_listing';
if(!empty($vendorsFields[$fieldName]) && !empty($currentVendor->$fieldName)) {
$fieldsClass->show($vendorFields[$fieldName], $currentVendor->$fieldName);
}
}
Regards,