URL Validation
Posted: Sun Jun 22, 2014 1:41 am
URL validation in OpenCart has troubled me for a while so today in response to another thread I went ahead and finished this vQmod. The goal is to validate urls to make sure they are valid according to the following rule set:
1. product cannot be followed by anything
2. information cannot be followed by anything
3. manufacturer can only be followed by a product and must not exist more than once
4. a category can only be followed by another category or a product
5. a product must belong to adjacent category or manufacturer present in url
6. categories must belong to parents in order of appearance in url
I've done some preliminary testing and so far so good. If anyone finds bugs or has ideas for improvements please let me know!
Cheers
UPDATE: With a bit of feedback, more thorough testing and a slew of bug fixes this seems to be working as it should.
I've added a setting called ""allow_parents" to support product category validation for either all parent categories or only the directly assigned category. For instance, if product "cinema-display" belongs only to category "monitors" which is a subcategory of "desktops":
desktops/monitors/cinema-display will always be valid
If "allow_parents" is set to "true" then
desktops/cinema-display will also be valid.
If set to false then a url path ending in "cinema-display" will only be valid if immediately preceeded by "monitors". so:
monitors/cinema-display will be valid and but
desktops/cinema-display will not.
1. product cannot be followed by anything
2. information cannot be followed by anything
3. manufacturer can only be followed by a product and must not exist more than once
4. a category can only be followed by another category or a product
5. a product must belong to adjacent category or manufacturer present in url
6. categories must belong to parents in order of appearance in url
I've done some preliminary testing and so far so good. If anyone finds bugs or has ideas for improvements please let me know!
Cheers
UPDATE: With a bit of feedback, more thorough testing and a slew of bug fixes this seems to be working as it should.
I've added a setting called ""allow_parents" to support product category validation for either all parent categories or only the directly assigned category. For instance, if product "cinema-display" belongs only to category "monitors" which is a subcategory of "desktops":
desktops/monitors/cinema-display will always be valid
If "allow_parents" is set to "true" then
desktops/cinema-display will also be valid.
If set to false then a url path ending in "cinema-display" will only be valid if immediately preceeded by "monitors". so:
monitors/cinema-display will be valid and but
desktops/cinema-display will not.