If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Access product pages with ..main_page=product_info&products_model= instead product_id

Access product pages with ..main_page=product_info&products_model= instead product_id

Locked

Started by tj1 on 22 May 2007, 5:29 AM · Views: 3,036

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
22 May 2007, 5:29 AM
#1
tj1 avatar

tj1

Totally Zenned

Join Date:
Mar 2005
Location:
California
Posts:
628
Plugin Contributions:
0

Post #1 by tj1

I have a couple of questions.

First, I'd like to know what code needs to be changed in order to be able to access product pages with products_model in addition to products_id; e.i., 'myzcstore.com/index.php?main_page=product_info&products_model=model_here'

I list links to all products in many third-party sites. I have thousands of products and I often delete and add new products, so it's a pain having to update all links on third-party sites with the new or changed products_id.
If I could provide links with the format 'myzcstore.com/index.php?main_page=product_info&products_model=modelhere, things would be much easier as model doesn't change and I don't have to know the id.

Now my other question is, do you think this is a good idea, do you know if search engines would penalize my site for having products accessible from two links ('myzcstore.com/index.php?main_page=product_info&products_id=id_here' and 'myzcstore.com/index.php?main_page=product_info&products_model=modelhere') ?

Thanks for any input on this.

22 May 2007, 6:26 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #2 by kobra

product_ID is a database table/record so to change this to model# would require re-writing the cart code and altering the DB

This is in at least 300 places

Zen-Venom Get Bitten

22 May 2007, 12:26 PM
#3
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Post #3 by a_berezin

To access product info pages by link

myzcstore.com/index.php?main_page=product_info&products_model=modelhere

you need to setting up products_id by the products_model:

  if (!isset($_GET['products_id']) && isset($_GET['products_model'])) {
    $_GET['products_model'] = zen_db_prepare_input($_GET['products_model']);
    $get_products_id = $db->Execute("SELECT products_id FROM " . TABLE_PRODUCTS . " WHERE products_model='" . zen_db_input($_GET['products_model']) . "' LIMIT 1");
    if($get_products_id->EOF)
      $_GET['products_id'] = 0;
    else
      $_GET['products_id'] = $get_products_id->fields['products_id'];
  }

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

22 May 2007, 4:55 PM
#4
tj1 avatar

tj1

Totally Zenned

Join Date:
Mar 2005
Location:
California
Posts:
628
Plugin Contributions:
0

Post #4 by tj1

Kobra, yes, that would be a lot of work, but luckily that's not really what I want, I don't want to replace products_id with products_model everywhere in my site, that would be crazy.

Currently links I provide to my products are like this:
myzcstore.com/index.php?main_page=product_info&products_id=id_here

I just would like to also be able to provide links like this
myzcstore.com/index.php?main_page=product_info&products_model=model_here

I believe I only need to change/add code in one place, just haven't figured out which file yet.

Being able to use products_model makes it much easier to provide product urls.

22 May 2007, 5:03 PM
#5
tj1 avatar

tj1

Totally Zenned

Join Date:
Mar 2005
Location:
California
Posts:
628
Plugin Contributions:
0

Post #5 by tj1

a_berezin, thanks for that code.

Actually I already had similar code using a function that DrByte provided, zen_get_products_id_from_model, I just don't know where to put the code.

Can you tell me which file I need to put this in?

Thanks.

23 May 2007, 7:47 PM
#7
tj1 avatar

tj1

Totally Zenned

Join Date:
Mar 2005
Location:
California
Posts:
628
Plugin Contributions:
0

Post #7 by tj1

Awesome! Thanks so much Andrew!
It works great.

This will save me hours and hours of work, I won't have to spend time updating links again. :)

I'm sure this will come in very handy to everyone who provides links to their products on other sites, especially for the ones with lots of products.

Now just regarding my second question, does anyone know if search engines would penalize my site for having products accessible from two different urls ('myzcstore.com/index.php?main_page=product_info&products_id=id_here' and 'myzcstore.com/index.php?main_page=product_info&products_model=modelhere') ?

I really don't know much about how search engines work, but I don't think this would have any effect. I have done several searches on google and yahoo and couldn't find anything mentioning this so I guess it's probably ok, right?