Page 1 of 1

HTTP 500 Product error after updating database

Posted: Thu Apr 25, 2024 9:02 am
by 14Steve14
We have one product that for some reason is not showing on our test site after a database upgrade. All the other 3000+ products show fine. This one product is a download product and shows in the category listings and searches but will not open in a product page. We get a HTTP 500 error. We have tried changing all text, inputs and images and still nothing works. If we duplicate the product it works fine so there is no real problem but its now got to a curiosity thing where I just want to know why the error is there.

Here is the error from the log files
[25-Apr-2024 09:51:12 Europe/London] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /home/####/public_html/####/includes/modules/header_tags/ht_product_schema.php:30
Stack trace:
#0 /home/####/public_html/####/includes/system/versioned/1.0.8.4/template.php(79): ht_product_schema->execute()
#1 /home/####/public_html/####/templates/default/includes/components/template_top.php(13): Template->build_blocks()
#2 /home/####/public_html/####/templates/default/includes/pages/product_info.php(13): require('/home/####/...')
#3 /home/####/public_html/####/product_info.php(25): require('/home/####/...')
#4 {main}
thrown in /home/####/public_html/####/includes/modules/header_tags/ht_product_schema.php on line 30
Does anyone have any ideas

Re: HTTP 500 Product error after updating database

Posted: Thu Apr 25, 2024 9:12 am
by burt
That block of code in product_schema header tag determines what Image to use in the output code.

L29: $images = $product->get('images');
L30: $products_image = ( count($images) > 0 )
? $images[0]['image']
: $product->get('image');

L29 grabs the array of extra images that the product has.
L30 sees if the array is NOT empty and if so uses the first large image. Otherwise the array is empty (therefore no extra images) so it uses the normal product image.

Not sure why $images is passing a string rather than an array for this product, especially if it works when you recreate the product.

Re: HTTP 500 Product error after updating database

Posted: Thu Apr 25, 2024 10:26 am
by burt
I wonder if the problem product has a "blank" entry in the product_images table ?

Re: HTTP 500 Product error after updating database

Posted: Thu Apr 25, 2024 10:36 am
by ecartz
Is there a customization to make ->get('images') fail over to products_image? Check the hooks and overrides.

Re: HTTP 500 Product error after updating database

Posted: Thu Apr 25, 2024 11:55 am
by 14Steve14
burt wrote: Thu Apr 25, 2024 10:26 am I wonder if the problem product has a "blank" entry in the product_images table ?
Thanks for taking the time to reply.

I have had a look in the database and the correct image is listed. the image was showing in the products listing. The image is present in the images folder.

When I copied the product, everything worked and showed as it should with no alterations.

Its only my natural curiosity that made me ask. When I upload the live site and convert the database I will be able to see if its something that will happen again.

Re: HTTP 500 Product error after updating database

Posted: Thu Apr 25, 2024 11:57 am
by 14Steve14
ecartz wrote: Thu Apr 25, 2024 10:36 am Is there a customization to make ->get('images') fail over to products_image? Check the hooks and overrides.
Thanks for the reply.

All other products work as they should as far a s we have found so far. It was only by luck that we found this one failing product as the product sort order was set to name not model so it was the first one we clicked on. We checked lots of other products in that and other categories and have not found any other one not working.

On my live site where the database came from the product shows as it should.