Jump to content
HA!*!*Y

[Free Php Script] Export Ps 1.4 To 1.5 Import Format

Recommended Posts

I needed to import my products from PS 1.4 to PS 1.5 I looked at lot of modules for it. They all were not working for me so i just made my own little script for it.

 

I hope it can be of some use to others

 

Remember i was exporting from 1.46 to 1.5.3

 

To Install all you need to do is open the file and edit than upload it to your server you should rename the file so others cant find it.

 

your shop directory

define('MY_ROOT_DIR','/');

 

you product folder url

you site . com/img/p/');

 

you category folder url

you site . com/img/c/');

 

your Language ID that you want to export for

define('LANG_ID', 1);

 

You should just leave it as ` (grave accent)

because its the one character that i never used in my product information.

define('FIELD_SEPARATOR', '`');

 

This is to shift all categories id

down one because of the new root category

define('CAT_ID_OFSET', 1);

 

export_ps14_v2.1

-fixed the mySQL table prefix error

 

 

Don't forget to delete it after your done its not password protected so any one could download your information

export_ps14.php

export_ps14_v2.php

export_ps14_v2.1.php

Edited by HA!*!*Y (see edit history)
  • Like 3

Share this post


Link to post
Share on other sites

just to confirm, this module extracts products and categories from your PS1.4 store to a "CSV" file, that can then be used to import into your PS1.5 store?

 

Thanks for sharing!

Share this post


Link to post
Share on other sites

@bellini13

 

yes, its for exporting CSV file from 1.4 to import with PS 1.5

 

Its not a module its a stand alone script

 

I am working on combinations, customers, addresses import functions today

Share this post


Link to post
Share on other sites

I am working on combinations, customers, addresses import functions today

 

Hi there

 

Did you manage to succeed with the script for customers, and possibly orders?

 

Having tried to upgrade, the best I can do is to get to 1.4.10.0, any movement to 1.5.3 breaks the image display and accessories. I figure that a completely fresh installation will work, but I don't want to affect existing customer logins and their previous order information.

 

Thanks

Share this post


Link to post
Share on other sites

Help, script don`t work for me.

 

 

Query Error: SELECT p.*, pl.name, GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR ",") as categories, p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, pl.description_short, pl.description, pl.meta_title, pl.meta_keywords, pl.meta_description, pl.link_rewrite, pl.available_now, pl.available_later, p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition FROM product p LEFT JOIN product_lang pl ON (p.id_product = pl.id_product) LEFT JOIN category_product cp ON (p.id_product = cp.id_product) LEFT JOIN category_lang cl ON (cp.id_category = cl.id_category) WHERE pl.id_lang = 6 AND cl.id_lang = 6 GROUP BY p.id_product

Table 'shop_base.product' doesn't exist

 

May be issue a SQL query, how to fix this problem ?

Edited by daixing (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Help, script don`t work for me.

 

 

Query Error: SELECT p.*, pl.name, GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR ",") as categories, p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, pl.description_short, pl.description, pl.meta_title, pl.meta_keywords, pl.meta_description, pl.link_rewrite, pl.available_now, pl.available_later, p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition FROM product p LEFT JOIN product_lang pl ON (p.id_product = pl.id_product) LEFT JOIN category_product cp ON (p.id_product = cp.id_product) LEFT JOIN category_lang cl ON (cp.id_category = cl.id_category) WHERE pl.id_lang = 6 AND cl.id_lang = 6 GROUP BY p.id_product

Table 'shop_base.product' doesn't exist

 

May be issue a SQL query, how to fix this problem ?

 

Hi

 

 

I got exactly the same error, but i solved it.

 

 

This code seems to be missing the DB_PREFIX in some places.

 

I changed it and now it is working nice to export de Products CSV.

 

Take a look at this peace of code:

 

 

