¿Cómo migrar tu sitio web de Magento 1 a la plataforma Shopify?

A medida que Magento 1 llega a su fin en junio de 2020, todos los propietarios de tiendas Magento están tratando de migrar su sitio web existente a Magento 2 o a alguna otra plataforma de comercio electrónico popular como Shopify o WooCommerce.

Recientemente migré uno de los sitios de Magento 1 de mi cliente a Shopify. Inicialmente, planeábamos usar alguna herramienta de migración de datos popular para migrar datos de Magento a Shopify, pero no funcionó bien para nosotros.

Aquí están los pasos que seguí para una migración exitosa.

1 – Preparando los datos de Magento al formato de Shopify

Getbras.com está vendiendo ropa interior para mujeres y el producto se agregó en sitios de Magento como productos configurables y variaciones hijas basadas en tamaño y color. Así que necesitamos seguir la misma estructura en el sitio de Shopify también.

Podemos exportar datos directamente de Magento a CSV, pero no podemos obtener la estructura exacta de cómo necesitamos importarlos a Shopify. Así que decidí escribir un script PHP personalizado para generar datos de Magento 1 y guardarlos en una tabla MYSQL. Puedes exportar directamente a CSV; almacenar en la tabla puede ayudarnos a realizar algún proceso más tarde si es necesario.

Los datos necesarios que necesitamos para importar productos configurables a Shopify son:

  1. Manejar
  2. Título
  3. Cuerpo HTML
  4. Proveedor
  5. Escriba
  6. Etiquetas
  7. Publicado
  8. Opción1 Nombre
  9. Opción1 Valor
  10. Opción2 Nombre
  11. Opción2 Valor
  12. SKU de variante
  13. Gramos de Variante
  14. Variant_Inventory_Tracke
  15. Cantidad_Inventario_Variantes
  16. Política_de_Inventario_de_Variantes
  17. Servicio_de_Cumplimiento_de_Variantes
  18. Precio_Variable
  19. Variant_Compare_At_Price
  20. Variant_Requiere_Envío
  21. Variant_Taxable
  22. Código de barras variante
  23. Image_Src
  24. Image_Position
  25. Texto_Alternativo_Imagen
  26. SEO_Título
  27. SEO_Description
  28. Unidad_Peso_Variantes
  29. Código_Tax_Variante

He creado una tabla mysql para almacenar los datos anteriores y generar datos utilizando un script personalizado de Magento 1. Aquí está el código php que uso.

<?php
    ini_set('memory_limit','2048M');
    ini_set('max_execution_time',12000); 
    require_once "app/Mage.php";
    $root=$_SERVER['DOCUMENT_ROOT'];
    Mage::app("default");
    Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_FRONTEND,Mage_Core_Model_App_Area::PART_EVENTS);
    //Mage::init();
    $connection = Mage::getSingleton('core/resource')->getConnection('dbname');
    $_helper = Mage::helper('catalog/output');
    $helper = Mage::helper('shoppersettings/image');
    $imgX = 252;
    $imgY = $helper->calculateHeight($imgX);
//$filename = 'google_pla_feed_magento.csv';
    $link=mysql_connect("localhost",'','');
    mysql_select_db('dbname',$link);
