Importing products (API)¶
Importing products by means of the API includes the following parts of the system:
- eContent repository: helper methods for automatic metadata generation.
- catalog data (categories, products and related attributes) need to be stored individually for every language used in the shop
- available classes for new database objects can be obtained from the
sve_classtable (by default only two classes: 1 = category, 2 = product)
Every catalog class defines a number of valid attributes for their elements. The name identifier, ID and Content Type of all attributes are stored in the table
node_id of the product,
attribute_id and language code fields are required.
After a new product is created, attributes can be associated with the product using its
In addition, creating a new attribute requires its ID and the language code.
Attributes use three data types to store their data (text, float and int). The API provides a corresponding setter method for every data type that needs to be called explicitly on import.
Importing a category¶
A category has
class_id = 1.
Categories are used to group products by setting the
parent_id of the product to the
node_id of the category.
The root node of the tree is 2 (the parent of the first category).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Importing a product¶
A product has
class_id = 2.
Creating a product requires the
parent_id (its Location in the product tree/catalog).
parent_id moves the product in the tree. After creation, the product's
node_id serves as its unique identifier.
Product entities provide getters and setters for their attributes.
To import into the
*_tmp table, use
$nodeId = $objectRepo->getNextNodeId();.
generateMetaData() method to generate metadata such as the URL alias of the product.
The following example creates a product object in the database and sets its properties. It creates attributes and associates them with the object. Different attributes have different data types (text is default).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
Create the index for the new products (in temporary area):
After the import, the database tables and Solr cores have to be switched: