Last active
March 28, 2017 09:45
-
-
Save stefanbc/1a2046d996ee60765b4a to your computer and use it in GitHub Desktop.
Export CSV from osCommerce and import it in Prestashop.Instructions:* Place the script in your osC root folder* Call the script in your browser* Save the file* Import it in Prestashop* Map the fields* Import!* You're awesome! Note: Tested with osC 2.2 rc 2a and Ps 1.5.4.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('includes/application_top.php'); | |
// Output headers so that the file is downloaded rather than displayed | |
header('Content-Type: text/csv; charset=utf-8'); | |
header('Content-Disposition: attachment; filename=data.csv'); | |
// Create a file pointer connected to the output stream | |
$output = fopen('php://output', 'w'); | |
// SQL for products with products extra images | |
// $exportSQL = "select p.products_id, pd.products_name, p.products_price, concat(p.products_image, ';', p.products_extra_images) as products_img, pd.products_description from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id"; | |
// SQL for products without extra products images | |
$exportSQL = "select p.products_id, pd.products_name, p.products_price, p.products_image, pd.products_description from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id"; | |
// SQL for customers | |
// $exportSQL = "select customers_email_address, customers_password, customers_dob, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS; | |
$exportQuery = tep_db_query($exportSQL); | |
if (tep_db_num_rows($exportQuery) > 1) { | |
while ($exportList = tep_db_fetch_array($exportQuery)) { | |
// In case you have a field with extra images in the osC DB you can use the | |
// code bellow to add it to the csv file | |
// $arrayImg = explode(';', $exportList['products_img']); | |
// foreach ($arrayImg as &$img) { | |
// if (!empty($img)) { | |
// $img = "http://YOUR_DOMAIN/" . $img; | |
// } | |
// } | |
// $exportList['products_img'] = implode(',', $arrayImg); | |
// We nned to format the DoB exported from osC so that it's correctly formated for Prestashop | |
// $exportList['customers_dob'] = date('Y-m-d', strtotime($exportList['customers_dob'])); | |
fputcsv($output, $exportList, ";"); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Greetings thank you very much for the code has served me great but I have a problem I need to export combinations of products (sizes, colors)
You can help?