Jump to content

Recommended Posts

Brilliant effort!

One item stands out that really should've been a core inclusion, is an HTML editor for descriptions, IMHumbleO. Something like CKEditor, depending on suitability with jquery, PHP7/8 etc.

 

Share this post


Link to post
Share on other sites

Here is the code for Category SEO. It will add 1 query to every pageload. I will do another one each for manufacturers and products.

    function execute() {
      global $PHP_SELF, $oscTemplate, $current_category_id, $languages_id;

      if ( (basename($PHP_SELF) == 'index.php') && ($current_category_id > 0) ){
            $categories_query = tep_db_query("select categories_name, categories_seo_title, categories_seo_description, categories_seo_keywords from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$current_category_id . "' and language_id = '" . (int)$languages_id . "' limit 1");
            if (tep_db_num_rows($categories_query) > 0) {
              $categories = tep_db_fetch_array($categories_query);
			  if (tep_not_null($categories['categories_seo_title'])) {	
                $oscTemplate->setTitle($categories['categories_seo_title'] . ', ' . STORE_NAME);
			  } else {
				$oscTemplate->setTitle($categories['categories_name'] . ', ' . STORE_NAME);  
			  }

			  if ( tep_not_null($categories['categories_seo_description']) ) {
			    $oscTemplate->addBlock('<meta name="description" content="' . tep_output_string($categories['categories_seo_description']) . '" />', $this->group);			    
			  }
			  if ( tep_not_null($categories['categories_seo_keywords']) ) {
			    $oscTemplate->addBlock('<meta name="keywords" content="' . tep_output_string($categories['categories_seo_keywords']) . '" />', $this->group);
		  }
        }
      }
    }

 

Share this post


Link to post
Share on other sites

Manufacturers.

    function execute() {
      global $PHP_SELF, $oscTemplate, $languages_id;

      if (basename($PHP_SELF) == FILENAME_DEFAULT) {
        if (isset($_GET['manufacturers_id']) && is_numeric($_GET['manufacturers_id'])) {

            $manufacturers_query = tep_db_query("select m.manufacturers_name, mi.manufacturers_seo_title, mi.manufacturers_seo_description, mi.manufacturers_seo_keywords from " . TABLE_MANUFACTURERS . " m, " . TABLE_MANUFACTURERS_INFO . " mi where m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and mi.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and mi.languages_id = '" . (int)$languages_id . "'");

            if (tep_db_num_rows($manufacturers_query)) {
              $manufacturers = tep_db_fetch_array($manufacturers_query);

			  if (tep_not_null($manufacturers['manufacturers_seo_title'])) {	
                $oscTemplate->setTitle($manufacturers['manufacturers_seo_title'] . ', ' . STORE_NAME);
			  } else {
				$oscTemplate->setTitle($manufacturers['manufacturers_name'] . ', ' . STORE_NAME);  
			  }

			  if ( tep_not_null($manufacturers['manufacturers_seo_description']) ) {
			    $oscTemplate->addBlock('<meta name="description" content="' . tep_output_string($manufacturers['manufacturers_seo_description']) . '" />', $this->group);			    
			  }
			  if ( tep_not_null($manufacturers['manufacturers_seo_keywords']) ) {
			    $oscTemplate->addBlock('<meta name="keywords" content="' . tep_output_string($manufacturers['manufacturers_seo_keywords']) . '" />', $this->group);
		      }		  
          }
        }
      }
    }

 

Share this post


Link to post
Share on other sites

Products.

    function execute() {
      global $PHP_SELF, $oscTemplate, $languages_id, $product_check;

      if (basename($PHP_SELF) == FILENAME_PRODUCT_INFO) {
        if (isset($_GET['products_id'])) {
          if ($product_check['total'] > 0) {
            $product_info_query = tep_db_query("select pd.products_name, pd.products_seo_title, pd.products_seo_description, pd.products_seo_keywords from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
            $product_info = tep_db_fetch_array($product_info_query);

			  if (tep_not_null($product_info['products_seo_title'])) {	
                $oscTemplate->setTitle($product_info['products_seo_title'] . ', ' . STORE_NAME);
			  } else {
				$oscTemplate->setTitle($product_info['products_name'] . ', ' . STORE_NAME);  
			  }

			  if ( tep_not_null($product_info['products_seo_description']) ) {
			    $oscTemplate->addBlock('<meta name="description" content="' . tep_output_string($product_info['products_seo_description']) . '" />', $this->group);			    
			  }
			  if ( tep_not_null($product_info['products_seo_keywords']) ) {
			    $oscTemplate->addBlock('<meta name="keywords" content="' . tep_output_string($product_info['products_seo_keywords']) . '" />', $this->group);
			  }
          }
        }
      }
    }

 

Share this post


Link to post
Share on other sites

In the SQL installer, there are 2 php8 errors:

Warning: Undefined array key "install"

  switch ($_GET['install']) {

this is the section of code:

  switch ($_GET['install']) {
    case ('new'):
      install_ORP_to_sql();
      tep_redirect(tep_href_link($filename));
      break;
    case ('remove'):
      $group_id = get_group_id($contrib);
      remove_keys($group_id);
      remove_group_id($contrib);
      remove_table();
      tep_redirect(tep_href_link($filename));
      break;
    case ('upgrade'):
      $group_id = get_group_id($contrib);
      remove_keys($group_id);
      install_ORP_to_sql($group_id);
      tep_redirect(tep_href_link($filename));
      break;
  }

And

Fatal error: Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, bool given in

if (sizeof($group_id_array <= 1)) {
  function get_group_id($config_title) {
    $group_id_array = tep_db_fetch_array(tep_db_query("SELECT configuration_group_id FROM " . TABLE_CONFIGURATION_GROUP . " WHERE configuration_group_title like '". $config_title . "'"));	
    if (sizeof($group_id_array <= 1)) {
      return $group_id_array['configuration_group_id'];
    }
    remove_group_id($contrib);
    return 0;
  }

 

Share this post


Link to post
Share on other sites

if (is_array($group_id_array) && sizeof($group_id_array <= 1)) {

Should really be...

if (is_array($group_id_array) && sizeof($group_id_array) <= 1) {

 

 

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Share this post


Link to post
Share on other sites

Try this for the first one.

switch (isset($_GET['install'])) {

or

switch ((isset($_GET['install']) ? $_GET['install'] : null)) {

 

 


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Share this post


Link to post
Share on other sites
16 minutes ago, Demitry said:

Try this for the first one.

switch (isset($_GET['install'])) {

or

switch ((isset($_GET['install']) ? $_GET['install'] : null)) {

 

 

The first one works to clear the error. The other one I will look at again tomorrow.

Share this post


Link to post
Share on other sites

tep_get_products_name

tep_get_products_description

tep_get_products_url

  function tep_get_products_name($product_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);

	return $product['products_name'] ?? '';
  }

  function tep_get_products_description($product_id, $language_id) {
    $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);

	return $product['products_description'] ?? '';
  }

  function tep_get_products_url($product_id, $language_id) {
    $product_query = tep_db_query("select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);


	return $product['products_url'] ?? '';
  }

I am starting to use ?? - null coalescing operator

https://www.tutorialspoint.com/php7/php7_coalescing_operator.htm

Which means the code is no longer compatible with php versions < 7.

Share this post


Link to post
Share on other sites
On 10/9/2021 at 11:21 AM, Hotclutch said:

https://www.dropbox.com/s/4kre1hbg36c8ao6/W3-osC Seo Meta Tags.zip?dl=0

-> Category & Manufacturer Descriptions.

-> Category, Manufacturer, Product Titles and Meta.

That completes SEO Meta Tags for W3-osC. Follow the instructions in the package.

There's an error in categories.php

              tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed, products_seo_title, products_seo_description, products_seo_keywords) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");

Should be:

              tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed, products_seo_title, products_seo_description, products_seo_keywords) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0', '" . tep_db_input($description['products_seo_title']) . "', '" . tep_db_input($description['products_seo_description']) . "', '" . tep_db_input($description['products_seo_keywords']) . "')");

Also the instruction for functions/general.php has been amended (for php8).

Step 5:

catalog/admin/includes/functions/general.php

Add before the closing ?>
// BOF SEO Meta Tags W3-osC
  function tep_get_category_description($category_id, $language_id) {
    $category_query = tep_db_query("select categories_description from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
    $category = tep_db_fetch_array($category_query);

    return $category['categories_description'] ?? '';
  }
  
  function tep_get_manufacturer_description($manufacturer_id, $language_id) {
    $manufacturer_query = tep_db_query("select manufacturers_description from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'");
    $manufacturer = tep_db_fetch_array($manufacturer_query);

    return $manufacturer['manufacturers_description'] ?? '';
  }
  
  function tep_get_category_seo_description($category_id, $language_id) {
    $category_query = tep_db_query("select categories_seo_description from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
    $category = tep_db_fetch_array($category_query);

    return $category['categories_seo_description'] ?? '';
  }
  
  function tep_get_category_seo_keywords($category_id, $language_id) {
    $category_query = tep_db_query("select categories_seo_keywords from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
    $category = tep_db_fetch_array($category_query);

    return $category['categories_seo_keywords'] ?? '';
  }
  
  function tep_get_category_seo_title($category_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $category_query = tep_db_query("select categories_seo_title from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
    $category = tep_db_fetch_array($category_query);

    return $category['categories_seo_title'] ?? '';
  }
  
  function tep_get_manufacturer_seo_description($manufacturer_id, $language_id) {
    $manufacturer_query = tep_db_query("select manufacturers_seo_description from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'");
    $manufacturer = tep_db_fetch_array($manufacturer_query);

    return $manufacturer['manufacturers_seo_description'] ?? '';
  }
  
  function tep_get_manufacturer_seo_keywords($manufacturer_id, $language_id) {
    $manufacturer_query = tep_db_query("select manufacturers_seo_keywords from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'");
    $manufacturer = tep_db_fetch_array($manufacturer_query);

    return $manufacturer['manufacturers_seo_keywords'] ?? '';
  }
  
  function tep_get_manufacturer_seo_title($manufacturer_id, $language_id) {
    $manufacturer_query = tep_db_query("select manufacturers_seo_title from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'");
    $manufacturer = tep_db_fetch_array($manufacturer_query);

    return $manufacturer['manufacturers_seo_title'] ?? '';
  }
  function tep_get_products_seo_description($product_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $product_query = tep_db_query("select products_seo_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);

    return $product['products_seo_description'] ?? '';
  }
  
  function tep_get_products_seo_keywords($product_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $product_query = tep_db_query("select products_seo_keywords from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);

    return $product['products_seo_keywords'] ?? '';
  }
  
  function tep_get_products_seo_title($product_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $product_query = tep_db_query("select products_seo_title from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);

    return $product['products_seo_title'] ?? '';
  }
// EOF SEO Meta Tags W3-osC

Package updated.

Share this post


Link to post
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

×