1. seppo
  2. RO CSVI
  3. Thursday, 12 February 2015
  4.  Subscribe via email
Hi,

How could I export the category tree from VM to CSV? If using VM category export template, it does not allow to select parent category field. I guess this is because the category tree table is separate from actual categories -table. Anyway to do this?
Accepted Answer Pending Moderation
Hello,

You can use the category_path field, this has the full structure in them.
  1. more than a month ago
  2. RO CSVI
  3. # 1
Accepted Answer Pending Moderation
Thanks for prompt answer! :)

Before I can see that in effect, there was another problem: When I slect the VM Category export->Process I get a csv file with category names in the first row, and after that a normal webpage (starting with <!DOCTYPE html>
<html...). How to export "normal" CSV, without HTML? As a quick tryout, I tried deselecting Export Frontend and Collect debug information -options. The ecport type was CSV.

I must be missing something..
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
Hello,

and after that a normal webpage (starting with <!DOCTYPE html>
That is not normal but a problem. Can you post the file so I can see the error you get?
  1. more than a month ago
  2. RO CSVI
  3. # 3
Accepted Answer Pending Moderation
Thank you for the answer. I managed to get through this error myself - or to get around it: It had something to do with media-fields. After I took those away from export it started to work OK. Might become a problem when using media fields, but since they are not needed now, I mark this also solved
  1. more than a month ago
  2. RO CSVI
  3. # 4
Accepted Answer Pending Moderation
There is a patch on the forum as someone reported the same problem, this happened when there was no media item linked to a category. This patch is included in the next release of CSVI.
  1. more than a month ago
  2. RO CSVI
  3. # 5
Accepted Answer Pending Moderation
Hi,

I get back to ths, as I realized that this was not working as expected:
I had existing categories, which I needed to replace with new ones, with new category-subcategory order too.
But when importing, it does replace the names, but some categories end up as subcategory to categories that should not have subcategories. Thus, it seems that when importing it is using old category tree, and only replacing names.

I tried to change category separator from / to \ or to > (as some category names had / in them which I replaced too)
But this did not help.

In the import I have category id, category path and category name. I suppose it would use the first field (virtuemart_category_id) as mapping field, but I was thiking if it was trying to use category_path for this. If so, it would leave to errors if all category names / structure was changed as it would not have matching order which to replace.
  1. more than a month ago
  2. RO CSVI
  3. # 6
Accepted Answer Pending Moderation
Hello,

I tried to change category separator from / to \ or to > (as some category names had / in them which I replaced too)
That is a good plan anyway otherwise you will get subcategories that are not subcategories.

In the import I have category id, category path and category name. I suppose it would use the first field (virtuemart_category_id) as mapping field, but I was thiking if it was trying to use category_path for this.
Are you doing a category import or a product import?

The category_name is not used when importing the category id. If you just want to change the names of the categories, the category id and the category name should be enough. You cannot change names of categories using the category_path field.
  1. more than a month ago
  2. RO CSVI
  3. # 7
Accepted Answer Pending Moderation
Hi,

That is a good plan anyway otherwise you will get subcategories that are not subcategories.


Do you mean that \ cannot be used as category separator instead of / ? I changed that since some of the original categroy names needs / in them.

Are you doing a category import or a product import?

I am doing a category import. I do not only need to change category names, but their order as well in terms of their depth. I mean, old subcategory of category A might change to sub catebory of category B or even into sub category of subcategory.So in that sense totally rearranging whole category tree.

Is it possible with CSV improved? Do I need to leave category name out and use only category_id and category_path for that?
  1. more than a month ago
  2. RO CSVI
  3. # 8
Accepted Answer Pending Moderation
I was trying to use only virtuemart_category_id and category_name (after which I would then use only virtuemart_category_id and category_path) to access same result. But when importing, I got error with message "No category path set".
This seems to indicate that the separation is done by category_path and not by virtuemart_category_id, am I right?
If so, it is impossible to change category tree-structure because I would need to change the separation field itself (=category_path)
  1. more than a month ago
  2. RO CSVI
  3. # 9
Accepted Answer Pending Moderation
This seems to indicate that the separation is done by category_path and not by virtuemart_category_id, am I right?
Correct, the category_path is the required field for categories.

If so, it is impossible to change category tree-structure because I would need to change the separation field itself (=category_path)
You would need to create a new import file with your new structure, remove all the existing categories and import the new structure and you should have it. Messing around with IDs is not the best way to go about it if you ask me as they are auto-generated by the database.
  1. more than a month ago
  2. RO CSVI
  3. # 10
Accepted Answer Pending Moderation
Hi,

Thank for your answer, I thought that was only way.
Anyway, a suggestion for future versions of CSVI: if there was a change of rearranging category structure it would be good. Based on what you said, I think it would need to be done binding it to existing categories, thus the id fields would be the same and not auto generated. This way the id field could be the separating one
  1. more than a month ago
  2. RO CSVI
  3. # 11
Accepted Answer Pending Moderation
Hello,

thus the id fields would be the same and not auto generated
You basically can't because it is an auto-increment field thus controlled by the database itself. If you don't want to auto-generate the IDs you would need to take the complete ID management into your own hands and control all linked tables as well.
  1. more than a month ago
  2. RO CSVI
  3. # 12
Accepted Answer Pending Moderation
But I mean, that once category is created (by database autoincrement or some other method), id usually don't change. Thus, exproting the current tree, making modifications in excel or such, and importing back would not cause need for new auto incrementations, as no new fields were added. This would allow to change current category structure, using existing id-fields as base fields. I understand that this would not work if new categoreis were added, but this would work for rearranging existing ones.
  1. more than a month ago
  2. RO CSVI
  3. # 13
Accepted Answer Pending Moderation
If you only want to change the name, you could use the Custom table import/export. You can then directly work on the language table in question and use the ID as key.
  1. more than a month ago
  2. RO CSVI
  3. # 14
Accepted Answer Pending Moderation
Thank you for the tip, but I was unable to do that:
I found the custom tables under settings, where I selected virtuemart_categories_en_gb. After this, in process area I was able to select export->CSVI Pro->Custom export ->go. After this I saw the virtuemart_categories_en_gb in the forth dropdown after custom export. But in the Export options area, in Fields tab in Field name dropdown the reas nothing to be added, dropdown was empty. So I was unable to construct such thing to be able to change names of categories. But maybe i did something wrong there, could you point how to do that?

About my suggestion for future versions: there could be an option to just modify current category tree based on id. If that option was selected, it could just ignore all lines with new id if there was any. This way, users could both reneame and re-arrange category tree in excel instead of virtuemart.

As an example of my current case where this current system is problematic: There is thousands of products and hundreds of categories and subcategires, so editing in excel or such is important. Now imagine that there comes some new categories and some old ones need to be transferred as subcategories of these new ones. This means that user would need to change category_path since it is the only one currently telling what is parent category for that category. This cannot be done with current setup of CSVI easily. Even only renaming one category is problematic (well, maybe can be achieved with instructions that will follow) since it would mean renaming of category_path also which cannot be done as is key.

While understanding this problem, I gave instructions for shopkeeper updating their categories not to change anything in existing ones, but just to add new ones through CSVI Pro (also important since there is so many categories), after I had added there first 30 or so. He added only 6 new ones to test it out, but made a little mistake with one line, where the name field was different to last part of category_path. So the CSVI Pro import reported error, but still after fixing this one line and trying again it was not working. This time the reason was, that many of the categories had taken some new categoreis to be their parent categories, even they were different names. I do not know how this happened, but I think it has something to do parser that breaks up category_path field, and was somehow interrupted with the mistake spelling in one of them at first try.
Now, I can rebuild (by delete and the importing from backups) whole category tree as suggested in this thread, but I am afraid to do that since most likely it will create new category id's (as you mentioned they are created on the fly by virtuemart). And this is problematic since there is already some procuts, pointed to belong to certain categories - which would then point to nowhere since virtuemart uses id as key. Luckily it is not live yet and building of all categories and products is in its early stages, but maybe you see the problem that creates for future usage.

If the key was ID field also for CSVI Pro, then there would not be above problems. Now, it cannot be used for renaming or rearranging of categories, and actually it is risky to use it for any category -related operations since it seems to easily break current structure of existing ones if there is an error in new fields (even the category_path was fields were not touched in those. I do not know if scandic or special characters like / in category name was part of the reason too - again, if it was, it could be avoided when using id field as key). If that would require to use parent category field, and that also only as numeric id field, it would still be easy to use.
  1. more than a month ago
  2. RO CSVI
  3. # 15
Accepted Answer Pending Moderation
Adding to previous info:

After problem mentioned, I deleted all procuts and categories in order to re-import them from ones that did work before. Hoewever, this time I got same error as shopkeeper got when doing his import with few new lines (which actually had this error):
Category name does not match category path. Make sure that the category_name field matches the last category in category_path field.

When import with this file was working, I was using version 5.21.1 and today I updated it to 5.21.2 before deleting an re-importing. So maybe there is some bug in new version? In the file I was trying to import, I use > as category separator, and it did break after first subcategory having / in it's name. Actually, that subcategory did come OK, but first subcategory of that did not (thus, being first 3rd level subcategory). I hope this info helps finding the bug. None of the 2nd level subcategory after that did come to virtuemart either.
  1. more than a month ago
  2. RO CSVI
  3. # 16
Accepted Answer Pending Moderation
But maybe i did something wrong there, could you point how to do that?
How to use the custom tables feature is explained in the Custom tables import and export document. If there are no fields, most likely the update available fields was not run.

Now imagine that there comes some new categories and some old ones need to be transferred as subcategories of these new ones.
That I have a hard time imagining ;)

This means that user would need to change category_path since it is the only one currently telling what is parent category for that category. This cannot be done with current setup of CSVI easily.
If you add the new category_path that will be created and the products assigned to it. Any empty categories can be removed with the Maintenance option in CSVI.

And this is problematic since there is already some procuts, pointed to belong to certain categories
You would import these products again as well with their new category path.

(which actually had this error):
Category name does not match category path. Make sure that the category_name field matches the last category in category_path field.
You will get this error when you use both the category_path and category_name in your import file and the category_name is different from the last category in the category_path. When using the category_path you should not have to use the category_name field.

So maybe there is some bug in new version?
So maybe there is some bug in new version?There is no bug with that part, not only has it not been touched but this check has been in place since version 1 almost.

In the file I was trying to import, I use > as category separator, and it did break after first subcategory having / in it's name.
If you have the / in your category name, you will have to choose another category separator. If you have the |-symbol in your category name you will need to rename the category since you can't choose another character for that.
  1. more than a month ago
  2. RO CSVI
  3. # 17
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!