How can I add ID group extra field in array extra_field

12.12.2022 18:26
#1
Aspik
Joomshopping forum user no avatar
Name: Aspik
24.09.2011
Posts: 12
Quote
How can I add ID group extra field in array extra_field

Hello,
How can I add ID group extra field in array $this->product->extra_field ?


Joomla: 4.2.5
JoomShopping: 5.1.1
PHP: 8.1.12
 
12.12.2022 19:28
#2
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25941
Quote
Aw: How can I add ID group extra field in array extra_field

I don't understand your question.

 
18.12.2022 16:00
#3
Aspik
Joomshopping forum user no avatar
Name: Aspik
24.09.2011
Posts: 12
Quote
Aw: How can I add ID group extra field in array extra_field

if look var_dump ($this->product->extra_field);

array(8) {
["id"]=>
int(4)
["name"]=>
string(19) ""
["description"]=>
string(0) ""
["value"]=>
string(2) "24"
["groupname"]=>
string(38) ""
["field_value_ids"]=>
array(1) {
[0]=>
string(2) "10"
}
["grshow"]=>
int(0)
["grshowclose"]=>
int(0)
}


How to add to an array ID groupname?

 
18.12.2022 16:47
#4
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25941
Quote
Aw: How can I add ID group extra field in array extra_field

components\com_jshopping\Table\ProductTable.php

function getExtraFields($type = 1){
$_cats = $this->getCategories();
$cats = array();
foreach($_cats as $v){
$cats[] = $v->category_id;
}
$productExtraField = $this->getExtraFieldsData();

$fields = array();
$JshopConfig = \JSFactory::getConfig();
$hide_fields = $JshopConfig->getProductHideExtraFields();
$cart_fields = $JshopConfig->getCartDisplayExtraFields();
$fieldvalues = \JSFactory::getAllProductExtraFieldValue();
$listfield = \JSFactory::getAllProductExtraField();
foreach($listfield as $val){
if ($type==1 && in_array($val->id, $hide_fields)) continue;
if ($type==2 && !in_array($val->id, $cart_fields)) continue;

if ($val->allcats){
$fields[] = $val;
}else{
$insert = 0;
foreach($cats as $cat_id){
if (in_array($cat_id, $val->cats)) $insert = 1;
}
if ($insert){
$fields[] = $val;
}
}
}

$rows = array();
foreach($fields as $field){
$field_id = $field->id;
$field_name = "extra_field_".$field_id;
if ($field->type==0){
if ($productExtraField[$field_name] != 0 && $productExtraField[$field_name] != ''){
$listid = explode(',', $productExtraField[$field_name]);
$tmp = array();
foreach($listid as $extrafiledvalueid){
$tmp[] = $fieldvalues[$extrafiledvalueid];
}
$extra_field_value = implode($JshopConfig->multi_charactiristic_separator, $tmp);
$rows[] = array("id"=>$field_id, "name"=>$listfield[$field_id]->name, "description"=>$listfield[$field_id]->description, "value"=>$extra_field_value, "groupname"=>$listfield[$field_id]->groupname, 'field_value_ids'=>$listid, 'group_id' => $field->group);
}
}else{
if (isset($productExtraField[$field_name]) && $productExtraField[$field_name]!=""){
$rows[] = array("id"=>$field_id, "name"=>$listfield[$field_id]->name, "description"=>$listfield[$field_id]->description, "value"=>$productExtraField[$field_name], "groupname"=>$listfield[$field_id]->groupname, 'group_id' => $field->group);
}
}
}

$rowsblock = array();
foreach($rows as $k=>$v){
if ($v['groupname']==''){
$grname = 'defaultgroup';
}else{
$grname = $v['groupname'];
}
$rowsblock[$grname][] = $v;
}

$rows = array();
foreach($rowsblock as $bl=>$val){
foreach($val as $k=>$v){
if ($k==0){
$v['grshow'] = 1;
}else{
$v['grshow'] = 0;
}
if ($k==(count($val)-1)){
$v['grshowclose'] = 1;
}else{
$v['grshowclose'] = 0;
}
$rows[$v['id']] = $v;
}
}
return $rows;
}

 
18.12.2022 17:36
#5
Aspik
Joomshopping forum user no avatar
Name: Aspik
24.09.2011
Posts: 12
Quote
Aw: How can I add ID group extra field in array extra_field

Thanks!
it will be very good if you include it by default in future versions


Last change: 18.12.2022 17:37
 
18.12.2022 18:44
#6
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25941
Quote
Aw: How can I add ID group extra field in array extra_field

Yes.
Will be in 5.1.2

 


Copyrights MAXXmarketing GmbH. Alle Rechte vorbehalten
Durch die Nutzung dieser Website stimme ich zu, dass Cookies zur optimalen Gestaltung der Website sowie zur Analyse der Nutzung der Website verwendet werden. Weiterführende Informationen finden Sie hier. OK, einverstanden.