How to display custom fields in listing of products.

  • Posts: 4
  • Thank you received: 1
3 years 6 days ago #339971

-- HikaShop version -- : 4.5.0
-- Joomla version -- : 4.0.1
-- PHP version -- : 7.4
-- Browser(s) name and version -- : Chrome latest

I want to display (show) the custum fields (tags) in the listing of products. On the detail product page The fields are displayed. But I want them displayed also in the overview of products, so the listings.
In configuration>display> I enabled the item "show custom fields for the table item on the product listings".

Please Log in or Create an account to join the conversation.

  • Posts: 83402
  • Thank you received: 13495
  • MODERATOR
3 years 5 days ago #339981

Hi,

That setting is for the custom fields of the table "item". From what I understand the custom fields you want to display on the listings are of the table "product".
You need to edit your custom fields in the menu Display>Custom fields. There, you have many display settings including one called "front-end listing" that you need to turn on.

Please Log in or Create an account to join the conversation.

  • Posts: 4
  • Thank you received: 1
3 years 5 days ago #339986

Hi,
I have done that all, and it works. The custom fields are showed on the product DETAIL page. But I want them also be showed in the product listing overview in the categorie listing (The small box with picture, price and add to cart ) How can I add there some more text.I want for example sell vacuum cleaners and in the product listing I want to add for example the maximum flow and maximum pressure, so the client does not have always to click the detail button to see the power of the vacuum cleaner and can better choose in the overview. In attachment an example from a random shop. You see, in the overview there are a few headlines about the product in the overview product listing.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83402
  • Thank you received: 13495
  • MODERATOR
3 years 5 days ago #339989

Hi,

This setting will do what you want.
However, looking at your screenshot, I can see that you (or your template provider or the person who made the website for you) heavily customized the products listing look.
So the view override for the products listing must be missing the code:

<!-- CUSTOM PRODUCT FIELDS -->
<?php
if(!empty($this->productFields)) {
	foreach($this->productFields as $fieldName => $oneExtraField) {
		if(empty($this->row->$fieldName) && (!isset($this->row->$fieldName) || $this->row->$fieldName !== '0'))
			continue;

		if(!empty($oneExtraField->field_products)) {
			$field_products = is_string($oneExtraField->field_products) ? explode(',', trim($oneExtraField->field_products, ',')) : $oneExtraField->field_products;
			if(!in_array($this->row->product_id, $field_products))
				continue;
		}
?>
	<dl class="hikashop_product_custom_<?php echo $oneExtraField->field_namekey;?>_line">
		<dt class="hikashop_product_custom_name">
			<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
		</dt>
		<dd class="hikashop_product_custom_value">
			<?php echo $this->fieldsClass->show($oneExtraField,$this->row->$fieldName); ?>
		</dd>
	</dl>
<?php
	}
}
?>
<!-- EO CUSTOM PRODUCT FIELDS -->
which displays the product custom fields on the listing page.
In that case, there is no easy way to add the custom product fields to the listing since the code to handle that "front-end listing" display option is missing/different.
You need to edit the view override code to add that code above hoping that it will work, or some other code modification based on the modifications already in place in the view override.
The best is to check with the person who made the customization or the template provider if it comes from the template.

Please Log in or Create an account to join the conversation.

  • Posts: 4
  • Thank you received: 1
3 years 5 days ago #340007

Hi,
The view (example is like mentioned , NOT my hika website, it is an example from a random website on the internet (and no hikashop) to let see wat I want.
I tried it wit gantry5 template and also with the standard joomla 4 template. No Custom fields by either. If I inspect the html of my page, I see the comments line custom fields and eof custom fields, but no code between it. I have seen the code you provide in the display option listing_img_title,
but this code is not generated in the html, and there is no template override, since I have the same result if I use standard cassiopeia template from joomla 4 (which has no overide ). As mentioned before, I made the fields and the are showed on the product detail page, but not in the listing_img_title display. Is ther anywhere a setting to show or not to show the custom fields in listing_img_title. For the product detail view, You can switch on or off, but I see no setting for the product listing view.

Please Log in or Create an account to join the conversation.

  • Posts: 83402
  • Thank you received: 13495
  • MODERATOR
3 years 4 days ago #340017

Hi,

Well, I checked your website just now to see what's going on, but I do already see the custom product fields on your listing:
i.imgur.com/fbWpFRz.png
So to me, it's already working.
Or are you talking about something else other than the "Debiet", "Vacuum", "Vermogen" and "Spanning" custom fields ?

Please Log in or Create an account to join the conversation.

  • Posts: 4
  • Thank you received: 1
3 years 3 days ago #340071

Hi,
I found the solution. On the custom Item tab, in the Display section, I enabled all views and then It worked. I found out wicht view it was, and in English it is called "Frontend Listing". This enables the custom fields on the product listing, and "Frontend" on the detail product tab. But I use hikashop translated in dutch and the "Frontend Listing" is poorly and badly translated, so I couldn't figure out the purpose. Thats why I asked where and if there was a setting for activating the view in product listing, because I saw in the program there was code written for it.. And there was.
In Dutch, when You hover over an item, i get the tooltip in English, so I understand the meaning, but for a lot of settings, there is no tooltip. This was also the case for this setting.
Anyway, my problem is soved and may thanks for the support.

Michael Flies

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.056 seconds
Powered by Kunena Forum