Magento – ezmage migration tool for oscommerce to magento

exportmagento-1.7module

I am trying to migrate data (categories, products, customers, and orders) from an osCommerce installation (ver 2.2rc2) to Magento (ver 1.7.0.2) using the migration tool offered at http://ezmage.com/migration-module/

The migration tool involves 8 steps which are executed by installing the module into magento & then processing each step via a browser GUI. Steps 1-6 were able to connect to OSC, create tmp tables within Magento's database, and migrate categories, products, and customers. The final step which is supposed to migrate orders appears to fail. The failure is only defined by the fact that no orders are migrated yet the script states:

congratulation the orders have been imported
Total Orders to Import:
Total Orders imported: 0

It appears the orders to import isn't being read.

There are other (much) older tools available on magentoconnect but none of them work. This ezmage plugin seems to be the most recent solution but fails on the last step. I'm hoping someone has either used/fixed this plugin and can offer a patch needed to complete the final step. phtml output below shows the logic behind the page that appears to mis-read the current state, along with the Main index controller from step7 follows below. Hopefully this is enough info to get a solution!

<?php   
$importOrdersTotal = Mage::getSingleton('core/session')->getimportOrdersTotal();
$importedOrdersTotal = Mage::getSingleton('core/session')->getimportedOrdersTotal();    
$error_msg = Mage::getSingleton('core/session')->getErrorMSG(); 
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><h1><strong>osCommerce Products/Categories/Customers/Orders Import </strong></h1></td>
  </tr>
  <tr>
    <td><strong>Step 6. Import Orders</strong></td>
  </tr>
  <tr>
    <td><br /><br />
</td>
  </tr>
    <?php if ($error_msg != ''){?>
  <tr>
    <td class="error"><hr /><h1><strong>ERROR</strong></h1><?php echo $error_msg; ?><hr /></td>
  </tr>    
  <?php } ?>   
  <tr>
    <td><br />
    <?php if ($importOrdersTotal != $importedOrdersTotal) { ?>
    Click the link below to import the orders, every time that you click teh script will go to import <?php echo Mage::getStoreConfig('oscommerceimportconf/mageconfiguration/conf_totalperimportorder',Mage::app()->getStore()); ?> orders<br /><br />
      <a href="<?php echo $this->getUrl('oscommerceimport/index/step71/')?>">Please click to import</a>
    <?php }else{?>  
      Congratulation the orders have been imported <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);  ?>Ezmage/OscommerceImport/check-ok.jpg" />
    <?php }?>      
      <br />
      <br /> 
      <br />
      <strong>Total Orders to import:</strong> <?php echo $importOrdersTotal; ?><br />
      <strong>Total Orders imported:</strong> <?php echo $importedOrdersTotal; ?></td>
  </tr>
  <tr>
    <td><br />
    <br />
    <br />    <div align="center"><a href="<?php echo $this->getUrl('oscommerceimport')?>">Main Menu</a></div></td>

and then the controller code:

