VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: marvays on April 12, 2019, 06:40:50 AM

Title: manufacturer in product name on product detail page
Post by: marvays on April 12, 2019, 06:40:50 AM
Hi. for SEO i need update my template. I have problem. How I add manufacturer inot this code?
I need the manufacturer's name before the product name in the h1 tag.
I've tried many variations, but none worked.

<?php // Product Title ?>
<h1 class="FlexibleProductDetailProductName"><?php echo $this->product->product_name ?></h1>
<?php // Product Title END ?>
Title: Re: manufacturer in product name on product detail page
Post by: marvays on April 12, 2019, 06:53:54 AM
And maybe even add product_mpn.

So the resulting shape would be "manufacturer product name product_mpn"
Can anybody help me, please?
Title: Re: manufacturer in product name on product detail page
Post by: Ghost on April 12, 2019, 08:41:46 AM
<?php echo $this->product->mf_name ' ' $this->product->product_name ' ' $this->product->product_mpn?>
Title: Re: manufacturer in product name on product detail page
Post by: marvays on April 12, 2019, 09:25:39 AM
Thx very much.
I need to edit the <title> tag to make the work perfect. To make the product detail the same.
Title: Re: manufacturer in product name on product detail page
Post by: Ghost on April 12, 2019, 09:37:49 AM
Normally you should use plugins to set things like metadata. But for your own purposes you can add this to the template override:

JFactory::getDocument()->setTitle('Your Title Here');

Or you can set custom title when editing the product.
Title: Re: manufacturer in product name on product detail page
Post by: marvays on April 12, 2019, 09:58:17 AM
Know you any good plugins? I need change it for all product page automatically. I only use sh404sef and there is very limited SEO.
Title: Re: manufacturer in product name on product detail page
Post by: marvays on April 12, 2019, 11:42:20 AM
Ok. Found it.

// Set the titles
// $document->setTitle should be after the additem pathway
if ($product->customtitle) {
$document->setTitle(strip_tags(html_entity_decode($product->customtitle,ENT_QUOTES)));
} else {
$catName = '';
if($category->published and !empty($category->category_name)){
$catName = $category->category_name.': ';
}
$document->setTitle(strip_tags(html_entity_decode($catName . $product->product_name,ENT_QUOTES)));
}