logo
down
shadow

Add image to sub-category instead of text link PHP-OPENCART


Add image to sub-category instead of text link PHP-OPENCART

Content Index :

I hope this helps . Ok, think I understand what you seek.
First you need to find a controller that is responsible for category view, you can find it (I assume it's OC2) in catalog/controller/product/category.php file. Somewhere around line 160 you will see:
$data['categories'][] = array(
    'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
    'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
);
$data['categories'][] = array(
    'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
    'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
    'image'=> $result['image']
);

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Tag : php , By : scott.sizemore
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I didn't look at the site you have posted above - if you cannot describe your issue by words or by submitting a code or image it should be improved.
From what I understand you just want an infinite scroll to display all the products you have in your eshop. It is not mentioned whether you want to preserve the default functionality (category tree with products attached to certain categories) or whether you want only this one listing - basically it does not matter - so I will describe in short how to add such new functionality.

opencart 1.5.6.4 Add image in the middle of category list


Tag : development , By : Robby
Date : March 29 2020, 07:55 AM
this will help I want to show an image or banner in the middle of product category list page. So if there are 10 products in the product category list then it will show 5 product, and then the image, and then the rest 5 product. , Open this file:
catalog/view/theme/default/template/product/category.tpl
<?php foreach ($products as $product) { ?>
<?php } ?>
<?php if($i == 5){ ?>
    <p>here is place for image</p>
<?php } $i++; ?>
<?php $i = 1; foreach ($products as $product) { ?>
<div>
  <?php if ($product['thumb']) { ?>
  <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
  <?php } ?>
  <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
  <div class="description"><?php echo $product['description']; ?></div>
  <?php if ($product['price']) { ?>
  <div class="price">
    <?php if (!$product['special']) { ?>
    <?php echo $product['price']; ?>
    <?php } else { ?>
    <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
    <?php } ?>
    <?php if ($product['tax']) { ?>
    <br />
    <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
    <?php } ?>
  </div>
  <?php } ?>
  <?php if ($product['rating']) { ?>
  <div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
  <?php } ?>
  <div class="cart">
    <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
  </div>
  <div class="wishlist"><a onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a></div>
  <div class="compare"><a onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $button_compare; ?></a></div>
</div>
<?php if($i == 5){ ?>
    <p>here is place for image</p>
<?php } $i++; ?>
<?php } ?>

Tag : php , By : Joe Sweeney
Date : March 29 2020, 07:55 AM
around this issue you have directly added line $data['linked_categories'] = $linked_categories;
<?php
class ControllerProductProduct extends Controller {
private $error = array();

public function index() {
    $this->load->language('product/product');

    $data['breadcrumbs'] = array();

    $data['breadcrumbs'][] = array(
        'text' => $this->language->get('text_home'),
        'href' => $this->url->link('common/home')
    );

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

    if (isset($this->request->get['path'])) {
        $path = '';

        $parts = explode('_', (string)$this->request->get['path']);

        $category_id = (int)array_pop($parts);

        foreach ($parts as $path_id) {
            if (!$path) {
                $path = $path_id;
            } else {
                $path .= '_' . $path_id;
            }

            $category_info = $this->model_catalog_category->getCategory($path_id);

            if ($category_info) {
                $data['breadcrumbs'][] = array(
                    'text' => $category_info['name'],
                    'href' => $this->url->link('product/category', 'path=' . $path)
                );
            }
        }

        // Set the last category breadcrumb
        $category_info = $this->model_catalog_category->getCategory($category_id);

        if ($category_info) {
            $url = '';

            if (isset($this->request->get['sort'])) {
                $url .= '&sort=' . $this->request->get['sort'];
            }

            if (isset($this->request->get['order'])) {
                $url .= '&order=' . $this->request->get['order'];
            }

            if (isset($this->request->get['page'])) {
                $url .= '&page=' . $this->request->get['page'];
            }

            if (isset($this->request->get['limit'])) {
                $url .= '&limit=' . $this->request->get['limit'];
            }

            $data['breadcrumbs'][] = array(
                'text' => $category_info['name'],
                'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url)
            );
        }
    }

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

    if (isset($this->request->get['manufacturer_id'])) {
        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('text_brand'),
            'href' => $this->url->link('product/manufacturer')
        );

        $url = '';

        if (isset($this->request->get['sort'])) {
            $url .= '&sort=' . $this->request->get['sort'];
        }

        if (isset($this->request->get['order'])) {
            $url .= '&order=' . $this->request->get['order'];
        }

        if (isset($this->request->get['page'])) {
            $url .= '&page=' . $this->request->get['page'];
        }

        if (isset($this->request->get['limit'])) {
            $url .= '&limit=' . $this->request->get['limit'];
        }

        $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);

        if ($manufacturer_info) {
            $data['breadcrumbs'][] = array(
                'text' => $manufacturer_info['name'],
                'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url)
            );
        }
    }

    if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
        $url = '';

        if (isset($this->request->get['search'])) {
            $url .= '&search=' . $this->request->get['search'];
        }

        if (isset($this->request->get['tag'])) {
            $url .= '&tag=' . $this->request->get['tag'];
        }

        if (isset($this->request->get['description'])) {
            $url .= '&description=' . $this->request->get['description'];
        }

        if (isset($this->request->get['category_id'])) {
            $url .= '&category_id=' . $this->request->get['category_id'];
        }

        if (isset($this->request->get['sub_category'])) {
            $url .= '&sub_category=' . $this->request->get['sub_category'];
        }

        if (isset($this->request->get['sort'])) {
            $url .= '&sort=' . $this->request->get['sort'];
        }

        if (isset($this->request->get['order'])) {
            $url .= '&order=' . $this->request->get['order'];
        }

        if (isset($this->request->get['page'])) {
            $url .= '&page=' . $this->request->get['page'];
        }

        if (isset($this->request->get['limit'])) {
            $url .= '&limit=' . $this->request->get['limit'];
        }

        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('text_search'),
            'href' => $this->url->link('product/search', $url)
        );
    }

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

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

    $product_info = $this->model_catalog_product->getProduct($product_id);

    if ($product_info) {
        $url = '';

        if (isset($this->request->get['path'])) {
            $url .= '&path=' . $this->request->get['path'];
        }

        if (isset($this->request->get['filter'])) {
            $url .= '&filter=' . $this->request->get['filter'];
        }

        if (isset($this->request->get['manufacturer_id'])) {
            $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
        }

        if (isset($this->request->get['search'])) {
            $url .= '&search=' . $this->request->get['search'];
        }

        if (isset($this->request->get['tag'])) {
            $url .= '&tag=' . $this->request->get['tag'];
        }

        if (isset($this->request->get['description'])) {
            $url .= '&description=' . $this->request->get['description'];
        }

        if (isset($this->request->get['category_id'])) {
            $url .= '&category_id=' . $this->request->get['category_id'];
        }

        if (isset($this->request->get['sub_category'])) {
            $url .= '&sub_category=' . $this->request->get['sub_category'];
        }

        if (isset($this->request->get['sort'])) {
            $url .= '&sort=' . $this->request->get['sort'];
        }

        if (isset($this->request->get['order'])) {
            $url .= '&order=' . $this->request->get['order'];
        }

        if (isset($this->request->get['page'])) {
            $url .= '&page=' . $this->request->get['page'];
        }

        if (isset($this->request->get['limit'])) {
            $url .= '&limit=' . $this->request->get['limit'];
        }

        $data['breadcrumbs'][] = array(
            'text' => $product_info['name'],
            'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id'])
        );

        $this->document->setTitle($product_info['meta_title']);
        $this->document->setDescription($product_info['meta_description']);
        $this->document->setKeywords($product_info['meta_keyword']);
        $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
        $this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js');
        $this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css');
        $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js');
        $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
        $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');

        $data['heading_title'] = $product_info['name'];

        $data['text_select'] = $this->language->get('text_select');
        $data['text_manufacturer'] = $this->language->get('text_manufacturer');
        $data['text_linked_categories']        = 'Categories:';
        $data['text_model'] = $this->language->get('text_model');
        $data['text_reward'] = $this->language->get('text_reward');
        $data['text_points'] = $this->language->get('text_points');
        $data['text_stock'] = $this->language->get('text_stock');
        $data['text_discount'] = $this->language->get('text_discount');
        $data['text_tax'] = $this->language->get('text_tax');
        $data['text_option'] = $this->language->get('text_option');
        $data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
        $data['text_write'] = $this->language->get('text_write');
        $data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));
        $data['text_note'] = $this->language->get('text_note');
        $data['text_tags'] = $this->language->get('text_tags');
        $data['text_related'] = $this->language->get('text_related');
        $data['text_payment_recurring'] = $this->language->get('text_payment_recurring');
        $data['text_loading'] = $this->language->get('text_loading');

        $data['entry_qty'] = $this->language->get('entry_qty');
        $data['entry_name'] = $this->language->get('entry_name');
        $data['entry_review'] = $this->language->get('entry_review');
        $data['entry_rating'] = $this->language->get('entry_rating');
        $data['entry_good'] = $this->language->get('entry_good');
        $data['entry_bad'] = $this->language->get('entry_bad');

        $data['button_cart'] = $this->language->get('button_cart');
        $data['button_wishlist'] = $this->language->get('button_wishlist');
        $data['button_compare'] = $this->language->get('button_compare');
        $data['button_upload'] = $this->language->get('button_upload');
        $data['button_continue'] = $this->language->get('button_continue');

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

        $data['tab_description'] = $this->language->get('tab_description');
        $data['tab_attribute'] = $this->language->get('tab_attribute');
        $data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']);
        $data['product_id'] = (int)$this->request->get['product_id'];
        $data['manufacturer'] = $product_info['manufacturer'];
        $data['text_linked_categories'] = $this->language->get('text_linked_categories');  
        $query_linked_categories = $this->model_catalog_product->getCategories($product_id);
        $linked_categories = array();
          foreach( $query_linked_categories as $linked_category_data ) {
               $linked_category = $this->model_catalog_category->getCategory($linked_category_data['category_id']);
               $linked_category_info['id'] = $linked_category_data['category_id'];
               $linked_category_info['href'] = $this->url->link('product/category', 'path=' . $linked_category_data['category_id']);
               $linked_category_info['name'] = $linked_category['name'];
               $linked_categories[] = $linked_category_info;
           }
        $data['linked_categories'] = $linked_categories;
        $data['text_linked_categories']        = 'Categories:';
        $data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
        $data['model'] = $product_info['model'];
        $data['reward'] = $product_info['reward'];
        $data['points'] = $product_info['points'];
        $data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');

        if ($product_info['quantity'] <= 0) {
            $data['stock'] = $product_info['stock_status'];
        } elseif ($this->config->get('config_stock_display')) {
            $data['stock'] = $product_info['quantity'];
        } else {
            $data['stock'] = $this->language->get('text_instock');
        }

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

        $manufacturer_image = $this->model_catalog_manufacturer->getManufacturer($product_info['manufacturer_id']);
            if($manufacturer_image){
                $data['manufacturers_img'] = $this->model_tool_image->thumbs($manufacturer_image['image'], 30, 30);
            } else  {
            $data['manufacturers_img'] = false;
        }


        if ($product_info['image']) {
            $data['popup'] = $this->model_tool_image->thumbs($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
        } else {
            $data['popup'] = '';
        }

        if ($product_info['image']) {
            $data['thumb'] = $this->model_tool_image->thumbs($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
        } else {
            $data['thumb'] = '';
        }

        $data['images'] = array();

        $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);

        foreach ($results as $result) {
            $data['images'][] = array(
                'popup' => $this->model_tool_image->thumbs($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')),
                'thumb' => $this->model_tool_image->thumbs($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height'))
            );
        }

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

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

        if ($this->config->get('config_tax')) {
            $data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price']);
        } else {
            $data['tax'] = false;
        }

        $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);

        $data['discounts'] = array();

        foreach ($discounts as $discount) {
            $data['discounts'][] = array(
                'quantity' => $discount['quantity'],
                'price'    => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')))
            );
        }

        $data['options'] = array();

        foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) {
            $product_option_value_data = array();

            foreach ($option['product_option_value'] as $option_value) {
                if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
                    if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) {
                        $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false));
                    } else {
                        $price = false;
                    }

                    $product_option_value_data[] = array(
                        'product_option_value_id' => $option_value['product_option_value_id'],
                        'option_value_id'         => $option_value['option_value_id'],
                        'name'                    => $option_value['name'],
                        'image'                   => $this->model_tool_image->thumbs($option_value['image'], 50, 50),
                        'price'                   => $price,
                        'price_prefix'            => $option_value['price_prefix']
                    );
                }
            }

            $data['options'][] = array(
                'product_option_id'    => $option['product_option_id'],
                'product_option_value' => $product_option_value_data,
                'option_id'            => $option['option_id'],
                'name'                 => $option['name'],
                'type'                 => $option['type'],
                'value'                => $option['value'],
                'required'             => $option['required']
            );
        }

        if ($product_info['minimum']) {
            $data['minimum'] = $product_info['minimum'];
        } else {
            $data['minimum'] = 1;
        }

        $data['review_status'] = $this->config->get('config_review_status');

        if ($this->config->get('config_review_guest') || $this->customer->isLogged()) {
            $data['review_guest'] = true;
        } else {
            $data['review_guest'] = false;
        }

        if ($this->customer->isLogged()) {
            $data['customer_name'] = $this->customer->getFirstName() . '&nbsp;' . $this->customer->getLastName();
        } else {
            $data['customer_name'] = '';
        }

        $data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']);
        $data['rating'] = (int)$product_info['rating'];

        // Captcha
        if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) {
            $data['captcha'] = $this->load->controller('captcha/' . $this->config->get('config_captcha'));
        } else {
            $data['captcha'] = '';
        }

        $data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);

        $data['products'] = array();

        $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);

        foreach ($results as $result) {
            if ($result['image']) {
                $image = $this->model_tool_image->thumbs($result['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
            } else {
                $image = $this->model_tool_image->thumbs('placeholder.png', $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
            }

            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_tax')) {
                $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price']);
            } else {
                $tax = false;
            }

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

            $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, $this->config->get('config_product_description_length')) . '..',
                'price'       => $price,
                'special'     => $special,
                'tax'         => $tax,
                'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
                'rating'      => $rating,
                'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id'])
            );
        }

        $data['tags'] = array();

        if ($product_info['tag']) {
            $tags = explode(',', $product_info['tag']);

            foreach ($tags as $tag) {
                $data['tags'][] = array(
                    'tag'  => trim($tag),
                    'href' => $this->url->link('product/search', 'tag=' . trim($tag))
                );
            }
        }

        $data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']);

        $this->model_catalog_product->updateViewed($this->request->get['product_id']);

        $data['column_left'] = $this->load->controller('common/column_left');
        $data['column_right'] = $this->load->controller('common/column_right');
        $data['content_top'] = $this->load->controller('common/content_top');
        $data['content_bottom'] = $this->load->controller('common/content_bottom');
        $data['footer'] = $this->load->controller('common/footer');
        $data['header'] = $this->load->controller('common/header');

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
            $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/product.tpl', $data));
        } else {
            $this->response->setOutput($this->load->view('default/template/product/product.tpl', $data));
        }
    } else {
        $url = '';

        if (isset($this->request->get['path'])) {
            $url .= '&path=' . $this->request->get['path'];
        }

        if (isset($this->request->get['filter'])) {
            $url .= '&filter=' . $this->request->get['filter'];
        }

        if (isset($this->request->get['manufacturer_id'])) {
            $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
        }

        if (isset($this->request->get['search'])) {
            $url .= '&search=' . $this->request->get['search'];
        }

        if (isset($this->request->get['tag'])) {
            $url .= '&tag=' . $this->request->get['tag'];
        }

        if (isset($this->request->get['description'])) {
            $url .= '&description=' . $this->request->get['description'];
        }

        if (isset($this->request->get['category_id'])) {
            $url .= '&category_id=' . $this->request->get['category_id'];
        }

        if (isset($this->request->get['sub_category'])) {
            $url .= '&sub_category=' . $this->request->get['sub_category'];
        }

        if (isset($this->request->get['sort'])) {
            $url .= '&sort=' . $this->request->get['sort'];
        }

        if (isset($this->request->get['order'])) {
            $url .= '&order=' . $this->request->get['order'];
        }

        if (isset($this->request->get['page'])) {
            $url .= '&page=' . $this->request->get['page'];
        }

        if (isset($this->request->get['limit'])) {
            $url .= '&limit=' . $this->request->get['limit'];
        }

        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('text_error'),
            'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id)
        );

        $this->document->setTitle($this->language->get('text_error'));

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

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

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

        $data['continue'] = $this->url->link('common/home');

        $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');

        $data['column_left'] = $this->load->controller('common/column_left');
        $data['column_right'] = $this->load->controller('common/column_right');
        $data['content_top'] = $this->load->controller('common/content_top');
        $data['content_bottom'] = $this->load->controller('common/content_bottom');
        $data['footer'] = $this->load->controller('common/footer');
        $data['header'] = $this->load->controller('common/header');

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
            $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/error/not_found.tpl', $data));
        } else {
            $this->response->setOutput($this->load->view('default/template/error/not_found.tpl', $data));
        }
    }
}

