Jump to content

Inserting a product directly in the database


Recommended Posts

Hi, people.

 

I'm moving from my OSCommerce to Prestashop and i've created my own scripts to move one database to the other. Almost everything is done, but I'm having an issue with the SEO friendly URLS, both in products and categories. I'd like to keep my OSCommerce urls to avoid adding 301 redirects in the htaccess file.

 

Now I write directly in the database:

 

update ps_product_lang set link_rewrite='$P_URL' where id_product='$P_ID' and id_shop='1'

 

This works in the sense that I go to Backoffice-> Catalog -> Products -> Seo Tab and the link displays properly, but if I put that link in a browser it won't display.

 

BUT, when I go to Backoffice-> Catalog -> Products -> Seo Tab, IF I CLICK "Save" without modifying anything then the link works.

 

I wonder what does "Save" do since htaccess is not modified and I can't find specific tables in the database to manage with SEO friendly stuff.

 

I'm new to Prestashop so I still don't know the directory and file structure, so I don't know where is the code for that "Save" button. Otherwise I could check what it does.

 

Any ideas?

 

Thanks in advance.

 

Sergio

Edited by serpeal79 (see edit history)
Link to comment
Share on other sites

Hi again. As I wrote before, the thing is that I want to change the SEO friendly URL for products writing directly in the database.

 

Example of a product with ID 1:

 

By thefault, the friendly URL for this product is:

 

etapa-bhm-amp-1000dsp-2x500w-rms-4-ohms

 

But I want to keep my OSCommerce URL, so I write directly in the database the url I want:

 

update ps_product_lang set link_rewrite='etapa-bhm-amp-1000dsp-2x500w-rms-ohms-p' where id_product='1' and id_shop='1'

 

Now I go to Backoffice-> Catalog -> Products -> Seo Tab and I see that my URL has been properly changed:

 

etapa-bhm-amp-1000dsp-2x500w-rms-ohms-p

 

Regular expressions for SEO friendly URL for products:

 

{rewrite}-{id}.html

 

So the browser should show the product in the url:

 

etapa-bhm-amp-1000dsp-2x500w-rms-ohms-p-1.html

 

But the browser do not show anything. I'm still in Backoffice-> Catalog -> Products -> Seo Tab and if I click "Save" then the browser show the product with the previous link, tough I have not changed anything in Backoffice, just clicked "Save".

 

I have gone further and I've dumped a copy of the database before clicking "Save" and after clicking it and except update dates there are no changes, so the button "Save" don't do anything in the database if there are no changes (except updates dates).

 

The .htaccess file is not modified at all, so I thought the issue should be in the cache system, so I cleaned smarty cache but the problem persists. So the problem seems not no be in the database, neither in the htaccess file, neither in the smarty cache.... I'm getting out of ideas.

 

Any help?

Edited by serpeal79 (see edit history)
Link to comment
Share on other sites

SOLVED

 

I've realized that when I go to Backoffice-> Catalog -> Products -> Seo Tab there is an information section that says: 

 

"

El enlace del producto será visualizado como
http://192.168.1.2/~serpeal/prestashop/etapa-bhm-amp-1000dsp-2x500w-rms-ohms-p -1.html

"

English translation should be something similar to "The link will look like".

 

And I've realized that there is an space after p  "-p -1.html"

 

It is interesting but there is no space in the friendly URL field neither in the database (I searched the database with PhpMyAdmin and there is no space).

 

I've enabled prestashop debugging and when I put the link WITHOUT THE SPACE in the browser I get this:

 

"

[Debug] This page has moved
Please use the following URL instead: http://192.168.1.2/~serpeal/prestashop/etapa-bhm-amp-1000dsp-2x500w-rms-ohms-p -1.html

"

 

WITH AN SPACE!

 

I get the OSCommerce URL from a php file with a wget command and it seems that I get the URL with an invisible control character at the end.

 

I've solved this just removing that control character.

 

Cheers.

Edited by serpeal79 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...