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 } ?>
No comments:
Post a Comment