Can't retrieve value from category custom field

  • Posts: 639
  • Thank you received: 16
  • Hikashop Business
11 years 3 months ago #158934

I created two custom fields for categories.

one is

forklift_construction_code - Filed type = Text

I want to load it's value to a variable named $constructioncode so I do this:

$this->row =& $row;
$db = JFactory::getDBO();
$db->setQuery('SELECT forklift_construction_code FROM '.hikashop_table('category').' WHERE category_id='.(int)$this->row->product_manufacturer_id);
$constructioncode = $db->loadResult();


but although I have all categories with a value defined for this field I always get a blank value. Looks like the value is not loading.

I use the same code to retrieve the value for category_name and category_id and it works fine, but those are core fields, shall I use different code for custom fields?

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

  • Posts: 639
  • Thank you received: 16
  • Hikashop Business
11 years 3 months ago #158936

SELF SOLVED - The code was incomplete.

Included here for the case is ever useful to somebody
$this->row =& $row;
$db = JFactory::getDBO();
$db->setQuery('SELECT category_id FROM '.hikashop_table('product_category').' WHERE product_id='.(int)$this->row->product_id);
$categoryName = $db->loadResult();
$db->setQuery('SELECT forklift_construction_code FROM '.hikashop_table('category').' WHERE category_id='.(int)$categoryName);
$constructioncode = $db->loadResult();

Last edit: 11 years 3 months ago by PeterChain.

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

  • Posts: 13201
  • Thank you received: 2322
11 years 3 months ago #158939

Hi,

You should be able to get the value in the var "$this->row->forklift_construction_code".
Thanks to set the error reporting to maximum, you maybe have an error.

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

Time to create page: 0.067 seconds
Powered by Kunena Forum