on 2018 Jun 22 3:45 PM
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?
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
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.Is this a Bug or the new behavior of Hybris?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.