Você está na página 1de 10

Approach 1

Extending TWMProduct from Product and TWMItem from VariantProduct.


Type definition:
<typegroup name="TWM">
<itemtype code="TWMProduct" extends="Product"
autocreate="true" generate="true"
jaloclass="de.hybris.platform.yacceleratorcore.jalo.TWMProduct">
<description>Total Wines Product type that contains additional
attribute specific to TWM product model.
</description>
<attributes>
<attribute qualifier="fullName"
type="java.lang.String">
<description>shortName of the
product.</description>
<modifiers/>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
<itemtype code="TWMItem" extends="VariantProduct"
autocreate="true" generate="true"
jaloclass="de.hybris.platform.yacceleratorcore.jalo.TWMItem">
<description>Total Wines Product type that contains additional
attribute specific to TWM product model.
</description>
<attributes>
<attribute qualifier="volume" type="java.lang.String">
<description>volume of the item.</description>
<modifiers/>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
</typegroup>

TWMProduct creation in hmc:

Above appoarch will not expose TWMProduct specific attributes to


TWMItem because of the no direct inheritance

Approach 2
Extending TWMProduct from VariantProduct and TWMItem from
VariantProduct.
Type definition:
<typegroup name="TWM">
<itemtype code="TWMProduct" extends="VariantProduct"
autocreate="true" generate="true"
jaloclass="de.hybris.platform.yacceleratorcore.jalo.TWMProduct">
<description>Total Wines Product type that contains additional
attribute specific to TWM product model.
</description>
<attributes>

<attribute qualifier="fullName"
type="java.lang.String">
product.</description>

<description>shortName of the

<modifiers/>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
<itemtype code="TWMItem" extends="VariantProduct"
autocreate="true" generate="true"
jaloclass="de.hybris.platform.yacceleratorcore.jalo.TWMItem">
<description>Total Wines Product type that contains additional
attribute specific to TWM product model.
</description>
<attributes>
<attribute qualifier="volume" type="java.lang.String">
<description>volume of the item.</description>
<modifiers/>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
</typegroup>

Error while creating TWMProduct:

Approach 3
Extending TWMProduct from VariantProduct and TWMItem from
VariantProduct. Making baseProduct at TWMProduct level optional.
Type definition:
<typegroup name="TWM">
<itemtype code="TWMProduct" extends="VariantProduct"
autocreate="true" generate="true"
jaloclass="de.hybris.platform.yacceleratorcore.jalo.TWMProduct">
<description>Total Wines Product type that contains additional
attribute specific to TWM product model.
</description>
<attributes>
<attribute qualifier="baseProduct" type="Product"
redeclare="true">
<persistence type="property"/>
<modifiers read="true" write="true" search="true"
optional="true" initial="false"/>
</attribute>
<attribute qualifier="fullName"
type="java.lang.String">
<description>shortName of the
product.</description>
<modifiers/>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
<itemtype code="TWMItem" extends="VariantProduct"
autocreate="true" generate="true"
jaloclass="de.hybris.platform.yacceleratorcore.jalo.TWMItem">
<description>Total Wines Product type that contains additional
attribute specific to TWM product model.
</description>
<attributes>
<attribute qualifier="volume" type="java.lang.String">
<description>volume of the item.</description>
<modifiers/>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
</typegroup>

Error while creating TWMProduct in hmc:

Exception in logs:
ERROR [hybrisHTTP36] [GenericItemCreateAction] create(...): Exception occured
during creation process!
de.hybris.platform.servicelayer.exceptions.ModelSavingException: missing
[baseProduct] for creating a new VariantProduct at
de.hybris.platform.servicelayer.exceptions.ModelSavingException: missing
[baseProduct] for creating a new VariantProduct at
de.hybris.platform.servicelayer.internal.converter.impl.ItemModelConverter.createN
ewItem(ItemModelConverter.java:1841)

Type Definition:

After Initialization

Exception in logs:
ERROR [hybrisHTTP36] [GenericItemCreateAction] create(...): Exception occured
during creation process!
de.hybris.platform.servicelayer.exceptions.ModelSavingException: missing
[baseProduct] for creating a new VariantProduct at
de.hybris.platform.servicelayer.exceptions.ModelSavingException: missing
[baseProduct] for creating a new VariantProduct at
de.hybris.platform.servicelayer.internal.converter.impl.ItemModelConverter.createN
ewItem(ItemModelConverter.java:1841)

Type Definition

Approach 4
Extending TWMProduct from VariantProduct and TWMItem from
VariantProduct. Making baseProduct at VariantProduct level optional.
Type definition:
<typegroup name="TWM">
<itemtype code="TWMProduct" extends="VariantProduct"
autocreate="true" generate="true"
jaloclass="de.hybris.platform.yacceleratorcore.jalo.TWMProduct">
<description>Total Wines Product type that contains additional
attribute specific to TWM product model.
</description>
<attributes>
<attribute qualifier="fullName"
type="java.lang.String">
<description>shortName of the
product.</description>
<modifiers/>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
<itemtype code="TWMItem" extends="VariantProduct"
autocreate="true" generate="true"
jaloclass="de.hybris.platform.yacceleratorcore.jalo.TWMItem">
<description>Total Wines Product type that contains additional
attribute specific to TWM product model.
</description>
<attributes>
<attribute qualifier="volume" type="java.lang.String">
<description>volume of the item.</description>
<modifiers/>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
<itemtype code="VariantProduct"
autocreate="false" generate="false">
<description>Total Wines Product type that contains additional
attribute specific to TWM product model.
</description>
<attributes>
<attribute qualifier="baseProduct" type="Product"
generate="false" autocreate="false" redeclare="true">
<persistence type="property"/>
<modifiers read="true" write="true" search="true"
optional="true" initial="false"/>

</attribute>
</attributes>
</itemtype>
</typegroup>

No effect on the type system after system update:

After Initialization

Você também pode gostar