VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Gruz on March 21, 2012, 16:55:29 PM

Title: Custom fields childs are not shown
Post by: Gruz on March 21, 2012, 16:55:29 PM
J 2.5.3
VM SVN, 2.0.3.E

When I add a parent custom field and a subparent custom fields - the subparent fields are never shown.
(http://static.xscreenshot.com/2012/03/21/10/screen_2c1dca8b43345e97d0ec87ea4a892ec4) (http://view.xscreenshot.com/2c1dca8b43345e97d0ec87ea4a892ec4)

I have tree of custom fields like this:

Index: .
===================================================================
--- . (revision 5696)
+++ . (working copy)
@@ -79,14 +79,18 @@
{
$fieldTypes= $this->model->getField_types() ;

+ //get top parent element
$query = "SELECT *,custom_value as value FROM #__virtuemart_customs
- WHERE (`virtuemart_custom_id`=".$id." or `custom_parent_id`=".$id.")";
- $query .=" order by custom_parent_id asc";
+ WHERE `virtuemart_custom_id`=".$id;
+ $query .=" order by ordering, custom_parent_id asc";
$this->db->setQuery($query);
- $rows = $this->db->loadObjectlist();
+ $this->rows = $this->db->loadObjectlist();
+ if ($this->rows[0]->field_type == 'P') {
+ $this->getChildCustomfieldList($id);
+ }

$html = array ();
- foreach ($rows as $field) {
+ foreach ($this->rows as $field) {
if ($field->field_type =='C' ){
$this->json['table'] = 'childs';
$q='SELECT `virtuemart_product_id` FROM `#__virtuemart_products` WHERE `published`=1
@@ -191,5 +195,28 @@
}
}

+ /**
+ * Gets the list of custom field childs and subchilds, full tree
+ *
+ * @author Gruz <arygroup@gmail.com>
+ *
+ * @param integer $id The parent fields ID
+ * @return void
+ */
+ function getChildCustomfieldList ($id) {
+ $query = "SELECT *,custom_value as value FROM #__virtuemart_customs
+ WHERE `custom_parent_id`=".$id;
+ $query .=" order by ordering, custom_parent_id asc";
+ $this->db->setQuery($query);
+ $rows = $this->db->loadObjectlist();
+ $this->rows = (object) array_merge((array)$this->rows,(array)$rows);
+ foreach ($rows as $row) {
+ if ($row->field_type == 'P')  {
+ $this->getChildCustomfieldList($row->virtuemart_custom_id);
+ }
+ }
+ }
+
+
}
// pure php no closing tag

http://paste.opensuse.org/11021488

I've add a fuction which recoursively looks for the child fields.

Result illustration:
(http://static.xscreenshot.com/2012/03/21/17/screen_ca4d6b1c445dc69d56f345bdb2095238) (http://view.xscreenshot.com/ca4d6b1c445dc69d56f345bdb2095238)

Please, let me know if this bug is going to be solved. I can't use custom fields because of this one and this http://forum.virtuemart.net/index.php?topic=99847.0
And there is no reaction from the dev team, if they consider this is a problem.

Thanks.
Title: Re: Custom fields childs are not shown
Post by: Studio 42 on March 22, 2012, 22:39:29 PM
Sorry Gruz,
But we have all 3 main members the Joomla day in france and can not add and look for it this week.
The parent was only here to "group" and set the custom in parent in one time in product and for searching in FE.
But be sure we look all suggestion and try to add it if this fith with the general usability of Virtuemart.
Title: Re: Custom fields childs are not shown
Post by: Gruz on March 25, 2012, 14:03:23 PM
The other problem connected with this one is that fields cannot have the same names. It's not ok, when I want to have the same names in different custom field groups.

I.e. I have "Subwoofer description" and "Satellite description" groups and both need to have  a  Power field in both groups.