Jump to content

CSV Import Category Limitation... clarification?


Recommended Posts

When configuring a CSV import of products, or categories, there is a note at the bottom of the page that says: "Note that the category import does not support categories of the same name."  Does anyone know exactly what this means?

 

The reason I ask, is that the most likely structure for my auto parts store will have unique parent categories, but repeating sub-categories for the automobile model and year applicable to each part.  In other words, nearly every part (product) will have subcategories with the same name as thousands of other parts... the year, for example ("1980, 1981, etc.)

 

Since I need to categorize thousands of parts, this needs to be done in an external database and then uploaded... will this CSV import limitation get in my way?

Link to comment
Share on other sites

I took a look in the code for the category import to verify what that meant. There were a couple of snippets that stood out to me in regards to how the tool searches for category in the database to see if it exists.

 

If you have the parent category mapped to the tool and its a string, the tool will search for the parent category by name in the database and assign the sub category's id_parent to it. 

 

(line 883 AdminImportController.php)

$category_parent = Category::searchByName($default_language_id, $category->parent, true);
if ($category_parent['id_category'])
{
$category->id_parent = (int)$category_parent['id_category'];
$category->level_depth = (int)$category_parent['level_depth'] + 1;
}

Then later on it searches for the category by name AND a parent id (line 945):

$category_already_created = Category::searchByNameAndParentCategoryId(
$default_language_id,
$category->name[$default_language_id],
$category->id_parent
);

and changes the category id for that category imported if it exists in the database; before adding or updating the category fields from the feed (line 952).

// If category already in base, get id category back
if ($category_already_created['id_category'])
{
$cat_moved[$category->id] = (int)$category_already_created['id_category'];
$category->id = (int)$category_already_created['id_category'];
}

 

In short, the category import uses the name of the parent category to find any category id in the database to assign for category->id_parent. Then it uses this parent category (if found) to see if the category already exists. I'm assuming this is why this note indicates that it won't import categories of the same name.

Anyways, how did it go when you tested it out?

Link to comment
Share on other sites

Haven't had a chance to test it out yet.  This on-line store is to be an addition to my "real" business modifying and repairing four wheel drive vehicles... basically a "jeep shop," which takes more than all my time.  I get windows of opportunity to move this project along, usually taking an hour just to come back up to speed and remember where I left it!  It looks like you've put some effort into this question though, which I will go through as soon as I can.

 

The whole category thing (or any other way to organize automotive parts) is pivotal to my site.  Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...