function getProducts()
{
global $db;
$csvOutput = array();
//from http://nemops.com/prestashop-export-products/
$query = 'SELECT p.*, pl.name, GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR ",") as categories, p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, pl.description_short, pl.description, pl.meta_title, pl.meta_keywords, pl.meta_description, pl.link_rewrite, pl.available_now, pl.available_later, p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition
FROM product p LEFT JOIN product_lang pl ON (p.id_product = pl.id_product)
 LEFT JOIN category_product cp ON (p.id_product = cp.id_product)
 LEFT JOIN category_lang cl ON (cp.id_category = cl.id_category)
WHERE pl.id_lang = '.LANG_ID.' AND cl.id_lang = '.LANG_ID.' GROUP BY p.id_product';

 

 

This code forgot the "ps_" (in my case) in it's last lines.

Try to insert the DB Prefix manually.

 

My new code became this way:

 

function getProducts()
{
global $db;
$csvOutput = array();
//from http://nemops.com/prestashop-export-products/
$query = 'SELECT p.*, pl.name, GROUP_CONCAT(DISTINCT(cl.name) SEPARATOR ",") as categories, p.price, p.id_tax_rules_group, p.wholesale_price, p.reference, p.supplier_reference, p.id_supplier, p.id_manufacturer, p.upc, p.ecotax, p.weight, p.quantity, pl.description_short, pl.description, pl.meta_title, pl.meta_keywords, pl.meta_description, pl.link_rewrite, pl.available_now, pl.available_later, p.available_for_order, p.date_add, p.show_price, p.online_only, p.condition
FROM ps_product p LEFT JOIN ps_product_lang pl ON (p.id_product = pl.id_product)
 LEFT JOIN ps_category_product cp ON (p.id_product = cp.id_product)
 LEFT JOIN ps_category_lang cl ON (cp.id_category = cl.id_category)
WHERE pl.id_lang = '.LANG_ID.' AND cl.id_lang = '.LANG_ID.' GROUP BY p.id_product';

 

 

 

 

I Hope to help you

 

 

 

EDIT:

 

Now i have another problem:

 

In my site the image url looks like: www.site.com/store/1261-2522-home/pelicula-1183.jpg

 

But in the CSV i have this kind of URL: www.site.com/store/img/p/4/4.jpg

 

 

How to fix that?

Edited by fernandokerber (see edit history)

Share this post


Link to post
Share on other sites

Has there been any movement on this project? I am pretty desperate for a script like this that moves products and orders/customers.

 

I am going to be tweaking it just to see if I can get this to work (better than starting from scratch)

fernandokerber - that file structure was actually given to me by the default 1.5.4install which resulted in broken images. It may not have anything to do with this script.

Share this post


Link to post
Share on other sites

Sorry LinzardB,

I don't have any plans to work on this for now

Share this post


Link to post
Share on other sites

hi there

 

 

can you explain better how to do this? change name.. put where? and do what?

Share this post


Link to post
Share on other sites

Strange, but the import format for the images links in this script is already the new, multi-level one.

I had to create my own bash shell script for the images to show up.

Note, this script creates the additional directories (and images into them) in 1.5 after you have copied the images from 1.4 and cd'ed to the images dir.

 

Thanks to: http://stackoverflow...533086#11533086 and http://stackoverflow...1533099/2090822

 

for f in *jpg; do
 if [[ $f =~ [0-9]+-([0-9]+)\..* ]]; then
id=${BASH_REMATCH[1]};
dir=`echo $id | sed 's/\([0-9]\)/\/\1/g'`;
mkdir -p ".$dir";
cp -p $f ".$dir/$id.jpg";
 fi
done

 

Note, you may also wish to remove the source images or/and do some further actions.

Also thanks to this post for recursive directories creation: http://stackoverflow...1252096/2090822

Edited by webxtor (see edit history)

Share this post


Link to post
Share on other sites

I am diggin out this pearl again. One of the most useful contributions at free cost I stumbled upon.

 

What I need to know is, how can I upload the script into a subfolder of root. So I can exclude the public from that folder.

I am a bit shaky having this script in the root folder.

your shop directory
define('MY_ROOT_DIR','/'

Can this be edited so the we put the script into a secure folder?

Thanks alot.

Share this post


Link to post
Share on other sites

Works great for me too! Tks

 

NOTE: At begining, couldn´t import well .csv file using MS Excell, because I was using coma or semi-colon as row separator instead the " ` " (don´t know the right name of this sign, maybe "inverted accent") Hope this help to someone!

Share this post


Link to post
Share on other sites

If anyone is still using this script and the image paths are old style, you just need to replace line 306 with this code:

$url_list .= URL_IMG_DIR_P.$product_id.'-'.$row['id_image'].'.jpg';

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More