X
X
Xtrme2019-12-18 02:13:51
PHP
Xtrme, 2019-12-18 02:13:51

What is the error in products product.php on line 432 - 436?

Tell me, please, the site is on the local, Opencart 3.0.2, when you go to any product, everything is displayed, but at the top of the page it gives an error.
Notice: Undefined variable: result in \domains\storage\modification\catalog\controller\product\product.php on line 436.
Here is the code of these lines:

$images = $this->model_catalog_product->getProductImages($result['product_id']);
      if(isset($images[0]['image']) && !empty($images)){
        $images = $images[0]['image']; 
      }else{
        $images = $image;

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ilya Savinykh, 2019-12-18
@Xtrme

Declare $result = [] before if, foreach, etc.

$result = [];
if(...) {
     foreach(... as ...) {
          $images = $this->model_catalog_product->getProductImages($result['product_id']);
          if(isset($images[0]['image']) && !empty($images)){
               $images = $images[0]['image']; 
          } else {
               $images = $image;
          }
}

G
grisha2217, 2019-12-18
@grisha2217

The $result variable does not exist. Maybe $result is declared inside foreach or if, so it doesn't exist.

L
liza2019, 2019-12-22
@liza2019

this piece is from some mod. It looks like it's in the wrong place. outside the
foreach ($results as $result) {
so it's impossible to tell. it is necessary to look all function where this piece is inserted.
although to be honest, this piece does not make much sense. in native file it looks like this
$results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);

$results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);

      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_additional_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height'))
        );
      }

or try replacing $result['product_id'] with $product_info['product_id']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question