Why models are generated in platform extensions?

Hybris is build over the concepts of extensions. Each extension has it’s own data model. Any extension can use an item type from other extension and extend it as per requirement.

For example, the itemtype  product defined in core extension. The catalog extension has extended the product itemtype, and added vendor to it.

While building the hybris, the frameworks builds according to dependencies. Since core is build before catalog extension, it is not aware of the vendor attribute defined in catalog extension. If we keep model class in extensions, then there will e chance of build failures. Like in our case, vendor attribute will not find a place in ProductModel class.

blog1

Hybris build framework, creates model classes, even before, building any extension. The platform is the best place to keep them, as every extension is built upon it only. So it is not logical to create model classes in particular extensions, when we can define same data model in various extensions.

Addon or Extension?

When it come to choose between addon or extension, it becomes a tricky situation. Because we don’t know actually, which one is preferable over another.

Extensions are basically a collection of related functionality, like we have promotion or a store front. It is a larger artefact, in terms of complexity and purpose it solves.

On the other hand, add ons, as their name suggests, are introduced to garnish a existing functionality. They are like toppings over your meal (extensions). For example, a Captcha addon.

  • When we need a functionality, which is used across multiple store front, like captcha, we can go for a addon. We need not to write a separate extension for that. But we can not go for an addon, if we need multiple sites, for multiple country or language. In that case, we need to create separate extension for that.
  • Suppose, you are working with a legacy system, where you can not modify the code base, but you want to modify the look and feel of it’s store front, in that case we can go for a add on.