lat9 / usu

Ultimate SEO URLs for Zen Cart
GNU General Public License v3.0
1 stars 5 forks source link

Is There A Way For URL Rewrite Based on Dropdown Filter Results? #33

Closed Pan2020 closed 3 years ago

Pan2020 commented 5 years ago

I had been thinking about this for a while.

On product listing page, you can see filter on the top of the list.

image

"Filter Results by:" is the dropdown menu I am talking about.

Currently the URL rewrite only go up to the point of the listing... https://homepromedical.com/cart/mobility-c-41/ https://homepromedical.com/cart/mobility-c-41/powered-wheelchairs-c-41_6/ https://homepromedical.com/cart/mobility-c-41/powered-wheelchairs-c-41_6/standard-powerchairs-c-41_6_61/

However, once I start to use the filter, it does not rewrite. https://homepromedical.com/cart/mobility-c-41/powered-wheelchairs-c-41_6/standard-powerchairs-c-41_6_61/?sort=20a&filter_id=6 (Used "Pride" manufacturer as filter)

The website also has the alternate navigation by browse from Manufacturer listing. https://homepromedical.com/cart/manufacturers_all.html https://homepromedical.com/cart/pride-m-6.html

But once filter applied, it does not rewrite. https://homepromedical.com/cart/pride-m-6.html?sort=20a&filter_id=61 (Category 61 for "Standard Powered Wheelchairs," same category as above example.

I do wonder if there is a way to rewrite URL in such that it allow rewrite based on filters?

Browse by Categories https://homepromedical.com/cart/mobility-c-41/powered-wheelchairs-c-41_6/standard-powerchairs-c-41_6_61/pride-m-6

Browse by Manufacturer https://homepromedical.com/cart/pride-m-6/standard-powerchairs-c-61 (OR "standard-powerchairs-c-41_6_61" if it is not possible to rewrite down to just "c-61").

It's simply because the SEO company kept asking for "Static Pages" on such filters (A list of product of certain category AND manufacturer, e.g. "Pride Standard Powerchair")... It's get to the point that it made me rather annoyed about it.

lat9 commented 5 years ago

What version of Zen Cart and what version of USU? What are your configuration settings for Ultimate URLs?

Pan2020 commented 5 years ago

image image

lat9 commented 5 years ago

I'll note that I'm unable to reproduce the categories' cascading links like your store has. Using the settings that you posted and using (albeit 155f) a demo-products install, the link that's generated for

image is http://localhost/zc155fusu/action-c-3_10/ (note that it's a single-category name included in the link).

You're confusing a categories/products' listing from a manufacturer's listing. A manufacturer's listing is indicated when the &manufacturers_id variable is supplied and results in a -m- suffixed link's generation.

In addition, those 'filter' variables have no bearing on the link's transformation. What drives USU is the presence of &manufacturers_id, &cPath and &products_id variables in the href-link request.

While USU will use both a -c- (category) and -p- (product) designation in a generated link (to identify a specific product), there's no concept of inter-linking a category with a manufacturer in the generated link.

Pan2020 commented 5 years ago

The Cascading Menu is from the Simple Category Tree Plugin. https://www.zen-cart.com/downloads.php?do=file&id=1797

So there is no way I can make static links for such manufacturer and categories combined? Since it seems that is the most demanding links and easiest to send email when referred to a specific recommendation.

Here are the current prime keywords I needed to make for static pages:

·       Pride mobility scooter
·       Invacare hospital bed mattress
·       Probasics wheelchair
·       Pride electric scooter
·       Pride power lift chair
·       Protekt mattress

I wonder is there a way like when use the filter, use the supply filter with selected ID to get name and make the URL after Zen Cart engine processed the information?

lat9 commented 5 years ago

There's always a way (it's open-source software); the combination of a categories/manufacturer just isn't provided by the base version of USU.

Pan2020 commented 5 years ago

I looked into code on how it works... so I see this particular block.

                // -----
                // A 'cPath' parameter is normally included on listing pages (for the categories' listings).
                //
                case 'cPath':
                    switch (true) {
                        case ($p2[1] == ''):
                            // Do nothing if cPath is empty
                            break;

                        case ($page == FILENAME_DEFAULT):
                            // Change $p2[1] to the actual category id
                            $tmp = strrpos($p2[1], '_');
                            if ($tmp !== false) {
                                $p2[1] = substr($p2[1], $tmp+1);
                            }

                            $category = $this->get_category_name($p2[1]);
                            if (USU_CATEGORY_DIR == 'off') {
                                $url = $this->make_url($page, $category, $p2[0], $p2[1], USU_END, $separator);
                            } else {
                                $url = $this->make_url($page, $category, $p2[0], $p2[1], '/', $separator);
                            }
                            unset($category);
                            break;

                        default:
                            $link_params[] = $valuepair;
                            break;
                    }
                    break;

                case 'manufacturers_id':
                    switch (true) {
                        case ($page == FILENAME_DEFAULT && !$this->is_cPath_string($params) && !$this->is_product_string($params)):
                            $url = $this->make_url($page, $this->get_manufacturer_name($p2[1]), $p2[0], $p2[1], USU_END, $separator);
                            break;

                        // -----
                        // If the current 'page' requested is a 'product_[something_]info', don't add the parameter.
                        //
                        case (preg_match('/product_(\S+_)?info/', $page)):
                            break;

                        default:
                            $link_params[] = $valuepair;
                            break;
                    }
                    break;

After that, I disabled the USU to see how the links will work based on index.php dynamic links.

Manufacturer Navigation:
https://homepromedical.com/cart/index.php?main_page=manufacturers_all
https://homepromedical.com/cart/index.php?main_page=index&manufacturers_id=6
https://homepromedical.com/cart/index.php?main_page=index&manufacturers_id=6&sort=20a&filter_id=61

Category Navigation:
https://homepromedical.com/cart/index.php?main_page=index&cPath=41
https://homepromedical.com/cart/index.php?main_page=index&cPath=41_6
https://homepromedical.com/cart/index.php?main_page=index&cPath=41_6_61
https://homepromedical.com/cart/index.php?main_page=index&cPath=41_6_61&sort=20a&filter_id=6

In both cases, it is the filter_id that supply which ID to filter. So I do think there is a way, if there is a case statements...

If cPath and filter_id exist, than filter_id is manufacturer. If manufacturers_id and filter_id exist, than filter_id is categories.

Then process SQL to get those category/manufacturer names that you surely have methods on those already implemented (for categories and manufacturers separately.)

But surely, there are more than just that block involved since links are generated from dynamic link processed with index.php of Zen Cart module.

So, it seem that you are saying, only way I can achieve is by manually do everything and implement code stuffs by myself?

lat9 commented 5 years ago

So, it seem that you are saying, only way I can achieve is by manually do everything and implement code stuffs by myself?

Yes.