Custom post type category, taxonomy and URL rewrite problem

I’m fairly new to wordpress and I’m working on a website which has an abundant category of products.
I want to create a custom post type to add a bunch of products. I’m going to demonstrate what I am trying to achieve and then elaborate on the problems I have faced.

Here is my requirements:

  1. I need to categorize my products by brand and functionality and it needs to be translated to:

by brand:

example.com/products/sub-category/product-name
eg. domain.com/products/toshiba/toshiba-E-Studio-2518A

by functionality:

example.com/products/functionality-category/product-name
eg. domain.com/products/color-printer/toshiba-E-Studio-2518A

As you can see in the example above, the product is categorized under more than one category.

  1. I need each of these categories and taxonomies to have an archive page (or any page that contains all of the relevant posts)

eg. domain.com/products/toshiba/ -> show all toshiba products

eg. domain.com/products/color-printer/ -> show all color printers

eg. domain.com/products/ -> show all products

What I have tried so far:

  • First I tried creating it using CPT ui, I used categories in my custom posts and it solved 50% of the problem. but then the URL slug of the category cannot be as same as the custom post slug.
  • I created a plugin so I could have more control, still no luck.Followed this article and many more to be honest

I’m having a tough time with this issue for almost a week now and really cannot find a solution to it, so I would appreciate some help.

thanks