Showing posts with label How to get product thumb in meta head for facebook opencart. Show all posts
Showing posts with label How to get product thumb in meta head for facebook opencart. Show all posts

Monday 2 March 2015

Get product thumb in header opencart


Get product thumb in header opencart

Open the catalog/controller/common/header.php

Insert the following code :

if (isset($this->request->get['product_id'])) {
    $this->load->model('catalog/product');
    $this->load->model('tool/image');
    $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
    $this->data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
    } else {
    $this->data['thumb'] = FALSE;
}

Now open catalog/view/theme/YOUR_TEMPLATE/template/common/header.tpl and insert the meta tag in head section

<?php if ($thumb) { ?>
<meta property="og:image" content="<?php echo $thumb; ?>"/>
<?php } ?>