I want to import data related to categories first and then products. But when i am going to upload only category csv file it is showing error "sku not found" and when i am trying to import merged data of category and products csv it is importing products but not showing any category and in products showing 0 record found and in import showing upload success message. Can anyone please help me.
2
votes
2 Answers
0
votes
You have to import categories alone.
Put all information in your csv, then go through a custom script like this one :
(create a script directory in your root Magento folder, and a category.php file in this location).
then you'll be able to import your category by going to yoursite.com/script/category.php
You can find example here :
http://www.magentoworks.net/import-bulk-category-in-magento
Regards,
0
votes
Please refer my tutorial which create category and subcategory using the magento script.
http://www.pearlbells.co.uk/import-the-categories-programmatically/
foreach ($arrResult as $import_category) {
try {
if (strtolower($import_category[16]) == 'true') {
$enabled = 1;
} else {
$enabled = 0;
}
if ($import_category[1] == 0) {
$parentId = '2';
}
else {
$parentId = $list[$import_category[1]];
}
$category = Mage::getModel('catalog/category');
$category->setName($import_category[2]);
$category->setMetaTitle($import_category[2]);
$category->setIncludeInMenu(1);
$category->setUrlKey($import_category[10]);
$category->setDescription(strip_tags($import_category[11]));
$category->setMetaDescription($import_category[12]);
$category->setMetaKeywords($import_category[13]);
$category->setIsActive($enabled);
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(1); //for active anchor
$category->setStoreId(Mage::app()->getStore()->getId());
$parentCategory = Mage::getModel('catalog/category')->load($parentId);
$category->setPath($parentCategory->getPath());
$category->setCustomUseParentSettings(true);
$category->setImage($import_category[6]);
$category->save();
$list[$import_category[0]] = $category->getId();
echo 'Category ' . $category->getName() . ' ' . $category->getId() . ' imported successfully' . PHP_EOL;
} catch (Exception $e) {
echo 'Something failed for category ' . $import_category[2] . PHP_EOL;
print_r($e);
}
}