Jump to content

Does not change the Meta Title Price automaticly


veltors

Recommended Posts

This is complete nonsense. This is not the right solution.
Leave the meta title in the product administration without price and add the product price to the tpl template in the head meta.

Link to comment
Share on other sites

Add price to page (open graph protocol) meta title:

./themes/classic/templates/catalog/product.tpl

(change classic to your theme)

1. find

<meta property="og:title" content="{$page.meta.title}">

2. replace to (price with tax)

<meta property="og:title" content="{$page.meta.title}{if $product.show_price} - {$product.price_amount} {$currency.iso_code}{/if}">

or

2. replace to (price without tax)

<meta property="og:title" content="{$page.meta.title}{if $product.show_price} - {$product.price_tax_exc} {$currency.iso_code}{/if}">

===================================================

If you want the meta title to be automatically generated from the product name, edit the codes as follows:

1. find

<meta property="og:title" content="{$page.meta.title}">

2. replace to (price with tax)

<meta property="og:title" content="{$product.name}{if $product.show_price} - {$product.price_amount} {$currency.iso_code}{/if}">

or

2. replace to (price without tax)

<meta property="og:title" content="{$product.name}{if $product.show_price} - {$product.price_tax_exc} {$currency.iso_code}{/if}">

 

Edited by Guest (see edit history)
Link to comment
Share on other sites

Add price to page  meta title:

./themes/classic/templates/catalog/product.tpl

(change classic to your theme)

1. find

<link rel="canonical" href="{$product.canonical_url}">

2. add after (price with tax)

<title>{$page.meta.title}{if $product.show_price} - {$product.price_amount} {$currency.iso_code}{/if}</title>

or

2. add after (price without tax)

<title>{$page.meta.title}{if $product.show_price} - {$product.price_tax_exc} {$currency.iso_code}{/if}</title>

===================================================

If you want the meta title to be automatically generated from the product name, edit the codes as follows:

1. find

<link rel="canonical" href="{$product.canonical_url}">

2. add after (price with tax)

<title>{$product.name}{if $product.show_price} - {$product.price_amount} {$currency.iso_code}{/if}</title>

or

2. add after (price without tax)

<title>{$product.name}{if $product.show_price} - {$product.price_tax_exc} {$currency.iso_code}{/if}</title>

========================================================

or another Add price to page  meta title:

./themes/classic/templates/_partials/head.tpl

(change classic to your theme)

1. find

<title>{block name='head_seo_title'}{$page.meta.title}{/block}</title>

2. replace to (price with tax + product name)

<title>{block name='head_seo_title'}{if $page.page_name == 'product'}{$product.name}{if $product.show_price} - {$product.price_amount} {$currency.iso_code}{else}{$page.meta.title}{/if}{/block}</title>

or

2. replace to (price without tax + product name)

<title>{block name='head_seo_title'}{if $page.page_name == 'product'}{$product.name}{if $product.show_price} - {$product.price_tax_exc} {$currency.iso_code}{else}{$page.meta.title}{/if}{/block}</title>

 

obrazek.png

Edited by Guest (see edit history)
Link to comment
Share on other sites

When you use {$product.name} in your code, you don't have to change the meta title in the product detail or in the database!

If you want to change the name of the meta title in the database for all products, just write a small script, save it in the root of the prestashop and run it from the URL.

(file name = update-product-meta-title.php) = URL https://your-domain.com/update-product-meta-title.php

Change your-domain.com to your domain !!!

<?php

    require_once(dirname(__FILE__).'/config/config.inc.php');    
    
    $get_products = Db::getInstance()->executeS('select id_product, id_shop, id_lang, name FROM '._DB_PREFIX_.'product_lang ORDER BY id_product');
                                              
    foreach ($get_products as $data) {
        Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product_lang set meta_title = '."'".$data['name']."'".' WHERE id_product = '.$data['id_product'].' AND id_shop = '.$data['id_shop'].' AND id_lang = '.$data['id_lang']);
    }

update-product-meta-title.php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...