首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Prestashop中实现出口nad导入订单数据?

问如何在Prestashop中实现出口nad导入订单数据?
EN

Stack Overflow用户
提问于 2014-09-15 18:28:32
回答 2查看 2.4K关注 0票数 0

我需要将客户订单所有数据从旧的Prestashop 1.3迁移到新的Prestashop 1.6。

我是中级presta开发人员,这对我来说不是个小问题,我没有找到任何模块或教程来管理这个问题。presta mySQL中的订单数据在十几个表中被分隔开来,版本1.3和1.6之间的差异引发了额外的兼容性问题。数据量不是一个问题,它的小店。

我想知道,你是如何处理这样的问题的?

我几乎没有什么想法,但没有人听起来足够好:

  1. 将数据导出到csv,使compabile为1.6,然后导入(由php脚本或从csv导入到mysql)。
  2. 使php脚本从db读取旧数据,使数据兼容,然后插入到new db。

这两种想法都很费时,也许有人有更好的想法/链接/解决方案?

EN

回答 2

Stack Overflow用户

发布于 2014-12-07 05:59:29

我没有见过这样一个免费模块来导入客户订单或..。我自己进口的类别和产品,从一个不熟悉的cms到presta 1.6后台的presta商店1.6,如果你想要导入的实体,它在右边有一个菜单,上面写着哪些字段应该在您生成的用于导入的csv文件中。如果您的csv文件不匹配,您应该以一种语言(如php)获取csv文件,然后解析该文件并生成适当的csv文件,以便在预prestashop中导入。

我认为用csv文件导入数据比较容易。上传用于导入presta的csv文件后,请询问您在csv文件中的每一列都与presta系统的哪一列相关。

票数 0
EN

Stack Overflow用户

发布于 2014-12-20 20:12:47

这个php脚本有4个函数。

  • getHeader()函数作为数组获取CSV文件的头。
  • getCategories()再次作为数组从CSV文件中获取类别名称。
  • getRecords()函数将所有记录(不包括标头)作为二维数组。

代码语言:javascript
复制
<?php

function getHeader()
{
    $filename  = "past_cms_csv_file.csv";
    $contents = file_get_contents($filename);
    $records = explode('EOREOR', $contents);
    $header = explode(';', $records[0]);
    array_splice($header, count($header)-1, 1);
    return $header; 
}


function getCategories()
{
    $header = getHeader();
    $index = array_search('v_categories_name_1_4', $header);
    $filename  = "past_cms_csv_file.csv";
    $contents = file_get_contents($filename);
    $records = explode('EOREOR', $contents);
    $cats = array();

    for($i=1;$i<count($records);$i++)
    {
        $record = $records[$i];
        $items = explode('";"', $record);
        array_push($cats,$items[$index] );
    }
    $newCats = array_unique($cats);


    $mycats = [];
    foreach($newCats as $cat)
    {
        array_push($mycats, $cat);
    }
    array_splice($mycats, count($mycats)-1 , 1);
    return $mycats;
}

function getRecords()
{
    $filename  = "past_cms_csv_file.csv";
    $contents = file_get_contents($filename);
    $records = explode('EOREOR', $contents);
    $header = getHeader();
    $index = array_search('v_categories_name_1_4', $header);
    $cats = getCategories();

    for($i=1;$i<count($records);$i++)
    {
        $record = $records[$i];
        $items = explode('";"', $record);
        array_push($cats,$items[$index] );


        for($j=0;$j<count($items);$j++)
        {
            $results[$i][$j] = $items[$j];
        }
    }   

    return $results;
}

function makecsvfile($filename , $start_index)
{
    $header = getHeader();
    $results = getRecords();
    $active_index = array_search('v_status', $header);
    $name_index = array_search('v_products_name_4', $header);
    $desc_index = array_search('v_products_description_4', $header);
    $meta_title_index = array_search('v_products_meta_title_4', $header);
    $meta_keywords_index = array_search('v_products_meta_keywords_4', $header);
    $meta_desc_index = array_search('v_products_meta_description_4', $header);
    $price_index = array_search('v_products_price', $header);
    $quantity_index = array_search('v_products_quantity', $header);
    $category_index = array_search('v_categories_name_1_4', $header);
    $subcategory_index = array_search('v_categories_name_2_4', $header);


    $string  = '';
    $string .= '"ID";"Active";"Name";"Description";"Meta_title";"Meta_keywords";"Meta_Description";"Categories";"Quantity";"tax_rule";"Price";"Image URLs"';
    $string .= PHP_EOL;

    for($i=1;$i<count($results);$i++)
    {
        if( $results[$i][$category_index] != 'Schoenen en sokjes'  &&
            $results[$i][$category_index] != 'Accessoires meisjes' &&
            $results[$i][$category_index] != 'Accessoires jongens' &&
            $results[$i][$category_index] != 'Communie -en doopkleding' &&
            $results[$i][$category_index] != 'Aanbiedingen'
            )
            {
                $string .= '"';
                $string .= $i+$start_index;
                $string .= '";"';
                if($results[$i][$active_index] == 'Active')
                    $string .= 1;
                else if($results[$i][$active_index] == 'Inactive')
                    $string .= 0;   
                $string .= '";"';
                $string .= $results[$i][$name_index];
                $string .= '";"';
                $string .= $results[$i][$desc_index];
                $string .= '";"';
                $string .= $results[$i][$meta_title_index];
                $string .= '";"';
                if(strlen($results[$i][$meta_keywords_index]) < 255)
                    $string .= $results[$i][$meta_keywords_index];
                else
                {
                    $meta_key_words = substr($results[$i][$meta_keywords_index],0,254);
                    $last_comma_pos = strrpos($meta_key_words , ',');
                    $meta_key_words = substr($meta_key_words,0,$last_comma_pos);
                    $string .= $meta_key_words;
                }
                $string .= '";"';
                $string .= $results[$i][$meta_desc_index];
                $string .= '";"';

                if($results[$i][$subcategory_index] == '' && 
                    $results[$i][$category_index] != 'Tiara\'s & Kroontjes' &&
                    $results[$i][$category_index] != 'Feest / Gala jurken' &&
                    $results[$i][$category_index] != 'Ringkussens' &&
                    $results[$i][$category_index] != 'Bolero\'s en Jasjes')
                    $string .= $results[$i][$category_index];

                else if($results[$i][$category_index] == 'Tiara\'s & Kroontjes')
                    $string .= 'Kroontjes, diademen & tiara\'s';

                else if($results[$i][$category_index] == 'Feest / Gala jurken')
                    $string .= 'Feest- en galajurken';          

                else if($results[$i][$category_index] == 'Ringkussens')
                    $string .= 'kado kussens';

                else if($results[$i][$category_index] == 'Bolero\'s en Jasjes')
                    $string .= 'Bolero’s & jasjes';         

                else 
                    $string .= $results[$i][$subcategory_index];
                $string .= '";"';

                $string .= $results[$i][$quantity_index];
                $string .= '";"';

                $string .= 53;
                $string .= '";"';
                $string .= $results[$i][$price_index];
                $string .= '";"';
                $string .= 'http://example.com/path/to/myimage.jpg';        
                $string .= '"';
                $string .= PHP_EOL;
            }
    }
    file_put_contents($filename, $string);
}

makecsvfile('products.csv' , 100);
?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25854478

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档