Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] Ultimate SEO URLs v2.1 - by Chemo


Recommended Posts

On 10/20/2018 at 3:39 PM, BrockleyJohn said:

Actually, now that you/they bring it up, I've a feeling that Chemo's class doesn't close the connection (while of course the core db functions do that via application_bottom). So you have a double saving - one connection instead of two and nothing left hanging around after the page is built.

@BrockleyJohn couple of days now and there's not been any max_user_connections warnings after modifying the code you provided. I'm going to watch the error logs further to see what happens.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

@Jack_mcs the database function for seo.class.php that John supplied several posts back looks to have taken care of the warnings I was seeing in my error log.

For you consideration for the next update.

Thx..SK

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

Hello,

Google search engine post results of old URLs of my website, after some readings, Google advise to redirect all none found URLs to 404 Not Found, my osc2.3.4 is redirecting all none found links to 404 Not Found unless the link contain index.php

e.g. www.domain.com/asdasda  redirect to 404 Not Found, good

but

e.g. www.domain.com/index.php/asdadasd redirect to home page instead  - This is a problem, Search engines keeps those wrong URLs as valid

PLEASE HELP, I have people who search for product A on Google, end up at home page instead of product page.

I think this redirection is cause by this code

 // Ultimate SEO URLs v2.2d
 if ((!defined(SEO_ENABLED)) || (SEO_ENABLED == 'true')) {
   include_once('includes/classes/seo.class.php');
   if ( !is_object($seo_urls) ){
     $seo_urls = new SEO_URL($languages_id);
   }
 }

Hope you can advise. Thanks

Link to comment
Share on other sites

@PsytaniumThis isn't a problem with this addon as you've mentioned in another post that you had turned it off. Please don't cross-post.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

2.3.4.1 CE and PHP 7.0

I installed this contribution in late September and had no issues that I'm aware of until now.

I've stumbled upon a product that has a valid SEO url when moused over, like...

mysite.com/name-of-product-p-4245.html

When I click on it, the URL in the browser loads as mysite.com/-p-0.html

And I get D'oh.  Product Not Found!

The item looks fine in the database in both the Products and Products Description tables. 

It looks fine in the Admin side where I create and maintain items. 

The only thing I can think of is that the item was turned off from view when I put it up for auction, but it will not load after turning it back on. 

Any idea what could be happening?  I've reset the SEO URLS cache hoping that might clear it up, but no luck. 

- Andrea

 

Link to comment
Share on other sites

@puggybelleIf it is just happening with that one product, then it seems like it would have to be a problem with that product. If you have the cache option set for the shop (configuration->cache), that might be doing it.  You could try using the uninstall option to see if that helps.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@Jack_mcs

Cache is set to false.  I have no idea what may have happened.  Item looks fine in the database.

I deleted the item and created it anew...with the same product title, same everything...but generating a new product ID number on the end...

And it STILL wouldn't load!  Product Not Found!

I deleted it again...changed the product title to something else...and now it loads.  Very bizarre.

Out of curiosity, what happens when you choose the Uninstall option in the SEO config page in Admin?

Or I guess I should ask...what do you have to do afterward to get it back?  I was too timid to try it.

- Andrea

Link to comment
Share on other sites

@puggybelle

1 hour ago, puggybelle said:

@Jack_mcs

I deleted the item and created it anew...with the same product title, same everything...but generating a new product ID number on the end...

And it STILL wouldn't load!  Product Not Found!

I deleted it again...changed the product title to something else...and now it loads.  Very bizarre.

What was the original product title? By chance, did it have any unusual characters in it?

M

Link to comment
Share on other sites

@ArtcoInc

No, nothing unusual.  Looked like all my others.  No funky characters or anything.

I think you know my site...all of my titles are formatted the same.  Date-name-keywords

Like...11-4-18-Name-Of-Product-Keyword-Keyword-p-4545.html

Something got corrupted, but I definitely didn't see anything wrong with the product in the database.  And I stared at it more than a few times. 

I'm just glad I stumbled upon it.  I clicked on the item just to retrieve the large photo (right click/save) for something else and that's when I discovered it wouldn't load.  Otherwise, it would be sitting out there like that...Product Not Found!...for eternity.  My fear is...are there more? 

With thousands of products there's no way I can just sit here and click thru them all to make sure they load. 

I had some issues with my webhost in recent months and I'm wondering if one of those sudden MySQL disconnects during editing may have done me in on that particular item.  I just don't know.  I have no memory or having problems with that item at any time.

