- Posts: 109
- Thank you received: 5
Get Item ID for a Given Category Id
12 years 1 week ago #172453
by Ed_Hika
Get Item ID for a Given Category Id was created by Ed_Hika
-- HikaShop version -- : 2.3.2
-- Joomla version -- : 3.3.3
-- Browser(s) name and version -- : IE 11
Hello, there.
Good afternoon!
I am trying to retrieve the Item ID for a given Category ID. Is there any update since the discussion on www.hikashop.com/forum/4-how-to/15169-get-the-itemid.html ? I.e. is there now a Hikashop function that I can call? If so, please could you provide the name of the class and method?
If not, please could you confirm that the best code to use will be the one that Nicolas stated in the discussion (see the link above)? I.e. the code is:
~~~~~~ START OF CODE ~~~~~~
function getItemidFromCategory($category_id){
$config =& hikashop::config();
foreach($config->values as $key => $value){
if(preg_match('#menu_([0-9]+)#',$key,$match)){
if(is_string($value->config_value)) $value->config_value = unserialize(base64_decode($value->config_value));
if($value->config_value == $category_id ){
return $match[1];
}
}
}
return false;
}
~~~~~~~ END OF CODE ~~~~~~~
Thanks.
Take care!
-- Joomla version -- : 3.3.3
-- Browser(s) name and version -- : IE 11
Hello, there.
Good afternoon!
I am trying to retrieve the Item ID for a given Category ID. Is there any update since the discussion on www.hikashop.com/forum/4-how-to/15169-get-the-itemid.html ? I.e. is there now a Hikashop function that I can call? If so, please could you provide the name of the class and method?
If not, please could you confirm that the best code to use will be the one that Nicolas stated in the discussion (see the link above)? I.e. the code is:
~~~~~~ START OF CODE ~~~~~~
function getItemidFromCategory($category_id){
$config =& hikashop::config();
foreach($config->values as $key => $value){
if(preg_match('#menu_([0-9]+)#',$key,$match)){
if(is_string($value->config_value)) $value->config_value = unserialize(base64_decode($value->config_value));
if($value->config_value == $category_id ){
return $match[1];
}
}
}
return false;
}
~~~~~~~ END OF CODE ~~~~~~~
Thanks.
Take care!
Please Log in or Create an account to join the conversation.
12 years 1 week ago #172467
by Xavier
Replied by Xavier on topic Get Item ID for a Given Category Id
Hi,
In fact, a category don't have attached item id, the item id is based on the menus.
So to have one item id per category you need to have one category listing menu associated to a category.
The code provided by Nicolas is still valid, it allow to have the item id of the attached category's menu.
In fact, a category don't have attached item id, the item id is based on the menus.
So to have one item id per category you need to have one category listing menu associated to a category.
The code provided by Nicolas is still valid, it allow to have the item id of the attached category's menu.
Please Log in or Create an account to join the conversation.
12 years 1 week ago #172611
by Ed_Hika
Replied by Ed_Hika on topic Get Item ID for a Given Category Id
Bonjour, Xavier.
Good afternoon!
Thank you for your reply.
This is probably a silly question (but do not that I am not familiar with php).
I cannot get the function to run. After some debugging, it seems that the function gets stuck (stop executing) at the following line:
$config =& hikashop::config();
Is there some declaration that I need to do at the start of the function?
Thanks.
Take care!
Good afternoon!
Thank you for your reply.
This is probably a silly question (but do not that I am not familiar with php).
I cannot get the function to run. After some debugging, it seems that the function gets stuck (stop executing) at the following line:
$config =& hikashop::config();
Is there some declaration that I need to do at the start of the function?
Thanks.
Take care!
Please Log in or Create an account to join the conversation.
12 years 1 week ago #172616
by Ed_Hika
Replied by Ed_Hika on topic Get Item ID for a Given Category Id
Bonjour, Xavier.
Good afternoon!
Just to let you know that I have figured it out. I included the following line at the start of the function and it's all honky dory now.
if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }
Thanks for your help.
Take care!
Good afternoon!
Just to let you know that I have figured it out. I included the following line at the start of the function and it's all honky dory now.
if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }
Thanks for your help.
Take care!
Please Log in or Create an account to join the conversation.
Time to create page: 0.200 seconds