Reputation: 1190
I have this site and I want to put some in header for SEO purposes. The H1 must contain manufacturer name (brand) and product code (model).
So the problem is that I'm not sure how to put this variables in controller's file so I could call them in template file next.
Any ideas? :)
Upvotes: 3
Views: 7379
Reputation: 1190
Did it! Added this code to controller/common/header.php
if (isset($this->request->get['product_id'])) {
$product_id = $this->request->get['product_id'];
} else {
$product_id = 0;
}
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($product_id);
$this->data['product_info'] = $product_info;
if ($product_info) {
$this->data['manufacturer'] = $product_info['manufacturer'];
$this->data['model'] = $product_info['model'];
}
And this to theme/default/template/common/header.tpl
<?php echo $product_info['manufacturer']; ?> <?php echo $product_info['model']; ?>
Upvotes: 0
Reputation: 15151
The best way around this would be to edit the product controller
catalog/controller/product/product.php
and change the heading there. It's set with
$this->document->setTitle($product_info['name']);
so you just need to prepend/append the manufacturer name there, such as
$this->document->setTitle($product_info['name'] . ' ' . $product_info['manufacturer']);
Upvotes: 1