I have been trying to solve this issue for a few days and have previously posted on the forum.
I have been looking in to the issue more and think I am close to solving the issue but am also new to open cart.
I have used the category wall to show all my categories on the home page of my store. When the user clicks on a category all products from that category are listed.
Each product has a set of options and I want these options to display on this page.
I am using opencart 1.5.1
I added a line of code to this file:- catalog/controller/product/category.php
Code: Select all
$this->data['action'] = $this->url->link('index.php?route=checkout/cart');
Code: Select all
this->data['products'][] = array(
Code: Select all
$options = $this->model_catalog_product->getProductOptions($result['product_id']);
Code: Select all
$this->data['products'][] = array(
'id' => $result['product_id'],
'options' => $options,
'name' => $result['name'],
'thumb' => $image,
'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
);
Code: Select all
<form action="<?php echo $action; ?>;" method="post" enctype="multipart/form-data" id="product_<?php echo $j;?>">
<?php if ($products['options']) { ?>
<?php foreach ($products['options'] as $option) { ?>
<div class="content"> <?php echo $option['name']; ?>: <select name="option[<?php echo $option['product_option_id']; ?>]" id="option[<?php echo $option['product_option_id']; ?>]" onchange="document.getElementById('price<?php echo $v ?>').selectedIndex=this.selectedIndex;
alert(document.getElementById('price<?php echo $v; ?>').value);">
<?php foreach ($option['option_value'] as $option_value) { ?>
<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?></option>
<?php } ?>
</select></div>
<?php } ?>
</div>
<input type="hidden" name="quantity" size="3" value="1" />
</div>
<?php } else { ?>
<div class="content" style="height:25px"> QTY: <input type="text" name="quantity" size="3" value="" /> </div>
<?php } ?>
<input type="hidden" name="product_id" value="<?php echo $products[$j]['id']; ?>" />
<a onclick="alert('<?php echo $products[$j]['name']; ?> added to the cart')" id="add_to_cart_<?php echo $j;?>" rel="<?php echo $j;?>" class="button add_to_cart"><span>Add to Cart</span></a>
</form>
Notice: Undefined index: options in C:\wamp\www\mystore\catalog\view\theme\mytheme\template\product\category.tpl on line 60
Any ideas how I can solve this error?