cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Custom attributes not displayed in the right tab - Commerce Backoffice

0 Kudos
1,980

Hi guys,

just tried to create custom properties for products in my local commerce instance (2105). I want two new attributes to be displayed in the "extended attributes" tab under the "IDs & Units" section.

Another, third attribute should be displayed in the "administration" tab (unbound). I created a new extension which is called "mycustombackoffice". My "mycustombackoffice-items.xml" looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<items 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			xsi:noNamespaceSchemaLocation="items.xsd">

	<itemtypes>
		<itemtype generate="false"
		   code="Product"
		   autocreate="false">
			<attributes>
				<attribute qualifier="productCustomerFeedback" type="java.lang.String">
					<description>Feedback from Customer</description>
					<persistence type="property"/>
				</attribute>
                
                <attribute qualifier="productPackagingQuality" type="java.lang.String">
					<description>Quality of the product</description>
					<persistence type="property"/>
				</attribute>
                
                <attribute qualifier="productContent" type="java.lang.String">
					<description>Product Content</description>
					<persistence type="property"/>
				</attribute>
			</attributes>
		</itemtype>
	</itemtypes>
</items><br>

Here you can see that I want to create the 3 attributes "productCustomerFeedback", "productPackageQuality" and "productContent".

The "mycustombackoffice-backoffice-config.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://www.hybris.com/cockpit/config">
    <context merge-by="type" parent="GenericItem" type="Product" component="editor-area" module="platformbackoffice">
		<ea:editorArea name="">
			<ea:tab name="hmc.tab.product.extendedattributes" position="26">
				<ea:section name="hmc.section.product.ids">
					<ea:attribute qualifier="productCustomerFeedback"/>
					<ea:attribute qualifier="productPackagingQuality"/>
				</ea:section>
			</ea:tab>
		</ea:editorArea>
    </context>
</config><br>

The two attributes "productCustomerFeedback" and "productPackagingQuality" should be displayed in the "extended attributes" tab under the product.ids section.

I also created the labels in the labels_en.properties file:

hmc.tab.concert=Concert
hmc.section.concert=Concert Variables<br>

After rebuilding the site, starting the server and updating commerce, I can see that the attributes have been added to the database:

Unfortunately, the attributes are not displayed in the right position in backoffice. They are all displayed in the "administration" tab, but two of them should be in "extended attributes".

What did I miss here?

Thanks a lot and regards

Dennis

Accepted Solutions (0)

Answers (6)

Answers (6)

former_member634058
Active Participant
0 Kudos

Hi Dennis,

Your mycustombackoffice-backoffice-config.xml does not have the correct header entries and I get the following error on applying your code:

Could not load cockpit configuration root element; creating new one

Please check other OOB backoffice-config.xml, and review your code. Also, please look for any code error when you are building the code and starting the server.

It should be like,

<config xmlns="http://www.hybris.com/cockpit/config"
        xmlns:ea="http://www.hybris.com/cockpitng/component/editorArea">

After correcting your code, following is what I can see:

Hope this helps.

Thanks.

mansurarisoy
Contributor
0 Kudos

Hi dannis,

Can you investigate the loading order of backoffice modules when you press Reset Everything button? I think this may be related with loading order of the extensions. There should be logs with "CockpitNG loading default configuration for module", this will tell you the loading order. To ensure that your extension is loaded after pcmbackoffice, add the following line to localextensions.xml file of your custom extension mycustombackoffice

<requires-extension name="pcmbackoffice"/>

Hope this helps,

0 Kudos

This is how my mycustombackoffice-backoffice-config.xml looks like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
 Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved
-->
<config xmlns:ea="http://www.hybris.com/cockpitng/component/editorArea">
	<!-- mycustombackoffice UI configuration should be provided here -->
    <context merge-by="type" parent="GenericItem" type="Product" component="editor-area" module="mycustombackoffice">
		<ea:editorArea name="">
			<ea:tab name="hmc.tab.product.extendedattributes" position="26">
				<ea:section name="hmc.section.product.ids">
					<ea:attribute qualifier="productCustomerFeedback"/>
					<ea:attribute qualifier="productPackagingQuality"/>
				</ea:section>
			</ea:tab>
		</ea:editorArea>
    </context>
</config>

And this is my mycustombackoffice-items.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved
-->
<!--
	ATTENTION: This is just an example file. You have to edit it according to your needs.
-->

<items 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			xsi:noNamespaceSchemaLocation="items.xsd">
	<itemtypes>
		<itemtype generate="false"
		   code="Product"
		   autocreate="false">
			<attributes>
				<attribute qualifier="productCustomerFeedback" type="java.lang.String">
					<description>Feedback from Customer</description>
					<persistence type="property"/>
				</attribute>
                
                <attribute qualifier="productPackagingQuality" type="java.lang.String">
					<description>Quality of the product</description>
					<persistence type="property"/>
				</attribute>
                
                <attribute qualifier="productContent" type="java.lang.String">
					<description>Product Content</description>
					<persistence type="property"/>
				</attribute>
			</attributes>
		</itemtype>
	</itemtypes>
</items>

I think I still miss something but can't figure out what...

0 Kudos

Hi guys, thanks a lot for your answers and for your help. Can you tell me how to check the log for errors, since it is still not working after I made the changes.

former_member634058
Active Participant
0 Kudos

Hi Dennis,

A few observations from my side:

1. In mycustombackoffice-backoffice-config.xml, you should do the following changes/add the following things.

  • module should be "mycustombackoffice" instead of "platformbackoffice"
  • When using ea:editorarea, entry should be made in config for xmlns:ea="http://www.hybris.com/cockpitng/component/editorArea"

2. For localization of items.xml attributes, do not make entry inside labels_en.properties. Instead it should be in mycustombackoffice-locales_en.properties. labels_en.properties are for localization of backoffice tabs and sections, as you have mentioned earlier. But according to your code, none is needed, since all the label properties are already defined OOB. The entries in your labels_en.properties do not match any code either in items.xml or backoffice config.xml

3. Also, as mentioned by Kai above <br> tags are not needed anywhere, wherever you have mentioned in your code. Please check if somehow they have been added by page break.

4. Once you have made changes in backoffice config files, you will need to rebuild the backoffice extensions, either by adding properties, as Kai has mentioned above, or by going to orchestrate mode (F4) after server restart and logging into backoffice as admin and then doing reset all option, or by doing system update from hac by selecting the backoffice extensions.

I think this will be enough to get the attributes at your intended location. Happy coding!!


Thanks.

kai_unewisse
Active Contributor
0 Kudos

Hi,

Remove the <br> behind </config>.

You should add in the config tag: xmlns:ea="http://www.hybris.com/cockpitng/component/editorArea"

I suggest adding this to your local.properties file:

backoffice.cockpitng.development.mode=true
backoffice.cockpitng.validate.cockpitConfig.onstartup=true

1.entry will add some actions/icons in the backoffice header

2.entry will validate the config file at startup. check the log for errors.

Good luck,
Kai