Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Redirecting one URL to another in order to move from old software to Zen Cart

    Good day everyone,

    I'm new as a registered member, but I've been lurking for awhile.

    My problem is as follows:
    I have a webshop running on Quick.Cart and I want to move it to Zen-Cart.
    Going pretty well, design is nearly done, I can copy the database over, but..

    I want to redirect the query string Quick.Cart used, to the query string Zen-Cart uses, this to not lose my page rankings.

    This is an example of a query string from quick.cart:
    ?p=productsMore&iProduct=[number]&sName=[productname]

    I'd have to move the info over to Zen-Cart's query strings like so:
    ?main_page=product_info&cPath=[pathnumber]&products_id=[number]
    (Edit: forgot to mention that the idea numbers will be the same for both carts)

    I see that zen-cart will find the product without a cPath set, so that shouldn't be too much of a problem (or is there a way to retrieve the correct cPath number from the database before redirecting?). The sName query string would have to be dropped.

    Can anyone help? I've searched google up and down, and found alot of query string to static url help in .htaccess and php, but I have no idea how to use that for query string to query string redirecting.

  2. #2
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Redirecting one URL to another in order to move from old software to Zen Cart

    This could be fairly easy for you to achieve, depending on how complex the old URLS become.

    The following code will do roughly what you need, with a little tweaking. Where you put it depends on the level of PHP experience, and how involved in Zen you are. If you want to keep to Zen standards, then you may want to create a new config file, and then include this in a init_includes folder.

    If you just need it to work, open up the index.php file in the root directory, and paste it after the

    include('includes/application_top.php');

    Include the following code:
    Code:
    <?php
    if (isset($_GET['iProduct']) && (int)$_GET['iProduct'] > 0) {
      $iProducts_id = (int)$_GET['iProduct'];
      zen_redirect(zen_href_link(zen_get_info_page($iProducts_id), 'cPath=' . zen_get_product_path($iProducts_id).'&products_id='.$iProducts_id));
    }
    ?>
    That is it!

    Good luck,

    Absolute

  3. #3
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Redirecting one URL to another in order to move from old software to Zen Cart

    Sorry for the late reply.

    Thanks a bunch, that worked exactly like I needed.
    I added "Header( "HTTP/1.1 301 Moved Permanently" ); " before the last line so it now marks the links as moved permanently.

    What was the tweaking bit you mentioned? Since it worked right immediately.

    Is there also a way to do this for categories?
    the old category urls are like this:
    ?p=productsList&iCategory=[number]&sName=[name]

    So again, the name can be discarded, and the number will be the same for the old url and the new one. Is there a way to get the position of a category and redirect it the same way as the products urls?

    I've made a miserable attempt with:
    Code:
    if (isset($_GET['iCategory']) && (int)$_GET['iCategory'] > 0) {
      $iCategory_id = (int)$_GET['iCategory'];
      Header( "HTTP/1.1 301 Moved Permanently" );
      zen_redirect('index.php?main_page=index&' . zen_get_path($iCategory_id));
    }
    But that just redirects directly to the category itself, without the categories it's in.
    By that I mean, category 4 is a subcategory of 3, but using that code it'll end up as cPath=4, instead of cPath=3_4.

    Hope you can help oncemore.

  4. #4
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Redirecting one URL to another in order to move from old software to Zen Cart

    That should be the correct code for redirecting to a category. Can you post a link so we can take a look at the code working on your store?

    Absolute

  5. #5
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Redirecting one URL to another in order to move from old software to Zen Cart

    Thanks for the quick reply >)

    I only have an old, very feature incomplete version on the web at the moment, the version I'm working is on the network here. But, I put the code in the old version's index.php, so it's at least viewable for you.

    (btw, I don't want that version indexed, so I put "<meta name="robots" content="noindex, nofollow" />" in the header, that should be enough, right?)

    I changed the code to:
    Code:
    if (isset($_GET['iCategory']) && (int)$_GET['iCategory'] > 0) {
      $iCategory_id = (int)$_GET['iCategory'];
      Header( "HTTP/1.1 301 Moved Permanently" );
      zen_redirect(zen_href_link(index) . '&' . zen_get_path($iCategory_id));
    }
    But that's basically the same, and didn't help.
    Thing is, it does redirect, it just doesn't find the category's main category, if there is one.

    For example, category number 66 is in category 2, so it should be cPath="2_66", but it ends up as cPath="66".

    Testable here:
    http://www.sjaakshobbyshop.nl/Develo...p?iCategory=66
    And where it should go:
    http://www.sjaakshobbyshop.nl/Develo...dex&cPath=2_66

    Thanks again :)

  6. #6
    Join Date
    Apr 2007
    Location
    Herts. UK
    Posts
    890
    Plugin Contributions
    4

    Default Re: Redirecting one URL to another in order to move from old software to Zen Cart

    Hi,

    To rebuild the cPath from the category id you will need to do something like...
    PHP Code:
    if (isset($_GET['iCategory']) && (int)$_GET['iCategory'] > 0) {
      
    $current_category_id = (int)$_GET['iCategory'];
      
    $rebuild_categories = array();
      
    zen_get_parent_categories($rebuild_categories$current_category_id);
      
    $rebuild_categories array_reverse($rebuild_categories);
      
    $cPath implode('_'$rebuild_categories);
      if (
    zen_not_null($cPath)) $cPath .= '_';
      
    $cPath .= $current_category_id;
      
    header ("HTTP/1.1 301 Moved Permanently");
      
    zen_redirect(zen_href_link("index","cPath=".$cPath));

    Hope that helps.

    Regards,
    Christian.

  7. #7
    Join Date
    Jan 2008
    Posts
    43
    Plugin Contributions
    0

    Default Re: Redirecting one URL to another in order to move from old software to Zen Cart

    Quote Originally Posted by CJPinder View Post
    Hi,

    To rebuild the cPath from the category id you will need to do something like...
    PHP Code:
    ... 
    Hope that helps.

    Regards,
    Christian.
    That worked magnificently, thanks a bunch. Not used to such fast and Helpful posts from a community, it's a firm reassurance for using Zen-Cart to me.

    One more question, you said "something like", do you mean there could be problems with the code, or shouldn't I take it that literally?

    Thanks again :)

  8. #8
    Join Date
    Apr 2007
    Location
    Herts. UK
    Posts
    890
    Plugin Contributions
    4

    Default Re: Redirecting one URL to another in order to move from old software to Zen Cart

    Quote Originally Posted by Diavire View Post
    One more question, you said "something like", do you mean there could be problems with the code, or shouldn't I take it that literally?
    There shouldn't be any problems with the code. I have been using something similar for quite awhile without issues. I said "something like" just to cover myself in case I had made any typos

    Glad you got it working.

    Regards,
    Christian.

  9. #9
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Redirecting one URL to another in order to move from old software to Zen Cart

    You'll find anyone that posts code snippets is always a little relaxed about it - "something like...." - "try....." - "maybe something like....." - "perhaps....."

    We've all posted code in the past to help out, and then when you do, someone is far to quick to point out that you have a typo and so assume that you haven't tested the code, or even know what you're talking about. And that's why the code never really comes with any guarantees.

    My advise, always check any code thoroughly before you copy ANYTHING, and make sur to ask questions if you spot anything you are unsure of.

    As for helpful posts and a fast community - that's just one of the great things about Zen - welcome aboard!

    Absolute

 

 

Similar Threads

  1. v139h Move order from one shop to shoppingbasket in another shop?
    By danfeld in forum Managing Customers and Orders
    Replies: 0
    Last Post: 25 Apr 2012, 11:12 PM
  2. Redirecting one zen cart to another during payment
    By dionb85 in forum General Questions
    Replies: 3
    Last Post: 13 Jan 2010, 02:30 AM
  3. Is it easy to move the zen-cart from a machine to another?
    By atmosx in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 18 Nov 2009, 06:09 PM
  4. Move an Order from one customer to another
    By lynbor in forum General Questions
    Replies: 1
    Last Post: 11 Jan 2007, 04:39 PM
  5. Using Easy Populate to move to zen from another cart?
    By tdsjulie in forum Basic Configuration
    Replies: 1
    Last Post: 15 Jul 2006, 09:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR