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
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.
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.
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.