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

Attribute on ItemType is not Removed

StefanKruk
Active Participant
0 Kudos
4,439

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?

View Entire Topic
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