https://bras-honey.myshopify.com/search?type=product&q=Loungeable%2Bboutique
    $_productCollection = Mage::getModel("catalog/product")->getCollection()->addAttributeToSelect(array('pre_order','name', 'price','special_price','brand','color','size','lingerie_type', 'image', 'status','short_description','description','sku','created_at'))
    ->addAttributeToFilter('type_id', array('eq' => 'configurable'))
    ->addAttributeToFilter('entity_id', array('gt' => $last_id))
    ->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
    //->setPageSize(10);
    //->setCurPage($p)
    $i=0;
    $k=0;
    foreach ($_productCollection as $_product):
        $name= $_product->getName();
        $name=str_replace("&","&amp;",$name);
        $sku=$_product->getSku();
        $created_at=$_product->getCreatedAt();
        $text=explode(" ",$sku);
        $sku=$text[0];
        $url_key = $_product->getProductUrl();
        $full_url_key = $_product->getProductUrl();
        //preparing unique handle for shopify
        $url_key = str_replace("https://www.example.com/", "", $url_key);
        $url_key = str_replace(".html", "", $url_key);
        $id=$_product->getId();
        $pre_order_status=$_product->getPreOrder();
        if($pre_order_status==""):
            $pre_order_status=0;
        endif;
        $product = Mage::getModel('catalog/product')->load($id);
        $desc=strip_tags($product->getDescription());

        $desc=str_replace("&nbsp;"," ",$desc);
        $desc=str_replace("&","&amp;",$desc);
        $desc1=$product->getDescription();
        $short_desc1=$product->getShortDescription();
        $productMediaConfig = Mage::getModel('catalog/product_media_config');
        $image_url = $productMediaConfig->getMediaUrl($product->getImage());
        $final_price=$product->getFinalPrice();
        $meta_title=$product->getMetaTitle();
        $meta_desc=$product->getMetaDescription();
        $special_price=$product->getSpecialPrice();
        $type_id=$product->getLingerieType();
        $brand_id=$product->getBrand();
        $final_price=number_format($final_price, 2, '.', '');
        $desc1=str_replace("&nbsp;"," ",$desc1);
        $desc1=str_replace("&","&amp;",$desc1);
        $desc1=str_replace('\\',"",$desc1);
        $desc1=str_replace("'","\'",$desc1);
        $short_desc1=str_replace("&nbsp;"," ",$short_desc1);
        $short_desc1=str_replace("&","&amp;",$short_desc1);
        $short_desc1=str_replace('\\',"",$short_desc1);
        $short_desc1=str_replace("'","\'",$short_desc1);
        $desc1 = $short_desc1.$desc1;
        preg_match_all('~<a(.*?)href="([^"]+)"(.*?)>~', $desc1, $matches);
        foreach ($matches[2] as $key => $value) {
            $value = str_replace("https://www.example.com/", "", $value);
            $value = str_replace("http://www.example.com/", "", $value);
           // echo '-----';
            //replacing magento url in the content with shopify url
            $sql1="SELECT id_path FROM mg_core_url_rewrite WHERE request_path='$value'";
            $res1=mysql_query($sql1,$link) or die(mysql_error());
            if(mysql_num_rows($res1)>0){
                while($rs1=mysql_fetch_object($res1)){
                   $id_path = $rs1->id_path;
                    if(strpos($id_path,'product/') !== false){
                        $value1 = 'products/'.$value;
                        $desc1 = str_replace($value,$value1,$desc1);
                   }elseif(strpos($id_path,'category/') !== false){

                        $text = explode("/",$value);
                        $l = count($text);

                       $value1 = 'collections/'.$text[$l-1];
                        $desc1 = str_replace($value,$value1,$desc1);
                    }
                }
            }
            if(strpos($value,'catalogsearch/') !== false){
                $text = explode("?q=",$value);
                $value1 = 'search?type=product&q='.$text[1];
                $desc1 = str_replace($value,$value1,$desc1);
            }

        }
        $desc1 = str_replace(".html","",$desc1);
        $pId="";
        $status=0;
        $lingerie_type="";
        $brand = Mage::getModel('catalog/product')->load($id)->getAttributeText('brand');
        $brand1=$brand;
        $brand=str_replace("&","&amp;",$brand);
        $lingerie_type = Mage::getModel('catalog/product')->load($id)->getAttributeText('lingerie_type');
        $lingerie_type1=$lingerie_type;
        $lingerie_type=str_replace("&","&amp;",$lingerie_type);
        if($lingerie_type==""):
            $lingerie_type="Lingerie";
        endif;
        $product = Mage::getModel('catalog/product')->load($id);
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
            $cats = $_product->getCategoryIds();

                $j=0;

                $category_name="";

                foreach ($cats as $category_id){

                    $_cat = Mage::getModel('catalog/category')->load($category_id) ;

                    if($j<10):

                    $category_name.=trim($_cat->getName()).',';

                    endif;

                    $j++;

                }

            $category_name=substr($category_name,0,strlen($category_name)-1);

//getting child variants of magento configurable products
foreach($childProducts as $child) {

    $k++;
    $child_sku =$child->getSku(); 
    $child_id=$child->getId();
    $child_name=$child->getName();
    $weight=$child->getWeight();
    $qty=$child->getQty();
    $size_id=$child->getSize();
    $color_id=$child->getColor();
    $type_id =$child->getLingerieType();
    $size = Mage::getModel('catalog/product')->load($child_id)->getAttributeText('size');
    $color = Mage::getModel('catalog/product')->load($child_id)->getAttributeText('color');
    $lingerie_type = Mage::getModel('catalog/product')->load($child_id)->getAttributeText('lingerie_type');
    $text=explode("-",$child_sku);
    $text1=explode(" ",$text[2]);
    $child_sku=$text[0].'-'.$text[1].'-'.$text1[0];
    $name = mysql_real_escape_string($name);
    $meta_title = mysql_real_escape_string($meta_title);
    $meta_desc = mysql_real_escape_string($meta_desc);
    //adding product temp mysql table
    $sql="INSERT INTO magento_shopify(Handle,Title,Body_HTML,Vendor,Type,Tags,Option1_Value,Option2_Value,Variant_SKU,Variant_Grams,Variant_Inventory_Qty,Variant_Price,Variant_Compare_At_Price,Variant_Barcode,Image_Src,Image_Position,Image_Alt_Text,SEO_Title,SEO_Description,Variant_Tax_Code) VALUES ('$url_key','$name','$desc1','$brand','$lingerie_type','$category_name','$color','$size','$child_sku','$weight','$qty','$final_price','$special_price','','$image_url','','$name','$meta_title','$meta_desc','')";
    mysql_query($sql,$link) or die(mysql_error());

}
$i++;
       endforeach;       
       exit;
    ?>
After run above script you can see all of your necessary magento data in mysql table. You can check and verify using phpmyadmin

An example screenshot here:

Ahora puedes exportar datos desde phpmyadmin.

Exportar datos en formato CSV y agregar el nombre de la columna como encabezado.

Después de exportar los datos, el archivo csv debe abrirse en Excel y actualizar el encabezado de las columnas que coincidan con la plantilla de importación csv de Shopify, un ejemplo de CSV que usamos se muestra a continuación.

Download here