/*******************************************************************************/
    /* Step 7                                                                                                                                          */
    /*******************************************************************************/
    public function step7Action()
    {                                                               

        Mage::getSingleton('core/session')->setErrorMSG('');    

        try {           
            //create products top import delete products, shipping, coupon, taxes,others
            $this->CreateGeneralProducts();


            $resource = Mage::getSingleton('core/resource');
            $readConnection = $resource->getConnection('core_read');

            $sql = "select osc_order_id from ezmage_orders where order_imported='y'";
            $list = $readConnection->fetchAll($sql);
            $importedOrdersTotal = sizeof($list);       
            Mage::getSingleton('core/session')->setimportedOrdersTotal($importedOrdersTotal);                                           
        }
        catch (Exception $ex) {
            //Mage::register('conection_status',$ex->getMessage());
            echo $ex->getMessage();
        }   

            $this->loadLayout();

                $block = $this->getLayout()->createBlock(
                    'Mage_Core_Block_Template',
                    'block_ezmage_oscommerce_import_step7',
                array('template' => 'ezmage/oscommerceimport/step7.phtml')
            );

            $this->getLayout()->getBlock('content')->append($block);            
            $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');

            $this->renderLayout();
    }   

    /*******************************************************************************/
    /* Step 71                                                                                                                                     */
    /*******************************************************************************/
    public function step71Action()
    {       

        // Add here another order total methods
        // Discount Modules list
        $discount_modules = array('ot_customer_discount','ot_discount_coupon','ot_giftcard','ot_loyalty_discount','ot_quantity_discount');
        // Other Charges Modules list
        $others_modules = array('ot_custom','ot_loworderfee');

        //$osc_order_totals_store = $this->GetOrderTotalsFromOSCAll($_connection_remote);


        // Stop Indexes     
        // http://www.clounce.com/magento/magento-reindex-programmatically
        // http://stackoverflow.com/questions/5420552/magento-programmatically-disable-automatic-indexing
        $pCollection = Mage::getSingleton('index/indexer')->getProcessesCollection(); 
        foreach ($pCollection as $process) {
            $process->setMode(Mage_Index_Model_Process::MODE_MANUAL)->save();
        }

        $_config = $this->setRemoteConectionConfig();

        $totalimport = 0;
        $storeId = Mage::getStoreConfig('oscommerceimportconf/mageconfiguration/conf_website',Mage::app()->getStore());

        try {           
            $resource = Mage::getSingleton('core/resource');
            $readConnection = $resource->getConnection('core_read');
            $writeConnection = $resource->getConnection('core_write');
            $_connection_remote = Mage::getSingleton('core/resource')->createConnection('oscommerce_conection', 'pdo_mysql', $_config); 

            $sql = "select * from ezmage_orders where order_imported<>'y'";
            $results = $readConnection->fetchAll($sql);

            // Get List of ISO Countries
            $country_list = $this->GetCountryList($_connection_remote);

            // Import each order
            foreach($results as $row) {
                // GET Order Information
                $osc_order = $this->GetOrderFromOSC($row['osc_order_id'],$_connection_remote);
                // Get Orders products
                $osc_order_products = $this->GetOrderProductsFromOSC($row['osc_order_id'],$_connection_remote);
                // GET Comments Information
                $osc_order_comments = $this->GetCommentsFromOSC($row['osc_order_id'],$_connection_remote);
                // GET Order Totals
                $osc_order_totals = $this->GetOrderTotalsFromOSC($row['osc_order_id'],$_connection_remote);

                // Get Shipping Information
                $shipping = $this->GetShippingTitle($osc_order_totals);

                // Create Quote Order
                $customer = Mage::getModel('customer/customer');
                $customer->setWebsiteId($storeId);
                $customer->loadByEmail($osc_order['customers_email_address']);

                $shopping_cart = $this->PrepareShoppingCart($osc_order_products,$_connection_remote,$osc_order_totals,$discount_modules,$others_modules);                                       

                $params = array("AccountNo" => $customer->getId(), "PartCart" => $shopping_cart);
                $this->global_shopping_cart = $shopping_cart;
                $quote_id = $this->PrepareOrder($params,$osc_order,$osc_order_products,$shopping_cart);

                // Create order
                $this->global_shopping_cart = $shopping_cart;               
                $order_id = $this->ConfirmOrder($quote_id,$osc_order_products,$osc_order_totals,$osc_order,$shopping_cart,$shipping);

                // Add Comments
                $this->AddOrderComments($order_id,$osc_order_comments);

                // Close Order 
                $this->CloseOrder($order_id);

                // update ezmage_orders
                $sql = "update ezmage_orders set order_imported='y',mage_order_id=".$order_id." where osc_order_id=".$row['osc_order_id'];      
                $writeConnection->query($sql);  

                $totalimport++;
                if ($totalimport == Mage::getStoreConfig('oscommerceimportconf/mageconfiguration/conf_totalperimportorder',Mage::app()->getStore())){
                    break;
                }   

            }

            // get import status    
            $sql = "select osc_order_id from ezmage_orders where order_imported='y'";
            $list = $readConnection->fetchAll($sql);
            $importedOrdersTotal = sizeof($list);       
            Mage::getSingleton('core/session')->setimportedOrdersTotal($importedOrdersTotal);

            // clean table sales_flat_quote if not we can't delete a product
            $sql = "DELETE FROM sales_flat_quote WHERE customer_is_guest = 0";
            $writeConnection->query($sql);

        }
        catch (Exception $ex) {
            Mage::register('conection_status','Oscommerce Order ID:'.$row['osc_order_id'].' - '.$ex->getMessage());
            //echo $ex->getMessage();
        }   

            $this->loadLayout();

                $block = $this->getLayout()->createBlock(
                    'Mage_Core_Block_Template',
                    'block_ezmage_oscommerce_import_step7',
                array('template' => 'ezmage/oscommerceimport/step7.phtml')
            );

            $this->getLayout()->getBlock('content')->append($block);            
            $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');

            $this->renderLayout();
    }   

Best Answer

are the orders actually imported into the temporary tables?

If so, try and find out which queries they're using for the transfer from the temp tables to Magento and run them from PHPMyAdmin for example or check the MySQL error logs on your server.

Optionally, try to run the import in a fresh, untouched installation of Magento to make sure no 3th party extensions might be the cause of the failure.

And last, try and contact the developer of the extension. They might be able to provide with (paid) support.

Related Topic