- Posts: 640
- Thank you received: 16
Can't retrieve value from category custom field
- PeterChain
-
Topic Author
- Offline
Less
More
12 years 3 months ago #158934
by PeterChain
Can't retrieve value from category custom field was created by PeterChain
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?
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.
- PeterChain
-
Topic Author
- Offline
Less
More
- Posts: 640
- Thank you received: 16
12 years 3 months ago - 12 years 3 months ago #158936
by PeterChain
Replied by PeterChain on topic SELF SOLVED!!
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();
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: 12 years 3 months ago by PeterChain.
Please Log in or Create an account to join the conversation.
12 years 3 months ago #158939
by Xavier
Replied by Xavier on topic Can't retrieve value from category custom field
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.
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.251 seconds