News:

Looking for documentation? Take a look on our wiki

Main Menu

Issue with plugin type custom field params

Started by sandomatyas, June 17, 2022, 13:22:20 PM

Previous topic - Next topic

sandomatyas

I have a site where I installed a vmcustom plugin and created 2 custom fields and assigned both of them to a product. At the productdetails view only the first customfield displays the params but not the second one.

I tried to debug a bit and dumped the plugin data in plgVmOnDisplayProductFEVM3

stdClass Object
(
    [virtuemart_custom_id] => 50
    [custom_parent_id] => 0
    [virtuemart_vendor_id] => 1
    [custom_jplugin_id] => 10327
    [custom_element] => mycustomvariant
    [admin_only] => 0
    [custom_title] => Abmessungen |
    [show_title] => 1
    [custom_tip] =>
    [custom_value] =>
    [custom_desc] =>
    [field_type] => E
    [is_list] => 0
    [is_hidden] => 0
    [is_cart_attribute] => 1
    [is_input] => 1
    [searchable] => 0
    [layout_pos] => addtocart
    [custom_params] => tipus="24"|
    [shared] => 0
    [published] => 1
    [ordering] => 0
    [virtuemart_shoppergroup_id] =>
    [virtuemart_customfield_id] => 1702084
    [virtuemart_product_id] => 20
    [customfield_value] =>
    [customfield_price] =>
    [customfield_params] =>
    [fpublished] => 1
    [override] => 0
    [disabler] => 0
    [noninheritable] => 0
    [product_sku] =>
    [product_gtin] =>
    [product_mpn] =>
    [_varsToPushParam] => Array
        (
            [tipus] => Array
                (
                    [0] => 0
                    [1] => int
                )

        )

    [tipus] => 24
    [_xParams] => customfield_params
    [display] =>
)

stdClass Object
(
    [virtuemart_custom_id] => 51
    [custom_parent_id] => 0
    [virtuemart_vendor_id] => 1
    [custom_jplugin_id] => 10327
    [custom_element] => mycustomvariant
    [admin_only] => 0
    [custom_title] => Farbauswahl |
    [show_title] => 1
    [custom_tip] =>
    [custom_value] =>
    [custom_desc] =>
    [field_type] => E
    [is_list] => 0
    [is_hidden] => 0
    [is_cart_attribute] => 1
    [is_input] => 1
    [searchable] => 0
    [layout_pos] => addtocart
    [custom_params] => tipus="46"|
    [shared] => 0
    [published] => 1
    [ordering] => 0
    [virtuemart_shoppergroup_id] =>
    [virtuemart_customfield_id] => 1702372
    [virtuemart_product_id] => 20
    [customfield_value] =>
    [customfield_price] =>
    [customfield_params] =>
    [fpublished] => 1
    [override] => 0
    [disabler] => 0
    [noninheritable] => 0
    [product_sku] =>
    [product_gtin] =>
    [product_mpn] =>
    [display] =>
)


As you can see there is no _varsToPushParam and _xParams in the second object (id=51) only the first one (id=50).  When I switch the ordering of product customfields I get the data for id=51 but not for id=50.

I tested this with 2 sites and 2 different plugins:
- VirtueMart 3.8.9 10473
- VirtueMart 4.0.2 10661

I found an older site of mine with VirtueMart 3.2.14, tried it there and it does work perfectly.

Any guess?

Milbo

Please check the textinputplugin, I just tested and it works there as expected
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sandomatyas

Ok, but these two plugins were okay with previous VM versions. We only updated VM, there is no new relase of the plugins. Is there some VM change which could be related to this? Do we need to modify the plugins? If yes, what should we change?

Milbo

I am sure I can find it, when I have the plugin, but so I have no clue.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

I have same issue.
I do not found for now the problem.
I checked the params and it's perhaps when you have an array
i have an array of product IDS and the param is NULL in the front end but work right in back-end

Studio 42

The problem is that _varsToPushParam is not set in the last customfield

I have 2 instances of same virtuemart_custom_id (34)
This is working fine

But the last use another virtuemart_custom_id (78) and do not include _varsToPushParam in the object and values are not set !


Tested with VirtueMart 3.8.9 10473

balai

The problem comes from that file: administrator/components/com_virtuemart/helpers/vmtable.php
line: 606
if (!is_string($obj->{$xParams})){
vmError('vmTable Error, $obj->{$xParams} is not a string '.print_r($obj));
return;
}


Seems like VM caches the custom fields.
When a custom field sets it's custom_params as an array, you get this, as it uses the cached version the 2nd time.
In our case (breakdesigns.net) we fixed it by not re-setting the custom_params in our code and using another var for that.

Possibly can be fixed in the core as well, as it then transforms the string to array using implode.
So maybe could check if it is an array before hand.