0
votes

I'm trying to leverage Import/Export module to import taxonomies and taxonomy terms like so

<Orchard>
  <Data>
    <Taxonomy Id="/Identifier=Product-Categories" Status="Published">
      <AutoroutePart Alias="eshop/categories" UseCustomPattern="false" />
      <IdentityPart Identifier="Product-Categories" />
      <TitlePart Title="Product Categories" />
      <TaxonomyPart TermTypeName="ProductCategoriesTerm" />
    </Taxonomy>
    <ProductCategoriesTerm Id="/Identifier=Category-1" Status="Published">
      <AutoroutePart UseCustomPattern="false" />
      <IdentityPart Identifier="Category-1" />
      <TitlePart Title="Test category" />
      <TermPart Count="0" Selectable="true" Weight="1" TaxonomyId="/Identifier=Product-Categories" Path="" />
    </ProductCategoriesTerm>
  </Data>
</Orchard>

ProductCategoriesTerm when created through dashboard has default pattern

{Content.Container.Path}/{Content.Slug} ### my-taxonomy/my-term/sub-term

but importing terms makes them to use just {Content.Slug} ... How do I instruct AutoroutePart to use the default pattern? Tried UseCustomPattern="false" or exclude AutoroutePart with no effect it's just test-category instead of eshop/categories/test-category and won't regenerate even if if I set AutouroutePart to automatically regenerate when editing content and disable custom patterns and it won't revert to default pattern even if I try to publish it through dashboard.

Also it's mandatory to include "Count" for the TermPart when importing, does it affect anything? Sounds like something that should be dynamic and relevant only with export.

1
The alias must be specified during import, if you have the autoroute part.Bertrand Le Roy
Alias doesn't have to be specified during import, it gets generated. But for that to work properly I had to specify Container. Still learning my way around Orchard :).Xeevis
OK, let me reformulate: it should. If you don't specify it, the behavior is unspecified. In other words, anything can happen because it's not a supported scenario. AFAIK, at least.Bertrand Le Roy
Actually alias generation behavior is specified, by default pattern set on AutoroutePart for that content type. By specifying alias during import it ignores this pattern, which in turn can cause problems down the road. I think it's better to avoid custom aliases and just let them follow unified pattern, it should give better control in case you need to make change to the alias composition, you can update just pattern and it can easily propagate to all aliases.Xeevis
Actually, not during import it's not, because aliases are also identities. By specifying alias during import, you are specifying the identity of the content item, which avoids problems down the road. For instance, you can re-import the same items and not get duplicates. I know it's necessary to specify reliable identities in an import file, because that's the way we designed it. When importing an item, you are not creating a new item from vague specifications, you are creating an exact copy of an existing one.Bertrand Le Roy

1 Answers

0
votes

When importing taxonomy terms (and I guess any other part that has a container) it's necessary to specify Container for the common part. Without it Container for the part is null and therefore can't resolve {Content.Container.Path} in the alias pattern.

<CommonPart Container="/Identifier=Product-Categories" />

Or if it's nested term then Container is the parent term.