Yash
Yash

Reputation: 1018

Dynamic schema in E-commerce

E-commerce websites show different fields for products of different categories. This implies they implement a dynamic schema. What techniques are used for such dynamic schema?

I am aware of Magento using the EAV model. Is there any other option which is used by other frameworks like ATG, Broadleaf, IBM Websphere commerce, etc.?

Thanks

Upvotes: 0

Views: 343

Answers (2)

Vihung
Vihung

Reputation: 13407

The usual way of extending products to have category-specific attributes in ATG is to extend the product repository item descriptor.

Usually, you would create a new sub-type of product for a category-specific product, and add properties for each category-specific attribute.

For example, you may want to define a "TV Product" sub-type of product where it has a Screen Size attribute

By default, there is only one type of product. This fact is represented by the type property having no options.

<property name="type" data-type="enumerated" column-name="product_type" writable="false" hidden="true"> </property>

You can extend that to represent multiple types and sub-types.

<property name="type" data-type="enumerated" column-name="product_type" writable="false" hidden="true">
  <option value="tv"/>
  <option value="option2"/>
</property>

Then, you can define your sub-type item descriptor as

<item-descriptor name="tvProduct" super-type="product" sub-type-value="tv">
  <!-- properties -->
</item-descriptor>

And then you can add property and table elements in your subtype to represent the category-specific properties such as screenSize.

There onwards, you can treat a tvProduct like any other kind of product. They will show up in any queries etc. for items of type product - but when you have an instance of a tvProduct it will have an additional screenSize property.

Upvotes: 1

phillipuniverse
phillipuniverse

Reputation: 2045

In Broadleaf, there are 2 ways to add custom properties:

  1. Subclass the existing ProductImpl Hibernate entity that corresponds to the BLC_PRODUCT table, putting all of your custom properties in a new MYCOMPANY_PRODUCT table instead. There is a pretty good tutorial on this at http://www.broadleafcommerce.com/docs/core/current/tutorials/core-tutorials/extending-entities-tutorial
  2. Most of the Broadleaf entities (like ProductImpl and SkuImpl) have a Map attribute map attached to them that you can add custom properties to without creating a new table or a new subclass. With the Broadleaf Custom Field module (a commercial module) these new dynamic fields can show up automatically in admin forms

Upvotes: 0

Related Questions