2016-01-06 17 views
0

我的问题是在导入我的数据时得到正确的菜单结构。在单个产品上导入多个类别

我使用的Magento 1.9.2.2

我收到我的数据以CSV格式是这样的:

"sku","Cat1","Cat2","Cat3","Cat4" 
"001","Plumbing","Pressfittings & pipes","Unipipe - MLC","Clutch" 
"002","Tools","Handtools|Pipetools","Pipetools|Pipecutters & Scissors","Plastic scissors" 
"003","Tools|Plumbing","Handtools|Pipetools|Pipes & Fittings","Pipetools|Calibration|Alupex fittings & tubes","Calibration tools|Tools for alupex" 

我做了一个小程序来除掉那些“|”和什么来后,使:

"002","Tools","Handtools|Pipetools","Pipetools|Pipecutters & Scissors","Plastic scissors" 

变为:

"002","Tools","Handtools","Pipetools","Plastic scissors" 

但我很想创建所有的垫层类别,所以我也得到这个SKU的002:

"002","Tools","Pipetools","Pipecutters & Scissors","Plastic scissors" 

我相信Magento会以某种方式使用该结构,但我很难弄清楚如何导入它。

我已经尝试了手动创建类别后正常导入Magento,并且这不起作用。 我也尝试用Magmi创建它们,但是我无法让Magmi使用多个主要和子类别。

有没有人看到这种数据格式,并有正确的方向线索,如何让它导入到菜单结构?

我有2500个主要和子类别在一起,所以手动创建它们根本不会工作。

想法,问题或意见,欢迎! :)

回答

0

MAGMI'飞行类别进口商'一定会为你做这个。我建议您非常仔细地阅读MAGMI wiki上的说明:您需要的所有信息都在那里,但我经常发现必须仔细检查并重新阅读MAGMI wiki上的详细信息和示例。

MAGMI下载说明安装和运行:http://wiki.magmi.org/index.php?title=Main_Page#Download_and_Install_Magmi

对即时类进口商MAGMI说明:http://wiki.magmi.org/index.php?title=On_the_fly_category_creator/importer

如果你还没有使用MAGMI之前然后用一个简单的CSV开始一起工作确保您的安装设置正确,并且您可以导入创建简单产品的csv。

我认为您面临的主要挑战是将您问题中描述的CSV文件格式转换为MAGMI可以使用的CSV格式。或者,您可以在MAGMI中编写代码来转换CSV数据,但如果这是一次性过程,我认为这可能过于复杂。

我不知道,我按照你的CSV例子的语法,但如果第一个字符串始终是顶级类别,然后在管道符号代表“子类别遵循”然后

"003","Tools|Plumbing","Handtools|Pipetools|Pipes & Fittings","Pipetools|Calibration|Alupex fittings & tubes","Calibration tools|Tools for alupex"

你争取作出MAGMI CSV这样

"sku","categories" "003","Tools::1::1::1/Plumbing::1::0::1;;Handtools::1::1::1/Pipetools::1::0::1/Pipes & Fittings::1::0::1;;Pipetools::1::1::1/Calibration::1::0::1/Alupex fittings & tubes::1::0::1;;Calibration tools::1::1::1/Tools for alupex::1::0::1"

晦涩::1::1::1表示is_activeis_anchorinclude_in_menu分别可以省略。

这不关我的事,但我深切关注由子类别标签的两个空间'Tools for alupex'(不启动我的小写Alupex或AluPEX)

+0

感谢马拉奇,这是帮助解决方案我。我的分类有点搞砸了,所以在重新安排和阅读你提供的链接后,Magmi完美地完成了这个诀窍。 – bjarkemonsted

0

你必须以编程方式创建这些类别,不可能通过导入(也许通过magmi但我不知道)。将脚本放入您的magento根目录并运行它。这是你可以如何继续(需要抛光):

$category = Mage::getModel('catalog/category'); 

$f = fopen($file, "r"); 

$row = 0; 
while (($data = fgetcsv($f, 0, ",")) !== FALSE) { 
    $multiple_categories = explode("|", $data); 
    //save main ones 
    $category->setName($multiple_categories[0]) 
     ->setIsActive(1)      
     ->setDisplayMode('PRODUCTS') 
     ->setIsAnchor(1) 
     ->setAttributeSetId($category->getDefaultAttributeSetId()); //or the id of your attribute set, this is important. 
    $category->save(); 
    unset($category); 
    //now deal with children 
    if(count($multiple_categories) > 1){ 
     i = 1; 
     foreach($multiple_categories as $subcategory){ 
      $category->setName($multiple_categories[i]) 
       ->setIsActive(1)      
       ->setDisplayMode('PRODUCTS') 
       ->setIsAnchor(1) 
       ->setAttributeSetId($category->getDefaultAttributeSetId()); 
      //manage parents now 
      $_category = Mage::getResourceModel('catalog/category_collection') 
       ->addFieldToFilter('name', $multiple_categories[i-1]) 
       ->getFirstItem(); //this needs more work 
      $parentId = $_category->getId(); 
      $parentCategory = Mage::getModel('catalog/category')->load($parentId); 
      $category->setPath($parentCategory->getPath()); 
      $category->save(); 
      unset($category); 
      i++; 
     } 
    } 
    $row++; 
} 
相关问题