VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Topic started by: Stephen Roberts on December 02, 2011, 00:30:59 am

Title: Revision 4902 slug problem
Post by: Stephen Roberts on December 02, 2011, 00:30:59 am
If you haven't caught this yet, there is a problem with slugs (at least on the categories). It appears that the date is being tacked onto the slug on every store to database. Example:

1. Edit category "Music" with current slug "music"
2. Hit apply. Slug is now "music2011-12-01-23-29-553"
3. Hit apply again. Slug is now "music2011-12-01-23-29-5532011-12-01-23-30-306"
Title: Re: Revision 4902 slug problem
Post by: Stephen Roberts on December 02, 2011, 02:09:35 am
FYI, I'm using Joomla! 1.5 for this.

It appears the problem is that it's not checking whether this is a new category or an existing category. Here's how I fixed it:

Change (line 434 in vmtable.php):

Code: [Select]
$q = 'SELECT `'.$slugName.'` FROM `'.$this->_tbl.'` WHERE `'.$slugName.'` =  "'.$this->$slugName.'" ';
to

Code: [Select]
$q = 'SELECT `'.$slugName.'` FROM `'.$this->_tbl.'` WHERE `'.$slugName.'` =  "'.$this->$slugName.'" AND `virtuemart_category_id`!='.$this->virtuemart_category_id;
You guys might have a better way though.
Title: Re: Revision 4902 slug problem
Post by: Milbo on December 02, 2011, 09:45:01 am
A thanks. I think people wonder how that happened.

Due the multilanguage the slug is most time in the lang table now, I added a check, should work now.

The idea of stephenroberts does not work, because the query would return nothing, when the slug is used elsewhere.
Title: Re: Revision 4902 slug problem
Post by: Stephen Roberts on December 02, 2011, 16:52:31 pm
Hmm, it seemed to work to me in both the case where you add a new category or edit an existing category. I'm interested to see how you decided to solve the problem. Thanks!
Title: Re: Revision 4902 slug problem
Post by: Stephen Roberts on December 02, 2011, 17:39:46 pm
I see what you're talking about now. If you're editing a category and try to name it the same as an existing category then no, it won't add a suffix to the slug the way I did it. I'll try to think through all cases next time instead of the first thing that works for me.  ;)
Title: Re: Revision 4902 slug problem
Post by: Milbo on December 02, 2011, 18:49:40 pm
oh stephenroberts, you did a good job. Finally after some months I got the real problem we had all time with it. So dont excuse yourself for doing the right thing.