Post by berdia » Tue Mar 23, 2021 8:58 pm

Hi,
I am getting:
Notice: Undefined variable: result in /var/www/storage/modification/catalog/controller/product/product.php on line 279;
Notice: Undefined variable: image in /var/www/storage/modification/catalog/controller/product/product.php on line 283
errors when I open individual products in OpenCart 3.x

Line 279 corresponds to this code: $images = $this->model_catalog_product->getProductImages($result['product_id']);
Line 283 corresponds to this code: $images = $image;

This is a code in whole:

Code: Select all

$images = $this->model_catalog_product->getProductImages($result['product_id']);
			if(isset($images[0]['image']) && !empty($images)){
				$images = $images[0]['image']; 
			}else{
				$images = $image;
			}
Could you please help to find out what the problem is?

Thank you.

Newbie

Posts

Joined
Tue Mar 23, 2021 8:53 pm

Post by JNeuhoff » Tue Mar 23, 2021 11:14 pm

This is most likely caused by a 3rd party OC extension.
Please provide more details, e.g. OC version, list of all extensions, web theme used etc.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by berdia » Tue Mar 23, 2021 11:57 pm

Thanks for your reply.

OC version is 3.0.3.2
Most of the extensions are under Modules:
Account
Banner
Carousel
Category
Featured
HTML content
Information
Latest
Newsletters
Slideshow
Specials
Theme category type
onWebChat
PayPal Standard

We use a Theme which we bought from Templatemonster called Wined. http://www.templatemonsterpreview.com/demo/75072.html

P.S. I installed onWebChat last night and the problem was there before that so I presume onWebChat is not causing the issue.

Thanks again.

Newbie

Posts

Joined
Tue Mar 23, 2021 8:53 pm

Post by OSWorX » Wed Mar 24, 2021 1:57 am

As the message already states what cause the error:

Code: Select all

$images = $this->model_catalog_product->getProductImages($result['product_id']);
Above there seems to be a query (result): $result['product_id']
But maybe it is not $result and the variable has another name.
Check the whole code.
Second message is a result of the missing first: $result['product_id']

p.s.: Template Monster Templates are mostly full of bugs!
Therefore you should also contact them first before asking here for help, because the use a lot of own modules (most of them are a lousy copy of others) - and the whole thing is a commercial thing.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by paulfeakins » Wed Mar 24, 2021 5:37 pm

berdia wrote:
Tue Mar 23, 2021 8:58 pm
Notice: Undefined variable: result in /var/www/storage/modification/catalog/controller/product/product.php on line 279;
Because the path includes storage/modification it means it's most likely an OCMOD.

Uninstall them one by one until the message goes.

Alternatively pay a developer such as ourselves or post a job in the Commercial Support Forum.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by berdia » Wed Mar 24, 2021 7:37 pm

Thanks for your reply. It's not OCMOD issues as I disabled every extension there one by one and error is still showing.

Newbie

Posts

Joined
Tue Mar 23, 2021 8:53 pm

Post by OSWorX » Wed Mar 24, 2021 8:03 pm

berdia wrote:
Wed Mar 24, 2021 7:37 pm
Thanks for your reply. It's not OCMOD issues as I disabled every extension there one by one and error is still showing.
Well, one expert one more ..
From what do you think come this:

Code: Select all

Notice: Undefined variable: result in /var/www/storage/modification/catalog/controller/product/product.php on line 279; 
As you can see clearly > storage/modification which means, this file IS modified by another extension through OCMod.
This can be any of the additional installed Extensions.

Have you also cleared the modification cache?
And read and do what I've written a long time ago above!

But, as you said "It's not OCMOD issues .." .. better hire an expert.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by berdia » Wed Mar 24, 2021 9:34 pm

Just received an email from template developers. Apparently, the reason for the error is a requirement of two images per item. We were uploading one image per item. I asked them to modify the code and send it to me so I can update it.
Thank you all for your help.

Newbie

Posts

Joined
Tue Mar 23, 2021 8:53 pm

Post by OSWorX » Wed Mar 24, 2021 9:55 pm

berdia wrote:
Wed Mar 24, 2021 9:34 pm
Just received an email from template developers. Apparently, the reason for the error is a requirement of two images per item. We were uploading one image per item. I asked them to modify the code and send it to me so I can update it.
Thank you all for your help.
As said:
OSWorX wrote:
Wed Mar 24, 2021 1:57 am
p.s.: Template Monster Templates are mostly full of bugs!
Therefore you should also contact them first before asking here for help, because the use a lot of own modules (most of them are a lousy copy of others) - and the whole thing is a commercial thing.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by shqbokhari » Mon Oct 07, 2024 3:34 am

I know this is an old thread but still posting it here in case if it would help others. I purchased theme from Templatemonstor and was getting the same error. The error was coming in this code system/storage/modification/catalog/controller/product/product.php (line 279/283). There are few places where I had to make changes to get this issue resolved. The two variables being referenced were kept outside of the foreach loop. After moving those inside the foreach loop the problem was resolved. See below

Code: Select all

foreach ($results as $result) {
				$data['images'][] = array(
				'popup' => $this->model_tool_image->resize($result['image'], 
				           $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), 
				           $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')),
				'thumb' => $this->model_tool_image->resize($result['image'], 
				           $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'), //Syed:replaced _image_additional_width -> _image_thumb_width
				           $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height'))//Syed:replaced _image_additional_height -> _image_thumb_height
				);
			//}  Syed commented out this line

			$images = $this->model_catalog_product->getProductImages($result['product_id']);  
			if(isset($images[0]['image']) && !empty($images)){
				$images = $images[0]['image']; 
			}else{
				$images = $image;                                                         
			}
			} // Syed added this line to bring the statements within the foreach loop (problem solved)
Last edited by shqbokhari on Mon Oct 07, 2024 3:37 am, edited 1 time in total.

Newbie

Posts

Joined
Fri May 27, 2022 3:51 am

Post by JNeuhoff » Mon Oct 07, 2024 8:09 pm

You need to change the original OCmod XML, not the system/storage/modification/catalog/controller/product/product.php, otherwise your fix will disappear next time you do a Extensions > Modifications > Refresh.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by shqbokhari » Sat Oct 12, 2024 10:43 am

Yes, you are absolutely right I modified the code in the (catalog\controller\product\product.php) file (corrected the issue with the wrong reference for thumb image and commented out the closing of foreach loop). Second change done is in the ocmod xml file that gets loaded into the ocmod table in the database for the theme bgmartcosmetic.ocmod.zip. The code in the theme ocmod was being inserted outside the foreach loop.

Newbie

Posts

Joined
Fri May 27, 2022 3:51 am
Who is online

Users browsing this forum: Majestic-12 [Bot] and 26 guests