public function review() {
    $this->load->language('product/product');

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

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

    if (isset($this->request->get['page'])) {
        $page = $this->request->get['page'];
    } else {
        $page = 1;
    }

    $data['reviews'] = array();

    $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);

    $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5);

    foreach ($results as $result) {
        $data['reviews'][] = array(
            'author'     => $result['author'],
            'text'       => nl2br($result['text']),
            'rating'     => (int)$result['rating'],
            'date_added' => ($this->language->get('code') == 'fa') ? jdate($this->config->get('config_shamsidate_format'), strtotime($result['date_added'])) : ($this->language->get('code') == 'fa') ? jdate($this->config->get('config_shamsidate_format'), strtotime($result['date_added'])) : date($this->language->get('date_format_short'), strtotime($result['date_added']))
        );
    }

    $pagination = new Pagination();
    $pagination->total = $review_total;
    $pagination->page = $page;
    $pagination->limit = 5;
    $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');

    $data['pagination'] = $pagination->render();

    $data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5));

    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/review.tpl')) {
        $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/review.tpl', $data));
    } else {
        $this->response->setOutput($this->load->view('default/template/product/review.tpl', $data));
    }
}

public function write() {
    $this->load->language('product/product');

    $json = array();

    if ($this->request->server['REQUEST_METHOD'] == 'POST') {
        if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) {
            $json['error'] = $this->language->get('error_name');
        }

        if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) {
            $json['error'] = $this->language->get('error_text');
        }

        if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) {
            $json['error'] = $this->language->get('error_rating');
        }

        // Captcha
        if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) {
            $captcha = $this->load->controller('captcha/' . $this->config->get('config_captcha') . '/validate');

            if ($captcha) {
                $json['error'] = $captcha;
            }
        }

        if (!isset($json['error'])) {
            $this->load->model('catalog/review');

            $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post);

            $json['success'] = $this->language->get('text_success');
        }
    }

    $this->response->addHeader('Content-Type: application/json');
    $this->response->setOutput(json_encode($json));
}

