SourceForge has been redesigned. Learn more.

#67 Category importer - no attributes



The category importer is not working for me with attributes (visible, active, anchor).
IMHO there is an error in "/magmi/plugins/extra/itemprocessors/categories/categoryimport.php" in "getCategoryIdsFromDef()" around line "219".

The foreach loop should be like that, to keep the attributes.

foreach($pcatparts as $cp)
// $catparts[]=$a[0];
$catparts[]=implode("::", $a);
//remove position to build catpart array


  • Sebastien Bracquemont

    This is a more complex problem than expected. The "category attributes" syntax has a "variable" number of params , ie : all are optional.

    I made a mistake choosing the item position separator to be the same as category attributes separator , since no way to find out what value is to be a position for item or a category attribute.

    So at this point, i think i'll be constrained to change one syntax or another (either category attributes or positioning) in order to be able to identify correctly what value means what.

  • Martin_W

    Martin_W - 2013-08-12


    Why is it so complex?

    Wouldn't it be possible to just change the separator and use the following syntax:

    The values for all attributes are boolean/integer, so there won't be any conflict.


  • Sebastien Bracquemont

    Fixing the bug by changing syntax is trivial, what isn't is to keep compatibility with existing syntax. the dillema is : what part of the syntax to change. Support for category attributes is older than support for item positioning, so changing it will have a bigger impact that changing item positioning support. Moreover, the comma & semicolon separator are widely used as common csv separators & some people are not very careful about enclosing & escaping. so, i'd prefer study all "non syntax breaking" alternatives before making this extreme choice.

  • Martin_W

    Martin_W - 2013-08-19

    Sorry, but I don't see that. There is no variable number of params. You can leave them blank instead of setting them to "0", but they are not optional. So there is no need to change the syntax. The first three options are ACTIVE, VISIBLE, ANCHOR and the fourth options is POSITION.

    The point is, that all options are dropped in line 219 of "/magmi/plugins/extra/itemprocessors/categories/categoryimport.php". To process the options, it is necessary to bring them back into $catparts. May be there is a missunderstanding, but changing "$catparts[]=$a[0];" to "$catparts[]=implode("::", $a);" works fine for me. Keeping the code as it is discards all options and there are not processed at the import.

  • Joost Wolthuis

    Joost Wolthuis - 2014-09-06

    Since position is always parameter 4 I just pop out the position part from the array.
    See code snippet below.
    This might give problems when a 5th parameter is added but for now it works.

       // build a position table to restore after cat ids will be created
        foreach ($pcatparts as $cp)
            $a = explode("::", $cp);
            if (count($a) > 4 ) {
                $catpos[] =  $a[4] ;
                unset ($a[4]) ;
            }else {
                $catpos[] = 0;
            $catparts[] = implode("::", $a);
            // remove position to build catpart array
  • Anse

    Anse - 2016-12-12

    I just worked around the removed attributes by modifying the explode() parameter from "::" to ":P:", in categoryimporter.php on line 205.

    See for the full story.


Log in to post a comment.