Importing an osCommerce Store into Magento 1.7.0.2: A Comprehensive Guide
If you’re looking to migrate your existing osCommerce store to Magento 1.7.0.2, you’ve likely encountered challenges with the official migration tool. While it’s marked as Beta and lacks proper completion, we can still leverage it for a successful import with some significant tweaks.
Why Use the Official Migration Tool?
The Magento Connect extension offers a free starting point for the migration process. It covers key areas like categories, products, orders, and customers. However, its incomplete nature requires manual intervention and customization to work effectively.
Preparation: Setting Up Your Environment
Before beginning, ensure you have:
- A fresh installation of Magento 1.7.0.2
- The osCommerce import files (categories.xml, products.xml, etc.)
- Access to your server via FTP or SSH
Importing Categories with Customization
The official tool struggles with proper category structure. To resolve this:
- Open
app/code/core/Mage/Oscommerce/Controller/CategoryController.php. - Locate the line
$this->getResponse()->setBody($xmlString); - Replace it with:
$parser = new Varien_Simplexml_Element($xmlString);
$this->getResponse()->setBody($parser->asXML());
This change ensures proper XML parsing and avoids corruption during the import process.
- Run the category migration using
http://localhost/index.php/oscommerce/category/import.
Importing Products: Fixing Skus and Images
The product importer faces issues with SKU formatting and image URLs. To fix these:
- Open
app/code/core/Mage/Oscommerce/Model/Product.php. - Locate the method
public function import($xmlString) - Add the following code to clean up SKUs:
$parser = new Varien_Simplexml_Element($xmlString);
$simpleProducts = $parser->xpath('//product');
foreach ($simpleProducts as $product) {
$sku = trim((string)$product->sku);
if (strlen($sku) > 64) {
$sku = substr($ sku, 0, 63);
}
$product->sku = $sku;
}
This ensures SKUs are properly formatted and trimmed to fit Magento’s character limit.
- For image URLs, use an SSH client like PuTTY or the command line to replace
http://localhostwith your actual domain in the/var/oscommerce_product_images/folder before running the import.
Orders and Customers: Handling Special Cases
For orders and customers, you may encounter issues with special characters and required fields. Ensure all required fields are populated and that special characters are properly encoded to avoid import failures.
Conclusion
Importing an osCommerce store into Magento 1.7.0.2 requires a combination of the official migration tool and manual customization. By addressing the known issues in the provided code snippets and following the outlined process, you can successfully migrate your data while minimizing frustration.
Remember to backup your databases before beginning the import and test thoroughly after completion.
For more advanced e-commerce development, consider exploring our services at Laravel Company (Laravel Company), where we specialize in tailored solutions for complex migration projects.