- Posts: 48
- Thank you received: 0
Category Custom Field for Vendor
- theweasel68
-
Topic Author
- Offline
Less
More
13 years 6 months ago #93972
by theweasel68
Category Custom Field for Vendor was created by theweasel68
Hi,
in HikaShop, there are several food-categories for products defined: American, Italian, Chinese, etc.
In HikaMarket, I want to assign one or several categories to each vendor.
I thought about creating a custom field. But as it seems, I can only use a new column from the table, and not an existing (the food category)?
Is this right?
How can I define a new custom field for the vendor backend, and use the data of an existing table, in combination with a multi select drop down list?
Thx
in HikaShop, there are several food-categories for products defined: American, Italian, Chinese, etc.
In HikaMarket, I want to assign one or several categories to each vendor.
I thought about creating a custom field. But as it seems, I can only use a new column from the table, and not an existing (the food category)?
Is this right?
How can I define a new custom field for the vendor backend, and use the data of an existing table, in combination with a multi select drop down list?
Thx
Please Log in or Create an account to join the conversation.
13 years 6 months ago #93994
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Category Custom Field for Vendor
Hi,
What do you want to store in that category custom field ?
The HikaShop custom field system does not allow such type of "filtering" on several categories. But by improving the system, it shoud be possible.
But my main question is about what you want to do maybe it would be possible to have the same result with another "structure".
After that, I don't understand what you want to do with vendor custom fields.
Regards,
What do you want to store in that category custom field ?
The HikaShop custom field system does not allow such type of "filtering" on several categories. But by improving the system, it shoud be possible.
But my main question is about what you want to do maybe it would be possible to have the same result with another "structure".
After that, I don't understand what you want to do with vendor custom fields.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- theweasel68
-
Topic Author
- Offline
Less
More
- Posts: 48
- Thank you received: 0
13 years 6 months ago #94520
by theweasel68
Replied by theweasel68 on topic Category Custom Field for Vendor
Hi,
actually I would like to assign one or several categories to each vendor. Ideally, it is from the same categories, which is already used for the products.
See the screenshot 1: this is, what I would like to show
See the screenshot 2: the categories, I have in the backend
Thx
actually I would like to assign one or several categories to each vendor. Ideally, it is from the same categories, which is already used for the products.
See the screenshot 1: this is, what I would like to show
See the screenshot 2: the categories, I have in the backend
Thx
Please Log in or Create an account to join the conversation.
13 years 6 months ago #94542
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Category Custom Field for Vendor
Hi,
In HikaMarket, a vendor could just assign a category to a product if he has access to it.
We would add in a future release, the possibility to "share" other categories to vendors. At this moment, the vendor would be able to place his products in these categories.
After that, the listing that you want to have is quite complex to implement.
You would have to retrieve all categories of the product in the listing and display the right category name in the listing (not displaying the current "daily receipt" one, etc).
I guess that, creating a product custom field which would contains the list of the categories would be better.
You can store in the custom field possible values the couple "category id / category name" and create the special display in the table listing.
The custom field values would not be dynamic, it means that you would have to update manually the values if you create a category or if a category is modified.
It is possible to create a "custom field" plugin in order to have a dynamic and specific system. But I am not sure that you would create and modify your categories every day.
Regards,
In HikaMarket, a vendor could just assign a category to a product if he has access to it.
We would add in a future release, the possibility to "share" other categories to vendors. At this moment, the vendor would be able to place his products in these categories.
After that, the listing that you want to have is quite complex to implement.
You would have to retrieve all categories of the product in the listing and display the right category name in the listing (not displaying the current "daily receipt" one, etc).
I guess that, creating a product custom field which would contains the list of the categories would be better.
You can store in the custom field possible values the couple "category id / category name" and create the special display in the table listing.
The custom field values would not be dynamic, it means that you would have to update manually the values if you create a category or if a category is modified.
It is possible to create a "custom field" plugin in order to have a dynamic and specific system. But I am not sure that you would create and modify your categories every day.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- theweasel68
-
Topic Author
- Offline
Less
More
- Posts: 48
- Thank you received: 0
13 years 6 months ago #94596
by theweasel68
Replied by theweasel68 on topic Category Custom Field for Vendor
Thanks Jerome,
I think this was just too complicated from my side. As you say, I will not edit the categories on a day to day basis. So the easiest will be to create a custom field for the vendor, and display the values on the product listing in the frontend.
So, what I did now:
I created a multi select custom field in the plg.hikamarket.vendor table
The column name is "vendor_category_for_product_listing"
The point is:
what do I have to add to my product / listing_table.php? in order to display the vendor custom field on the product listing page?
Tried to copy some of the existing code (for the product vote) and modify it, but no success...
I think this was just too complicated from my side. As you say, I will not edit the categories on a day to day basis. So the easiest will be to create a custom field for the vendor, and display the values on the product listing in the frontend.
So, what I did now:
I created a multi select custom field in the plg.hikamarket.vendor table
The column name is "vendor_category_for_product_listing"
The point is:
what do I have to add to my product / listing_table.php? in order to display the vendor custom field on the product listing page?
Tried to copy some of the existing code (for the product vote) and modify it, but no success...
Please Log in or Create an account to join the conversation.
13 years 6 months ago #94688
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Category Custom Field for Vendor
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:
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.
Regards,
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:
Code:
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');
}
Code:
// 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.
Code:
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');
}
Code:
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,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- theweasel68
-
Topic Author
- Offline
Less
More
- Posts: 48
- Thank you received: 0
13 years 6 months ago - 13 years 6 months ago #94996
by theweasel68
Hi,
because the idea is to show the "kitchen category" of the vendor as an additional info - later on, I also want to add a filter for kitchen category. For example, vendor 1 is category Italian. Vendor 2 is category International & Vegetarian, etc.
The vendor can have multiple categories.
I assume the vendor field is more suitable than the product custom field.
I implemented the code as you said (added <?php before and ?> after) - unfortunately nothing is shown...
Replied by theweasel68 on topic Category Custom Field for Vendor
Jerome wrote: Hi,
Why a vendor custom field ?
You vendors just have one single category ?
A product custom fields could not be better ?
Hi,
because the idea is to show the "kitchen category" of the vendor as an additional info - later on, I also want to add a filter for kitchen category. For example, vendor 1 is category Italian. Vendor 2 is category International & Vegetarian, etc.
The vendor can have multiple categories.
I assume the vendor field is more suitable than the product custom field.
I implemented the code as you said (added <?php before and ?> after) - unfortunately nothing is shown...
Last edit: 13 years 6 months ago by theweasel68.
Please Log in or Create an account to join the conversation.
13 years 6 months ago #95116
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Category Custom Field for Vendor
Hi,
I have separate the code in two different blocks.
The first block load the custom fields (for the product or for the vendor) and the second block display the content in the loop.
The first one could be paste at the beginning of the view but the second one, should be paste at a precise place.
You have to add a new cell (and a new column) in order to display it, like the product name, the price or the code are displayed.
After that, I didn't test the code that I gave you. It is some code that I have written like that. Some test and debugging could be required.
Regards,
I have separate the code in two different blocks.
The first block load the custom fields (for the product or for the vendor) and the second block display the content in the loop.
The first one could be paste at the beginning of the view but the second one, should be paste at a precise place.
You have to add a new cell (and a new column) in order to display it, like the product name, the price or the code are displayed.
Code:
<?php if ($this->config->get('show_code')){ ?>
<td class="hikashop_product_code_row">
<?php
echo $this->row->product_code;
?>
</td>
<?php } ?>
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Moderators: Obsidev
Time to create page: 0.223 seconds