How-To: Use The Product Name As The Page Title Instead Of Categories :: Product Name

How to use The Product Name As The Page Title

Instead Of Categories :: Product Name

Please add:

#file - if folder structure is missing please create it

app/addons/my_changes/controllers/frontend/products.post.php

#content

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($mode == ‘view’ && !empty($_REQUEST[‘product_id’])) {
$product = Tygh::$app[‘view’]->getTemplateVars(‘product’);
if(empty($product[‘page_title’])){
//other data can be added to title dynamic also
$page_title = $product[‘product’];
Tygh::$app[‘view’]->assign(‘page_title’, $page_title);
}
}

* The modification will create the dynamic page title only for products with empty page_tile

* Tested on CS-Cart 4.8.1

PS: "My Changes" add-on needs to be active

Please feel free to ask any questions!

Keep on smiling,

---
Valentin
part of hungryweb.net

How to use The Product Name As The Page Title

Instead Of Categories :: Product Name

Please add:

#file - if folder structure is missing please create it

app/addons/my_changes/controllers/frontend/products.post.php

#content

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($mode == ‘view’ && !empty($_REQUEST[‘product_id’])) {
$product = Tygh::$app[‘view’]->getTemplateVars(‘product’);
if(empty($product[‘page_title’])){
//other data can be added to title dynamic also
$page_title = $product[‘product’];
Tygh::$app[‘view’]->assign(‘page_title’, $page_title);
}
}

* The modification will create the dynamic page title only for products with empty page_tile

* Tested on CS-Cart 4.8.1

PS: "My Changes" add-on needs to be active

Please feel free to ask any questions!

Keep on smiling,

---
Valentin
part of hungryweb.net

Hi Valentin

I followed your instructions but received an error, the site would not load any product pages. I'm using version 4.2.3. Any ideas?

Thanks

For 4.0.x / 4.1.x / 4.2.x / 4.3.x please use

#content

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($mode == ‘view’ && !empty($_REQUEST[‘product_id’])) {
$product = Registry::get(‘view’)->getTemplateVars(‘product’);
if(empty($product[‘page_title’])){
//other data can be added to title dynamic also
$page_title = $product[‘product’];
Registry::get(‘view’)->assign(‘page_title’, $page_title);
}
}

For 4.0.x / 4.1.x / 4.2.x / 4.3.x please use

#content

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($mode == ‘view’ && !empty($_REQUEST[‘product_id’])) {
$product = Registry::get(‘view’)->getTemplateVars(‘product’);
if(empty($product[‘page_title’])){
//other data can be added to title dynamic also
$page_title = $product[‘product’];
Registry::get(‘view’)->assign(‘page_title’, $page_title);
}
}

Great, thanks so much Valentin. This works perfectly! : )

For 4.0.x / 4.1.x / 4.2.x / 4.3.x please use

#content

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($mode == ‘view’ && !empty($_REQUEST[‘product_id’])) {
$product = Registry::get(‘view’)->getTemplateVars(‘product’);
if(empty($product[‘page_title’])){
//other data can be added to title dynamic also
$page_title = $product[‘product’];
Registry::get(‘view’)->assign(‘page_title’, $page_title);
}
}

Great, thanks so much Valentin. This works perfectly! : )

Hi again Valentin

I'd also like to automatically capitalize all my product titles eg. masport motor mower = Masport Motor Mower. I believe I would use UCWORDS() for this, but I'm not sure how to correctly incorporate this into the solution you have already provided above. If it's not too much trouble, are you able to show me how this is done?

Thanks in advance

: )

..

I'd also like to automatically capitalize all my product titles eg. masport motor mower = Masport Motor Mower. I believe I would use UCWORDS() for this, but I'm not sure how to correctly incorporate this into the solution you have already provided above. If it's not too much trouble, are you able to show me how this is done?..

Please use:

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($mode == ‘view’ && !empty($_REQUEST[‘product_id’])) {
$product = Tygh::$app[‘view’]->getTemplateVars(‘product’);
if(empty($product[‘page_title’])){
//other data can be added to title dynamic also
$page_title = ucwords(strtolower($product[‘product’]));
Tygh::$app[‘view’]->assign(‘page_title’, $page_title);
}
}

the only difference is:

$page_title = ucwords(strtolower($product['product']));

Hope this helps!

For 4.0.x / 4.1.x / 4.2.x / 4.3.x please use

#content

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($mode == ‘view’ && !empty($_REQUEST[‘product_id’])) {
$product = Registry::get(‘view’)->getTemplateVars(‘product’);
if(empty($product[‘page_title’])){
//other data can be added to title dynamic also
$page_title = $product[‘product’];
Registry::get(‘view’)->assign(‘page_title’, $page_title);
}
}

Great, thanks so much Valentin. This works perfectly! : )

Hi again Valentin

I'd also like to automatically capitalize all my product titles eg. masport motor mower = Masport Motor Mower. I believe I would use UCWORDS() for this, but I'm not sure how to correctly incorporate this into the solution you have already provided above. If it's not too much trouble, are you able to show me how this is done?

Thanks in advance

: )

Thank you so much Valentin, that's great. Working well. : )

that's great, thanks.

Is there a way to add also company name to the title?

like
product name | company name?

Try

$page_title = $product['product'] . ' ' .  Registry::get('settings.Company.company_name');

Can you make this work on recent cs-cart 4.12 ?

At first view, it should work. Please try

Can you make this work on recent cs-cart 4.12 ?

Yes

We have done it in past we can do it again

Are your looking for safe and secured managed digital marketing services with access to seo tools ( Similar to SEMRUSH on regular basis

Connect with us for details discussion just send us Email for proposal and Free Audit report of your website

Along with our services all cs-cart users get Worth $150

1. Advanced SEO Addon

2. SEO for Tags for creating more related pages with better SEO URL

Just Send us Email at Rajesh@gsnindia.com

We will get back with Free Audit Report of your website and Complete Digital marketing plan.

We Assure of 100% Money back if no significant changes in your organic traffic Min Time for engagement is 6 Months. Our rates are very reasonable. and affordable,

Regards

Rajesh

SEO and Ecommerce Consultant