Find out the source of the error

So here is my site which I am trying to build with opencart. Now I needed functionality for users to check the available areas for the pincode. Since there will be COD in only authorized pincodes, but there will be no rest. So simple. I just found a plugin for this.

I added the file and the back-end worked, however my front-end got stuck and gave this error:

Fatal error: Call to undefined method ModelCatalogProduct::getProductCart() in /home1/thewebsi/public_html/opencarttemp/catalog/controller/module/related.php on line 24

      

Now, I am really new to opencart, so I cannot figure out where I am going wrong. Here is the related.php file by the way.

<?php
class ControllerModuleRelated extends Controller {
    protected function index($setting) {
        $this->language->load('module/related');

        $this->data['heading_title'] = $this->language->get('heading_title');

        $this->data['button_cart'] = $this->language->get('button_cart');

        $this->load->model('catalog/product');

        $this->load->model('tool/image');

        $limit = $setting['limit'];

        if (isset($this->request->get['product_id'])) {
            $product_id = (int)$this->request->get['product_id'];
        } else {
            $product_id = 0;
        }

            $this->data['products'] = array();

            $results = $this->model_catalog_product->getProductCart($product_id);
            $i = 0;
            foreach ($results as $result) {
                if ($result['image']) {
                $image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']);
                } else {
                    $image = false;
                }

                if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                    $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
                } else {
                    $price = false;
                }

                if ((float)$result['special']) {
                    $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
                } else {
                    $special = false;
                }

                if ($this->config->get('config_review_status')) {
                    $rating = (int)$result['rating'];
                } else {
                    $rating = false;
                }

                $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']),
                );
                    if (++$i == $limit) break;

            }   

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/related.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/module/related.tpl';
        } else {
            $this->template = 'default/template/module/related.tpl';
        }

        $this->render();
    }
}
?>

      

If anyone can only guide me on how to debug this, I can do it. And before I forget, here is the plugin link: http://www.opencart.com/index.php?route=extension/extension/info&extension_id=15386&filter_search=pincode

UPDATE: The bug has now changed to the following, without making or changing:

Fatal error: Class 'Controllermodulerelated' not found in /home1/thewebsi/public_html/opencarttemp/vqmod/vqcache/vq2-system_engine_controller.php on line 41

      

UPDATE 2: Here is the getProductCart function in the ModelCatalogProduct class.

<?php
class ModelCatalogProduct extends Model {
//Code
public function getProductCart($product_id) {
        $product_data = array();

        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");

        foreach ($query->rows as $result) { 
            $product_data[$result['related_id']] = $this->getProduct($result['related_id']);
        }

        return $product_data;
    }
//Code
?>

      

+3


source to share





All Articles