2

I want to create custom banner component, extended from SimpleBannerComponent. But after I created it, it fails to create in Backoffice, see below.

1) I added this item to my *-items.xml file.

<itemtype code="PromotionBannerCMSComponent" autocreate="true" generate="true" extends="SimpleBannerComponent"
          jaloclass="my.package.core.jalo.components.PromotionBannerCMSComponent">
    <description>Promotion banner component</description>
    <deployment table="PromotionBanners" typecode="15301"/>
    <attributes>
        <attribute qualifier="code" type="java.lang.String">
            <persistence type="property"/>
            <modifiers/>
            <description>Banner name (not unique)</description>
        </attribute>
        <attribute qualifier="title" type="localized:java.lang.String">
            <description>Title</description>
            <modifiers read="true" write="true" search="true" initial="true"/>
            <persistence type="property"/>
        </attribute>
        <attribute qualifier="position" type="SimpleBannerPositionEnum">
            <description>Banner position</description>
            <modifiers optional="true" initial="true"/>
            <persistence type="property"/>
        </attribute>
        <attribute qualifier="altText" type="localized:java.lang.String">
            <description>Banner alt text</description>
            <modifiers optional="true" initial="true"/>
            <persistence type="property"/>
        </attribute>
        <attribute qualifier="titleSecondary" type="localized:java.lang.String">
            <description>Title secondary</description>
            <persistence type="property" />
            <modifiers />
        </attribute>
        <attribute qualifier="urlLoc" type="localized:java.lang.String">
            <description>Banner url</description>
            <persistence type="property" />
            <modifiers />
        </attribute>
    </attributes>
</itemtype>

2) I did ant clean all, restarted server, I've run HAC -> Update with my custom extension checked and with Update running system also checked. Then I did a server restart again.

3) I wanted to create the component in the Backoffice WCMS->Components->Add, but it fails with error - I've turned on the flexible.search.exception.show.query.details to see it:

 [ConfigurableFlowController] Object  could not be saved
com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException: Object  could not be saved

and

Caused by: de.hybris.platform.servicelayer.exceptions.ModelSavingException: [de.hybris.platform.servicelayer.interceptor.impl.UniqueAttributesInterceptor@716c1b71]: unexpected validator error: SQL search error - Unknown column 'item_t0.p_catalogversion' in 'where clause' query = 'SELECT  item_t0.PK  FROM cmscomponent item_t0 WHERE
.
.

Now I can't create even the basic SimpleBannerComponent, neither the other components. Is there something wrong with the update? I'm using Hybris 1811.18.

Stepan Tuhacek
  • 219
  • 5
  • 18

3 Answers3

2

Turns out I had an old deployment table which collided with this component, somehow it didn't show an error during ant clean all.

So I run in HAC delete from ydeployments where typecode=XX; (XX is typecode found in HAC) and started over with almost the same deployment, except I removed jaloclass and deployment table description:

<itemtype code="PromotionBannerCMSComponent" autocreate="true" generate="true" extends="SimpleBannerComponent">
    <description>Promotion banner component</description>
    <attributes>
        <attribute qualifier="code" type="java.lang.String">
            <persistence type="property"/>
            <modifiers/>
            <description>Banner name (not unique)</description>
        </attribute>
        <attribute qualifier="title" type="localized:java.lang.String">
            <description>Title</description>
            <modifiers read="true" write="true" search="true" initial="true"/>
            <persistence type="property"/>
        </attribute>
        <attribute qualifier="position" type="SimpleBannerPositionEnum">
            <description>Banner position</description>
            <modifiers optional="true" initial="true"/>
            <persistence type="property"/>
        </attribute>
        <attribute qualifier="altText" type="localized:java.lang.String">
            <description>Banner alt text</description>
            <modifiers optional="true" initial="true"/>
            <persistence type="property"/>
        </attribute>
        <attribute qualifier="titleSecondary" type="localized:java.lang.String">
            <description>Title secondary</description>
            <persistence type="property" />
            <modifiers />
        </attribute>
        <attribute qualifier="urlLoc" type="localized:java.lang.String">
            <description>Banner url</description>
            <persistence type="property" />
            <modifiers />
        </attribute>
    </attributes>
</itemtype>
Stepan Tuhacek
  • 219
  • 5
  • 18
0

One of the problem that I am able to see is that the deployment table should be deleted since the best practice is to provide one only when extending the GenericItem(when you do not specify a parent this type will be automatically set). So your definition should look like this:

<itemtype code="PromotionBannerCMSComponent" autocreate="true" generate="true" extends="SimpleBannerComponent"
      jaloclass="my.package.core.jalo.components.PromotionBannerCMSComponent">
<description>Promotion banner component</description>
<attributes>
    <attribute qualifier="code" type="java.lang.String">
        <persistence type="property"/>
        <modifiers/>
        <description>Banner name (not unique)</description>
    </attribute>
    <attribute qualifier="title" type="localized:java.lang.String">
        <description>Title</description>
        <modifiers read="true" write="true" search="true" initial="true"/>
        <persistence type="property"/>
    </attribute>
    <attribute qualifier="position" type="SimpleBannerPositionEnum">
        <description>Banner position</description>
        <modifiers optional="true" initial="true"/>
        <persistence type="property"/>
    </attribute>
    <attribute qualifier="altText" type="localized:java.lang.String">
        <description>Banner alt text</description>
        <modifiers optional="true" initial="true"/>
        <persistence type="property"/>
    </attribute>
    <attribute qualifier="titleSecondary" type="localized:java.lang.String">
        <description>Title secondary</description>
        <persistence type="property" />
        <modifiers />
    </attribute>
    <attribute qualifier="urlLoc" type="localized:java.lang.String">
        <description>Banner url</description>
        <persistence type="property" />
        <modifiers />
    </attribute>
</attributes>

Try to initialize the system in order to test this in order to delete the old type and its associated table from the database.

dj_frunza
  • 1,553
  • 3
  • 17
  • 28
  • 1
    `One of the problem that I am able to see is that the deployment table should be deleted ` - This is not the root cause of the problem. It is just that putting an additional deployment table, in this case, will require the FS query to create some more joins. – Arvind Kumar Avinash May 25 '20 at 14:06
0

I tested your code with 1905.13, and it's working fine. (I needed to adjust the package name and add the SimpleBannerPositionEnum definition) I simply did "ant all" in command-line and "Update running system" during Platform Update (without any extension checked). I'm able to create an instance of PromotionBannerCMSComponent in backoffice.

Have you tried initializing and see if it works on your side? Otherwise, you may need to share more about the error / stacktrace.

geffchang
  • 3,279
  • 2
  • 32
  • 58