I have had the experience of suffering a disconnect during editing and watching an item disappear.  Only the image remains.  The description and title vanish.  But, this one is really strange as it looked fine in both Admin and the database.  Nothing missing.  Nothing changed.

And it wouldn't let me duplicate the product name after deleting the original.  I think that's just bizarre.

- Andrea

 

Link to comment
Share on other sites

5 hours ago, puggybelle said:

Out of curiosity, what happens when you choose the Uninstall option in the SEO config page in Admin?

It removes all of the database changes for the addon, including its cache. When the site is visited, the settings are added back in. If you have altered its settings and do an uninstall. then you will have to change them back to what you want. Since you mentioned above that your url's have two-characters words in them, you will need to change the short word setting.

If the name of the product is only two characters and you had the setting set to the default 3, then that might be the cause of the problem. Though you should have seen that before so it is unlikely the reason.

But since you have narrowed it down to the name, you could duplicate that product and use the duplicate to edit the name one character at a time to get back to the original name to see if you can get it to fail. But I think it is more likely that the original name had a corrupted character in it that was causing it to fail.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@Jack_mcs

I don't believe there was a wonky character in the title.  All of my titles are the same, in the way they're formatted.  Just numbers and text.

I'm going to hope that it was one of those crap moments I experienced with my webhost until they put me on a different server when I raised hell.

My item descriptions that I migrated over from 2.2 were loaded with css code that was killing the extra description from appearing when browsing by category.

I've been manually editing and stripping that code for a couple of months now, one item at a time in Admin.  Got thru 100 or so today.  It's ongoing.

I'm clicking around fast and furious and I haven't run into it again, so...I just have to hope it was one of those abrupt disconnects in the past that may have somehow whacked that item.  I'll never know and that blows.  Hope I don't see anymore of it. 

Thanks for the explanation of the uninstall.  I took that entry literally...like, UNINSTALL.  WIPE IT OUT.  And start over if you wish to have it.  Oh, well.  It's a great tool and I'm glad to have it!

- Andrea

Link to comment
Share on other sites

@Jack_mcs

I'm sorry.  This is what happens when posting late at night.

I have a question about the Reset SEO URLs Cache feature.

Is that something that should be done every so often or only when you have a problem?

I remember installing this and some things were not working and when I did that, it cleared up all of my trouble immediately.

Should I use that feature on a regular basis or let it sit?  Thank You!

- Andrea

Link to comment
Share on other sites

8 hours ago, puggybelle said:

I don't believe there was a wonky character in the title.  All of my titles are the same, in the way they're formatted.  Just numbers and text.

I meant something that you couldn't see. I've seen it happen quite a bit when converting databases with other languages from old shops to new ones. The characters were only visible by looking at the data in the database. I know this isn't exactly the situation you are going through but an invalid entry is possible.

 

8 hours ago, puggybelle said:

I have a question about the Reset SEO URLs Cache feature.

Is that something that should be done every so often or only when you have a problem?

It's OK to do that if you do not have many products. The way the cache system in this addon was written can cause a large slowdown when it initially runs for sites with many products. There's no set number to go by since it also depends on the server. But if there has been a problem like this where something was, apparently, corrupted it would be a good idea to clear the cache.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 1 month later...

A new version has been uploaded with these changes:

  • Added code to prevent a strict warning. Found by member @altoid.
  • Changed instructions to give a warning in php 7 and would cause a failure in php 8.
  • Changed more code for compatibility with php 7.2 - add by member @raiwa.

See the update file for a change needed in the application_top.php file. Also, I suggest you check the settings for this addon. While they shouldn't have changed I find that one of the biggest things overlooked is the short word filter. Most shop owners, in my experience, leave it set at 3, which may be correct. But if the shop has names that are less than 3 characters. the url may not be as you want and may even be incorrect. For example, if you sell a product named "Ring size 7" and another named "Ring size 8", both will appear as "Ring size" and could be confusing to your customers.

 

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@Jack_mcs Happy New Year! I trust you haven't worked all the way through.

A good tip on the settings - it reminds me; one of my clients has the feature to add exceptions to the short words filter, and it's been such a long time I can't remember where it came from. Used it to be part of the addon, or was it extended for them?

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

@BrockleyJohn I don't remember an option like that and if it was a setting I wouldn't have deleted it, at least not on purpose. So it must have been something someone code for him.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

It's simple enough. The setting code (placed after the length of the short word filter) is:

                $this->default_config['SEO_URLS_FILTER_SHORT_WORDS_EXCEPT'] = array('DEFAULT' => '',
                                      'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, 'Filter Short Words Except', 'SEO_URLS_FILTER_SHORT_WORDS_EXCEPT', '', 'Exclude these words from the short words filter.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, NULL)");
                $x++;

