Custom Field Value and Filtering Issue

  • Posts: 100
  • Thank you received: 1
9 years 10 months ago #159363

-- HikaShop version -- : 2.3.1
-- Joomla version -- : 3.3
-- PHP version -- : 5x

HI

I have created a custom field of table "product" as below:




I use this custom field to create a filter:





I have discoverd that the space in the Value - "Anglican Church" causes the filter option to become unchecked. (The behaviour should be checked after search results).




When I change this to Value - "AnglicanChurch", then filtering works properly.

My problem is if I use this custom field $this->row->venue on a product list table, it returns the value (AnglicanChurch or 2) and not the Title "Anglican Church".

How do you retrieve the Title of the custom field rather than the Value?

Would you have any suggestion around this issue.


Thanks

Patrick

Attachments:
Last edit: 9 years 10 months ago by paddyrolls.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 years 10 months ago #159395

Hi,

Yes, you should avoid the space in the value of the custom field.
To load the title instead of the value, you can do like that:

$fieldsClass = hikashop_get('class.field);
$fields = $fieldsClass->getFields('frontcomp',$this->row,'product','checkout&task=state');
echo $fieldsClass->show($fields['venue'],$this->row->venue);

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

  • Posts: 100
  • Thank you received: 1
9 years 10 months ago #159433

HI Nicolas

Thank you for the information. Could I also:

1. How would I get the title of custom fields that are not shown in the frontend and only in backend of product view.
2. I am using $fields->field_categories and it returns ",19," representing the category for the custom field. Could you advise how to could return the category name

Thanks

Patrick

Last edit: 9 years 10 months ago by paddyrolls.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 years 10 months ago #159467

Hi,

1. you could directly write the title. Otherwise such code can do it:

$fieldsClass->getFieldName($fields['venue']);

2. There is no function for that. You'll have to do it yourself:
$category_id = (int)str_replace(',','',$fields->field_categories);
$categoryClass = hikashop_get('class.category');
$category = $categoryClass->get($category_id);
echo $category->category_name;

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

  • Posts: 171
  • Thank you received: 4
9 years 4 months ago #183673

Hi,

if i do this to get the value of a dropdown i get the following error

Notice: Trying to get property of non-object in administrator/components/com_hikashop/classes/field.php on line 1288 Notice: Trying to get property of non-object in administrator/components/com_hikashop/classes/field.php on line 1289 Fatal error: Call to undefined method hikashop::show() in administrator/components/com_hikashop/classes/field.php on line 1298

any help would be aprriciated :)

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 years 4 months ago #183787

Hi,

Several pieces of code were posted here. What exact code modification did you do and where exactly ?

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

  • Posts: 171
  • Thank you received: 4
9 years 4 months ago #183789

nicolas wrote: Hi,

Yes, you should avoid the space in the value of the custom field.
To load the title instead of the value, you can do like that:

$fieldsClass = hikashop_get('class.field);
$fields = $fieldsClass->getFields('frontcomp',$this->row,'product','checkout&task=state');
echo $fieldsClass->show($fields['venue'],$this->row->venue);


this one

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 years 4 months ago #183799

Hi,

Where did you add that code ?
Do you have a custom product field called "venue" ? Could you do a screenshot of the options of your custom field ?

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

  • Posts: 171
  • Thank you received: 4
9 years 4 months ago #183904

This is my field and the code i use is

$fieldsClass = hikashop_get('class.field');
$fields = $fieldsClass->getFields('frontcomp',$this->row,'product','checkout&task=state');
echo $fieldsClass->show($fields['steltype'],$this->row->steltype);

but gives me the error.
It is added in product/listing_img_title.php

Attachments:
Last edit: 9 years 4 months ago by jesper.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 years 4 months ago #183942

Hi,

It would have been great to have a screenshot of all the options of the custom field, including the remaining options on the right of the screen.
Here is the potential issue:
- you should turn on the "front-end" option in your custom field, or change frontcomp to backend in your custom code.
- make sure that the "include sub categories" option of the categories listing of your custom field is activated.
- make sure that you didn't restrict your custom field to only some user groups via the "access levels" option.

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

  • Posts: 171
  • Thank you received: 4
9 years 4 months ago #184058

well the frontend showing worked...
rest was as you already stated... now it just shows on products where i didn't want it, but can hide it there with a display none, so no worries :)

Thanx :)

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

Time to create page: 0.100 seconds
Powered by Kunena Forum