0

Finding this error in the OpenCart Error Log and not knowing what is causing it.

PHP Notice: Undefined index: description in .../vqmod/vqcache/vq2-catalog_view_theme_margaretha_template_product_product.tpl on line 484

The code:

<?php foreach ($products as $product) { ?>
    <!-- line 484 -->
    <div class="box-desc"><?php echo $product['description']; ?></div>
<?php } ?>

We see the products and descriptions in the database table but can't see why the error is coming up.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
chance
  • 1
  • try to `var_dump($products)`. check if index `'description'` really exists, or it has more levels inside. `var_dump` it and add it on the question – user1978142 Apr 30 '14 at 01:25

1 Answers1

0

there is no 'description' on $products array(), this is the related part of controller ('products/products'):

            $this->data['products'][] = array(
                'product_id' => $result['product_id'],
                'thumb'      => $image,
                'name'       => $result['name'],
                'price'      => $price,
                'special'    => $special,
                'rating'     => $rating,
                'reviews'    => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
                'href'       => $this->url->link('product/product', 'product_id=' . $result['product_id'])
            );

its a problem with you template. BUT, you can simple add the description index and set his value to $result['description'] because $result array have all columns of product returned from the model.

                'description' => $result['description'],
Dreanmer
  • 733
  • 2
  • 7
  • 18