Post by sicario » Fri Apr 21, 2017 10:13 am

Originally it is posted to http://stackoverflow.com/questions/2914 ... egory-page
but i got some error:

Fatal error: Call to undefined method ModelCatalogProduct::hasOptionPriceIncrease() in /home2/k6q1s3k7/mycoffeelab.ph/vqmod/vqcache/vq2-catalog_controller_product_category.php on line 250

how to resolve this thing thanks!

Add the following function to \catalog\model\catalog\product.php

Code: Select all

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;
}
}
Then add the following line to the $this->data['products'][] array in the category controller: \controller\product\category.php

Code: Select all

$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'])
);
Then you can add something similar to the following in the view: \catalog\view\theme\duvalay\template\product\category.tpl

Code: Select all

<p class="price">
 <?php if ($product['has_option_price_increase']) { echo 'From'; } ?>  

Newbie

Posts

Joined
Mon Oct 17, 2016 2:31 pm

Post by paulfeakins » Fri Apr 21, 2017 4:49 pm

The problem is the method hasOptionPriceIncrease() is missing.

This is not a built-in OpenCart method, so we can assume it should be added by a vQmod and that it's not being added for some reason, possibly because another vQmod is already modifying that part of the file.

Try searching your vQmods for hasOptionPriceIncrease to identify which one is adding this, and then find out why it is not able to add it by looking at the "search" part of it.

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


User avatar
Guru Member

Posts

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

Post by sicario » Sat Apr 22, 2017 10:03 am

can you show me how to call the price to my category page if i have price option?

Newbie

Posts

Joined
Mon Oct 17, 2016 2:31 pm
Who is online

Users browsing this forum: No registered users and 423 guests