× Here you can get community support related to ReDJ.

301 redirect Virtuemart products

More
11 years 1 month ago #761 by admin
Replied by admin on topic 301 redirect Virtuemart products
You are missing the Enterprise version... :)

Jokes apart, the new ReDJ version for Joomla 2.5 has all needed macros even in the Community
version. The old ReDJ version for Joomla 1.5 has the pre_match macro only in the Enterprise version. Even if your rule is right, it will not work for your version.

Kind regards,
Luigi

Please Log in or Create an account to join the conversation.

  • rasputin73
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 1 month ago #792 by rasputin73
Replied by rasputin73 on topic 301 redirect Virtuemart products
Hey Luigi,
I really appreciate all your help with this. ReDJ is pretty amazing. Unfortunately I still can't get the redirect to work right.

I've now upgraded to Joomla 2.5.9 running Virtuemart 2.0.18a. I also purchased ReDJ Enterprise! I'm running the new Joomla/Virtuemart on a subdirectory (/jupgrade) for now, but that will be changing as soon as this is all working.

It turns out that I need to do some database lookup to make this work since virtuemart wont allow addressing by sku, but thats all I have to reference from because of the previous sites structure.

So, just to refresh your memory on the details, the from url is structured like

www.slashntest.com/jupgrade/00973.html
www.slashntest.com/jupgrade/00034.html
www.slashntest.com/jupgrade/10023.html

These match the product sku with the leading zeros removed and the .html removed, so the sku looks like

973
34
10023

It turns out that I needed to look up those "product_sku" values in the database and find the related virtuemart_product_id

From phpmyadmin I can run this query:

SELECT `virtuemart_product_id`
FROM `j25_virtuemart_products`
WHERE `product_sku` = '973'

and it will return the proper virtuemart_product_id of 1426 . I did notice in phpmyadmin that I had to have the quotes around '973' otherwise it would return the id's of other sku
s including 00973-7, 00973-9, etc... those are my child product variants and I don't need them redirected.

I also need to lookup the category_id which looks like this as an sql query

SELECT `virtuemart_category_id`
FROM `j25_virtuemart_product_categories`
WHERE `virtuemart_product_id` = '1426'

So, for instance the "from url" of
www.slashntest.com/jupgrade/00973.html
should return a "to url" of
www.slashntest.com/jupgrade/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=1426&virtuemart_category_id=26

so it flows like this:

pattern match (5 digits followed by .html) --> remove preceding zeros --> db match that 'product_sku' to the 'virtuemart_product_id' --> db match that to 'virtuemart_category_id' --> finally start structuring the redirect itself...

forgive my syntax, but something like this:
(base url) index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id= (product) &virtuemart_category (category)

sorry to be so long winded, but I wanted to make sure I didn't leave anything out this time :) I really appreciate your help!
Thanks,
Matt

Please Log in or Create an account to join the conversation.

  • rasputin73
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 1 month ago #793 by rasputin73
Replied by rasputin73 on topic 301 redirect Virtuemart products
Oh, a combined sql query of

SELECT `virtuemart_product_id` , `virtuemart_category_id`
FROM `j25_virtuemart_product_categories`
WHERE `virtuemart_product_id` = (
SELECT `virtuemart_product_id`
FROM `j25_virtuemart_products`
WHERE `product_sku` = '973'
)

is a little cleaner. virtuemart_product_id=1426 virtuemart_category_id =26 Don't know if that helps.

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #795 by admin
Replied by admin on topic 301 redirect Virtuemart products
Hi Matt,
this is the complex trasformation that ReDJ should do until now... :)

I was building placeholders on my environment, just hold on.

Luigi

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #797 by admin
Replied by admin on topic 301 redirect Virtuemart products
Try this:
From URL: ^/jupgrade/[0-9]+\.html$
To URL: http://{siteurl}/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=${pid}&virtuemart_category_id=${cid}
Case sensitive: true
Request only: true
Decode URL: true
Placeholders:
id={preg_match 1}/\/jupgrade\/0*([0-9]+)\.html$/i{/preg_match}
pid={tableselect #__virtuemart_products,virtuemart_product_id,product_sku}${id}{/tableselect}
cid={tableselect #__virtuemart_product_categories,virtuemart_category_id,virtuemart_product_id}${pid}{/tableselect}

Please, advise.

Kind regards,
Luigi
The following user(s) said Thank You: rasputin73

Please Log in or Create an account to join the conversation.

  • rasputin73
  • Topic Author
  • Offline
  • New Member
  • New Member
More
11 years 1 month ago #804 by rasputin73
Replied by rasputin73 on topic 301 redirect Virtuemart products
Well, your most complicated redirect to so far is a huge success!

I made a minor adjustment of dropping the /jupgrade part of the url since I pointed my domain to it last night.

I was going to post what the final redirect looks like after my minor adjustment, but I can't figure out why it wont let me post the code on the forum. It keeps seeing it as an sql injection even when I put it in code brackets or quote brackets. Oh well, the only thing different is the removal of the two references to /jupgrade.

Thank you so much Luigi! You are amazing!

Please Log in or Create an account to join the conversation.

Time to create page: 0.109 seconds