Page 1 of 1
Error in product.php when related empty/unset
Posted: 28 Mar 2024, 20:48
by lpatrick
Beta 44 (maybe previous beta versions also)
Jan
Shouldn't line 1376 in admin/libraries/phocacart/product/product.php
Code: Select all
PhocacartRelated::storeRelatedItems((int)$table->id, $data['related']);
be encapsulated in an isset or something?
The import fails on that now.
Re: Error in product.php when related empty/unset
Posted: 29 Mar 2024, 14:28
by Jan
Hi, do you get some error message there?
Jan
Re: Error in product.php when related empty/unset
Posted: 29 Mar 2024, 14:33
by lpatrick
In console, I get
PhocacartRelated::storeRelatedItems(): Argument #2 ($related) must be of type ?array, string given, called in /var/www/html/joomla/administrator/components/com_phocacart/libraries/phocacart/product/product.php on line 1376"
When I look at the incoming $data for the storeProduct function, I see related is there but as an empty string. There was however no related tag in the imported XML.
But even when I change $data[related] to an empty array, I can't go on.
Also, even when I add related products to a product manually and I export, they do not appear in the created XML. Seems that hasn't been implemented yet either.
Re: Error in product.php when related empty/unset
Posted: 29 Mar 2024, 16:12
by lpatrick
So, it seemed, after changing $data[related] to an empty array that the reason I couldn't go on was because there were other new errors along the line.
When the import file contains empty fields for attributes e.g.
Code: Select all
<image/>
<image_medium/>
<image_small/>
<color/>
<default_value/>
you don't seem to accept them. (Array to string conversion warning).
But that's exactly how the XML you export creates them.
So yes, I can remove the empty fields and force related to an empty array but I don't understand why the import isn't compatible with your export.
Are there many more changes to be expected in that area please?
Re: Error in product.php when related empty/unset
Posted: 29 Mar 2024, 20:42
by Jan
Hi, yes, related function was changed in Joomla 5 (the import still not), in Joomla 5, there can be more "related" types, so this needs to be implemented into import/export.
Jan
Re: Error in product.php when related empty/unset
Posted: 30 Mar 2024, 14:07
by lpatrick
But Jan it isn't only that.
Why are empty tags no longer allowed? And if they aren't, why are they in the export?
Re: Error in product.php when related empty/unset
Posted: 03 Apr 2024, 00:25
by Jan
Hi,
in the project more different developers started to work and some of them use type control. This problem does not mean, that something is not more allowed, but that the code needs to be changed (so the translation from XML/CMS of empty string needs to be done, so it is accepted in fucntion wich accepts arrays only.) So mosty probably, this will be fixed with transformation of empty string to empty array.
Jan