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

Attribute on ItemType is not Removed

StefanKruk
Active Participant
0 Kudos
4,417

Good day everyone,

we are using Hybris 6.6.0.0 and added a Attribute (localized:java.lang.String) to Product with the name "newField" via items.xml We deployed the new Attribute and added Values to the Attribute. After a while we discovered that the Attribute is not needed and removed it from the item.xml. After we deployed the changes again SyncJobs were failing because the Job tried to read the Values from the removed Attribute.

In Previous Versions we added and removed Fields without Problems. Is this a Bug or the new behavior of Hybris?

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

To completely remove an attribute from hybris and DB either you need to initialize after changing items.xml or you have manually run a SQL query on DB to remove the column(or else a groovy script) and then do an update from HAC.

Run this impex for removing attribute:

 REMOVE AttributeDescriptor; qualifier[unique = true]; enclosingType(code)[unique = true]
 ; newField ; Product

And Then run this groovy script from HAC in commit mode on to remove it from DB:

  import org.springframework.jdbc.core.JdbcTemplate
     JdbcTemplate jdbcTemplate = spring.getBean("jdbcTemplate")
     try {
     int rows = jdbcTemplate.update("ALTER TABLE products DROP COLUMN {yourdatabasecolumname};")
     } catch (Exception e) {
     println(String.format("'%s'", e.getMessage()))
     }

column name in DB is usually p_attributename

tsena-n
Discoverer
0 Kudos
it worked, thanks
Former Member
0 Kudos

Hi Stefan

Can you go in your backoffice, then click System --> Types
In the editor section, search for Product and click on 'Properties' tab and see if your "newField" is present in the list of attributes. See below screenshot.

if yes, then remove your attribute from this list and then try running synchronization. Should work. Also, connect to your database via a client like MySQL workbench or DB visualizer and see if this "newField" is still present in your DB.

Let me know how you go!

priyanka_gupta2692
Participant
0 Kudos

Hi Sourabh,

I followed the same steps, but still facing issue while doing synch.

Former Member
0 Kudos

Hi ,

Is this a Bug or the new behavior of Hybris?

No,Removing the Attribute from the table .please follow the below link. [1]: https://labs.techaspect.com/index.php/2017/09/06/deleting-an-attribute-from-hybris-database/ Please accept this question if really useful to you.