public function getRecurringDescription() {
    $this->language->load('product/product');
    $this->load->model('catalog/product');

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

    if (isset($this->request->post['recurring_id'])) {
        $recurring_id = $this->request->post['recurring_id'];
    } else {
        $recurring_id = 0;
    }

    if (isset($this->request->post['quantity'])) {
        $quantity = $this->request->post['quantity'];
    } else {
        $quantity = 1;
    }

    $product_info = $this->model_catalog_product->getProduct($product_id);
            $data['text_linked_categories'] = $this->language->get('text_linked_categories');

            $query_linked_categories = $this->model_catalog_product->getCategories($product_id);
            $linked_categories = array();
            foreach( $query_linked_categories as $linked_category_data ) {
                $linked_category = $this->model_catalog_category->getCategory($linked_category_data['category_id']);
                $linked_category_info['id'] = $linked_category_data['category_id'];
                $linked_category_info['href'] = $this->url->link('product/category', 'path=' . $linked_category_data['category_id']);
                $linked_category_info['name'] = $linked_category['name'];
                $linked_categories[] = $linked_category_info;
            }
    $recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id);

    $json = array();

    if ($product_info && $recurring_info) {
        if (!$json) {
            $frequencies = array(
                'day'        => $this->language->get('text_day'),
                'week'       => $this->language->get('text_week'),
                'semi_month' => $this->language->get('text_semi_month'),
                'month'      => $this->language->get('text_month'),
                'year'       => $this->language->get('text_year'),
            );

            if ($recurring_info['trial_status'] == 1) {
                $price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')));
                $trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' ';
            } else {
                $trial_text = '';
            }

            $price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')));

            if ($recurring_info['duration']) {
                $text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']);
            } else {
                $text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']);
            }

            $json['success'] = $text;
        }
    }

    $this->response->addHeader('Content-Type: application/json');
    $this->response->setOutput(json_encode($json));
}

