CategoryTree loader¶
It loads given rows to the spy_category_node
and spy_category_closure_table
tables.
The Category.tree.publish
event is triggered.
Warning
Unique Constraint Suggested to Prevent Duplicates
To ensure data integrity and prevent duplicate entries when running the importer multiple times
with the same dataset, it is strongly recommended to add a unique constraint on the
fk_category_node
and fk_category_node_descendant
columns.
Without these constraints, duplicate relationships may be inserted on each import execution, leading to redundant data in the database.
Suggested SQL Constraint:
<table name="spy_category_closure_table">
<unique name="uqc_category_closure_table">
<unique-column name="fk_category_node"/>
<unique-column name="fk_category_node_descendant"/>
</unique>
</table>
By enforcing this constraint, the CategoryTreeLoader
can reliably handle repeated imports
without unintentionally duplicating entries.
Usage:
<category-tree
categoryNodeIdField="categoryNodeId"
categoryIdField="categoryId"
categoryKeyField="categoryKey"
parentCategoryIdField="parentCategoryId"
parentCategoryKeyField="parentCategoryKey"
isMainCategoryNodeField="isMainCategoryNode"
isRootCategoryNodeField="isRootCategoryNode"
categoryNodeOrderField="categoryNodeOrder"
/>
Attributes:
categoryNodeIdField
- name of the field where the category node id should be setcategoryIdField
- name of the field containing the category idcategoryKeyField
- name of the field containing the category keyparentCategoryIdField
- name of the field containing the parent category idparentCategoryKeyField
- name of the field containing the parent category keyisMainCategoryNodeField
- name of the optional field containing the boolean isMain value, if not set Spryker Database default is usedisRootCategoryNodeField
- name of the optional field containing the boolean isRoot value, if not set Spryker Database default is usedcategoryNodeOrderField
- name of the optional field containing the node order value, if not set Spryker Database default is used