Error in product.php when related empty/unset

Phoca Cart - complex e-commerce extension
lpatrick
Phoca Enthusiast
Phoca Enthusiast
Posts: 88
Joined: 13 Feb 2024, 17:00

Error in product.php when related empty/unset

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Error in product.php when related empty/unset

Post by Jan »

Hi, do you get some error message there?

Jan
If you find Phoca extensions useful, please support the project
lpatrick
Phoca Enthusiast
Phoca Enthusiast
Posts: 88
Joined: 13 Feb 2024, 17:00

Re: Error in product.php when related empty/unset

Post 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.
lpatrick
Phoca Enthusiast
Phoca Enthusiast
Posts: 88
Joined: 13 Feb 2024, 17:00

Re: Error in product.php when related empty/unset

Post 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?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Error in product.php when related empty/unset

Post 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
If you find Phoca extensions useful, please support the project
lpatrick
Phoca Enthusiast
Phoca Enthusiast
Posts: 88
Joined: 13 Feb 2024, 17:00

Re: Error in product.php when related empty/unset

Post 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?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Error in product.php when related empty/unset

Post 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
If you find Phoca extensions useful, please support the project
Post Reply