Tag : php , By : Grant
Date : March 29 2020, 07:55 AM
this will help Step 1: Go to catalog\view\theme\THEMEACTIVE\template\product\category.tpl Find following line of code (in default theme there are in two places)
<?php foreach ($categories as $category) { ?><li>
<a href="<?php echo $category['href']; ?>">
            <img src="<?php echo $category['category_image']; ?>" />
          </a>
$data['categories'][] = array(
                'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'category_image' =>$this->model_tool_image->resize($result['image'], 200,200),

Opencart 2.3.0.2 : Category image on product pages


Tag : php , By : Mahyar Sepehr
Date : March 29 2020, 07:55 AM
Hope that helps I kinda know this should be a fairly simple thing to do, but in my opencart 2.3.0.2 webshop, I want to display the category image on product pages. , Change the category image code with below code in product controller:
if ($category_info) {
   if ($category_info['image']) {
      $data['thumbcat'] = "../image/".($category_info['image']);
   } else {
      $data['thumbcat'] = '';
   }
}
Related Posts Related QUESTIONS :
  • Pretty URL with $_GET method
  • Wordpress always load same page - index.php
  • Find value in array and return with new from different array
  • PHP multiple file upload with different keys
  • Can't modify times one a time without weird errors
  • Get size of scraped image with domcrawler (Goutte)
  • Laravel - Ordering a collection of models
  • PHP Fatal error: Uncaught Error: Call to a member function setFetchMode() on boolean
  • Strict Standards: Only variables should be passed by reference in /main_dir/sub_dir/backup.php
  • Uncaught Google_Exception: (update) unknown parameter: 'copyRequiresWriterPermission'
  • Laravel 5 form does not redirect with old input
  • How to get values greater than or equal to in Mysql database sql when its a value like 1:00 PM?
  • PHP datediff overday issue
  • Masking an auto incrementing primary key
  • How to grab a String BEFORE a certain word
  • ZF2 Routing Multiple Controllers based on route constraints
  • How to deregister/dequeue jquery.sticky.js in Elementor (Pro)?
  • How to fix errors counting words in text plain with PHP?
  • How to get View data in Laravel in custom helper or directive
  • Creating a new data entry into a database with eloquent and trying to access the variable in the url
  • How to test authentication using Laravel Dusk?
  • PHP parse_str not getting all $_GET variables
  • Variable issues in php class
  • Get orders between dates in Codeigniter
  • Eloquent Special Chars Issue
  • Keeping leading zeros column Mysql
  • Current level navigation in Wordpress
  • Add a custom text to WooCommerce cart items if the product has a specific shipping class
  • Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate
  • How do I add a new key value pair to an object in PHP?
  • Http post request to php with dart
  • How to add a route in with blade into parameters of a component
  • How can i get the source of a 777 - CHMOD php file?
  • Convert 2010-04-16 16:30:00 to "Tomorrow Afternoon"
  • How can I hide a $_GET variable to be more secured in PHP?
  • Login to Gmail Inbox using Curl?
  • Upload Excel or CSV file to MySQL with PHP
  • Outlook Marking Email as Junk Email
  • Upload an image using class.upload.php via AJAX, display image in form using jQuery
  • mysql_connect() causes page to not display (WAMP)
  • How to limit a users uploaded image size using PHP
  • What's the difference whether or not to run PHP in safe mode?
  • Logging in to a website cURL
  • Using php to create a password system with chinese characters
  • PHP is not called properly in IE using set interval function in Javascript
  • How to read pdf, ppt, xl, doc files content into a string in php/python
  • php script for currency conversion
  • In PHP... best way to turn string representation of a folder structure into nested array
  • PayPal for Indian Rupees (INR) any solution
  • PHP Deployment to Live Server
  • Ideal Multi-Developer Lamp Stack?
  • How can I save an image from a file input field using PHP & MySQL?
  • Warning: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a sort flag in
  • Connecting to external MySQL DB from a web server not running MySQL
  • Is it possible to add custom fields to a Drupal taxonomy term?
  • PHP 6.0 - Roadmap?
  • jQuery wait for ajax call to be over before continuing
  • checkUnique function?
  • How to define an n-m relation in doctrine?
  • Sort the unsorted text file and rewrite to same text file in sorted order
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com