How to remove or update all data records in Hybris?

Scenario 1:

I want to remove all the data from the Hybris ItemType.

Solution:

If you want to remove all records for particular itemType. Then you can do it using HAC Impex import.
  • Open HAC (/hac)
  • Go to console > ImpEx Import
  • Run the below Impex (Change MyItemType with the ItemType for which you want to remove the data)
$targetType=MyItemType
REMOVE $targetType[batchmode=true];itemtype(code)[unique=true]
;$targetType

Scenario 2:

Sometimes, you want to remove selected data based on some condition or probably want to run complex SQL query. Then we wish if we could do it by writing SQL query, as many of developers are aware of syntax and its resources are easily available.

Solution:

Yes, you can do it in Hybris HAC also. Only thing is you should know the appropriate table and attribute/fields names in DB. If you don't, you can always run the select flexible search query and can see generated SQL query.
  • Open HAC (/hac)
  • Go to console > FlexibleSearch
  • Select SQL Query tab
  • Execute your sql query. By defalut, query runs in rollbacked mode(data will not impected). You need to execute it after enabling commit mode(click on ROLLBACK) to make changes on DB.
delete from carts
Author Image

Ankitkumar Patel

Sr. SAP Hybris consultant, having 15+ years experience in SAP Commerce Cloud (Hybris), SAP Spartacus. Extensive experience in SAP Hybris development, third-party integrations, project architecture and design... Read more

Comments

  1. Great document for quick help on such basic issues.

    ReplyDelete

Post a Comment

Popular posts from this blog

Hybris flexible search query examples

How to Install temporary Hybris license?