and the filter method becomes:

        function short_name($str, $limit=3){
                $container = array();
                if ( $this->attributes['SEO_URLS_FILTER_SHORT_WORDS'] != 'false' ) $limit = (int)$this->attributes['SEO_URLS_FILTER_SHORT_WORDS'];
				$except = (defined('SEO_URLS_FILTER_SHORT_WORDS_EXCEPT') ? explode(',',strtoupper(SEO_URLS_FILTER_SHORT_WORDS_EXCEPT)) : array());
                $foo = @explode('-', $str);
                foreach($foo as $index => $value){
                        switch (true){
                                case ( strlen($value) <= $limit ):
                                        if (count($except) == 0 || !in_array(strtoupper($value),$except)) 
											continue;
                                default:
                                        $container[] = $value;
                                        break;
                        }                
                } # end foreach

                $container = ( sizeof($container) > 1 ? implode('-', $container) : (sizeof($container) > 0 ? $container[0] : $str ));
                return $container;
        }
        

 

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

Thanks for posting it. I've never had anyone ask for such an option but it may be.  Can you give an example of some words that would be skipped?

I recommend moving the count($except) above the loop so it doesn't have to be counted on each pass.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

5 hours ago, Jack_mcs said:

Thanks for posting it. I've never had anyone ask for such an option but it may be.  Can you give an example of some words that would be skipped?

I recommend moving the count($except) above the loop so it doesn't have to be counted on each pass.

Good point with the count.

It comes from a shop that sells DJ equipment, filters 2 letter words, and excludes 'DJ' and some  manufacturer-specific model suffixes that are separated from the rest of the model by a dash (eg. SX, RX, SR, RR), preserving phrases like

DJ controller, DJ mixer (because the DJ is a very important search qualifier)

and models like DDJ-SX, DDJ-SR, DDJ-RR and DDJ-RX, which are different bits of kit that would otherwise all just come out as DDJ in the link while people talking about them will just call them SX, SR and so on

I don't remember their reason not to allow all 2 letter words but I do recall a discussion as their list grew longer about putting in an alternative feature to this filter exclusion list, a list of noise words that would always be filtered, but when thinking of examples that noise list rapidly became bigger and they decided to keep it as it is.

If setting a suitable word length works for a store, it's clearly a lot easier to maintain than a list of exclusions that you have to bear in mind as you add new products. Whatever your settings, my advice is to remember that SEO is not an implementation issue - but an ongoing development process. You need to keep looking at all aspects of it and make sure that your settings are sensible for your current shop catalogue. If you change the URL settings remember to reset the cache and if it's an established site that's already indexed make sure your product and category pages include a canonical tag to avoid duplicate content issues.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

I sell DVDs with several different volumes i.e.

DVD Volume 1  DVD Volume 2  DVD Volume 3 and so forth

I have to change these to One, Two, Three etc.

This code change could be useful for short numbers if required.

Edited by mhsuffolk

Live shop Phoenix 1.0.8.4 on PHP 7.4 Working my way up the versions.

Link to comment
Share on other sites

8 minutes ago, mhsuffolk said:

I sell DVDs with several different volumes i.e.

DVD Volume 1  DVD Volume 2  DVD Volume 3 and so forth

I have to change these to One, Two, Three etc.

This code change could be useful for short numbers if required.

Martin, you might be better off with a small change to the standard filter:

        function short_name($str, $limit=3){
                $container = array();
                if ( $this->attributes['SEO_URLS_FILTER_SHORT_WORDS'] != 'false' ) $limit = (int)$this->attributes['SEO_URLS_FILTER_SHORT_WORDS'];
                $foo = @explode('-', $str);
                foreach($foo as $index => $value){
                        switch (true){
                                case ( strlen($value) <= $limit && (! is_numeric($value)) ):
                                        continue;
                                default:
                                        $container[] = $value;
                                        break;
                        }                
                } # end foreach

                $container = ( sizeof($container) > 1 ? implode('-', $container) : (sizeof($container) > 0 ? $container[0] : $str ));
                return $container;
        }

ie. don't filter any numbers - the change is in the case line in the switch

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

6 hours ago, BrockleyJohn said:

It comes from a shop that sells DJ equipment, filters 2 letter words, and excludes 'DJ'

If I'm understanding you correctly, you are saying that "DJ controller" would just show "controller". If that is correct, I think it would hurt the results a little since "controller" can be applied to many things other than DJ equipment. Of course, it is only in the url so it won't make a big difference but I would consider it.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...