SEO - Product Suffix

If it doesn't quite fit in the other areas, put it here...
User avatar
Mort_Lemur
Builder
Posts: 137
Joined: Tue Jun 02, 2026 6:12 pm
Phoenix Version: v1.1.0.6
Has thanked: 71 times
Been thanked: 45 times

SEO - Product Suffix

Post by Mort_Lemur »

Hi,

I have been looking recently at SEO, inspired by a post by @14Steve14.

I have noticed that Phoenix Cart appears to append the store name to product page titles. For example, the rendered title is:
This is my product Title which can be quite long | MY SITE NAME
The suffix isn’t in the product’s SEO title field, and I’ve seen the same behavior on the Phoenix demo when looking at the page source. As our store name is 18 characters, it can make product titles quite long, which is not really ideal for SEO which recommends product titles of around 50 - 60 characters (although no hard limit is set).

As I don't want to start altering core files, Is there a supported, update-safe way to remove the store-name suffix on product pages while keeping it on other pages? (eg Category pages) Would you recommend changing a setting, configuring the header-tags module, or using another approach such as an override?

Thanks :)



Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4748
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 282 times
Been thanked: 470 times

Re: SEO - Product Suffix

Post by burt »

A hook would do it, I think.
Minimal code, 1 new file.

Otherwise
Make a copy of the header tag module, stripping out the separator and other bits that you don't want.
Uninstall core HT module
Install your own new HT module
Minimal(ish) code, 2 new files (as the new HT would need a language file)

Either of these gets the result you want, no core code changes.

Probably simplest, remake the HT module, 5 minutes?
Hook way, you need to find the right injection point, make the hook, test it, etc. Probably slightly more work in the long run.
I am not here to build for you.
I am here to build with you. Let's help each other.

Omar_one
Senior Contributor
Posts: 693
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 103 times
Been thanked: 62 times

Re: SEO - Product Suffix

Post by Omar_one »

I was also reflecting on that, and having some free time today, I put together the following thoughts after reading Burt's response.

Code: Select all

<?php
/*
  $Id$

  CE Phoenix, E-Commerce made Easy
  https://phoenixcart.org

  Copyright (c) 2026 Phoenix Cart

  Released under the GNU General Public License
*/

  class ht_custom_product_title extends abstract_module {

    const CONFIG_KEY_BASE = 'MODULE_HEADER_TAGS_CUSTOM_PRODUCT_TITLE_';

    protected $group = 'header_tags';

    function execute() {
      global $product;

      if (isset($_GET['products_id'], $product) && (basename(Request::get_page()) === 'product_info.php') && $product->get('name')) {
        $product_title = ((MODULE_HEADER_TAGS_CUSTOM_PRODUCT_TITLE_SEO_TITLE_OVERRIDE === 'True') && (!Text::is_empty($product->get('seo_title')))
          ? $product->get('seo_title')
          : $product->get('name'));

        // Check if removal of store suffix is enabled
        if (defined('MODULE_HEADER_TAGS_CUSTOM_PRODUCT_TITLE_REMOVE_SUFFIX') && MODULE_HEADER_TAGS_CUSTOM_PRODUCT_TITLE_REMOVE_SUFFIX === 'True') {
          $GLOBALS['Template']->set_title($product_title);
        } else {
          // Use available separator or fallback safely
          $separator = defined('MODULE_HEADER_TAGS_PAGES_SEO_SEPARATOR') ? MODULE_HEADER_TAGS_PAGES_SEO_SEPARATOR : ' | ';
          $GLOBALS['Template']->set_title($product_title . $separator . $GLOBALS['Template']->get_title());
        }
      }
    }

    protected function get_parameters() {
      return [
        $this->config_key_base . 'STATUS' => [
          'title' => 'Enable Custom Product Title Module',
          'value' => 'True',
          'desc' => 'Do you want to allow custom product titles to be added to the page title?',
          'set_func' => "Config::select_one(['True', 'False'], ",
        ],
        $this->config_key_base . 'REMOVE_SUFFIX' => [
          'title' => 'Remove Store Suffix on Product Pages',
          'value' => 'True',
          'desc' => 'Do you want to remove the global store name suffix specifically on product pages?',
          'set_func' => "Config::select_one(['True', 'False'], ",
        ],
        $this->config_key_base . 'SORT_ORDER' => [
          'title' => 'Sort Order',
          'value' => '0',
          'desc' => 'Sort order of display. Lowest is displayed first.',
        ],
        $this->config_key_base . 'SEO_TITLE_OVERRIDE' => [
          'title' => 'SEO Title Override?',
          'value' => 'True',
          'desc' => 'Do you want to allow product titles to be over-ridden by your SEO Titles (if set)?',
          'set_func' => "Config::select_one(['True', 'False'], ",
        ],
      ];
    }

  }

Code: Select all

<?php
/*
  $Id$

  CE Phoenix, E-Commerce made Easy
  https://phoenixcart.org

  Copyright (c) 2026 Phoenix Cart

  Released under the GNU General Public License
*/

const MODULE_HEADER_TAGS_CUSTOM_PRODUCT_TITLE_TITLE = 'Custom Product Title (No Store Suffix)';
const MODULE_HEADER_TAGS_CUSTOM_PRODUCT_TITLE_DESCRIPTION = 'Adds product names or SEO titles to the page title on product info pages without appending the global store name suffix.';



Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply