I want to add product options in the category page in opencart 2.0.
I have added this code in \catalog\model\catalog\product.php
public function hasOptionPriceIncrease($product_id) {
$option_data = $this->getProductOptions($product_id);
if (is_array($product_option_value)) {
foreach ($product_option_value as $option) {
if (is_array($option['product_option_value'])) {
foreach ($option['product_option_value'] as $value) {
if ($value['price'] > 1) {
return true;
}
}
}
} return false }
and then in \controller\product\category.php
'has_option_price_increase' =>$this->model_catalog_product->hasOptionPriceIncrease($result['product_id'])
so now in category $this->data['products'][] becomes something like this-
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_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'] . $url),
'has_option_price_increase' =>$this->model_catalog_product->hasOptionPriceIncrease($result['product_id'])
);
Now i didn't understand how to call this in my view i.e., in collection.tpl
Please help me to display this in my view, to show the product options in category page.
I spent hours doing this but I got it working. Now, I only needed the SELECT so you go and modified it to your needs in the category.tpl I'm using version 2.1.0.2
1- Go to /catalog/controller/product/category.php Then >> Find the product array
2- Add this code above the array
3- add this code inside the products array
4- Go to /catalog/view/theme/YOUR TEMPLATE/template/product/category.tpl and add this code to your product loop
I'm still working in the javascript so I can add product to the cart with quantity and options without going into the product's page. Thanks