Best way to remove component references in pages

Avatar

Avatar
Boost 1
Level 1
pharidos
Level 1

Likes

2 likes

Total Posts

11 posts

Correct reply

0 solutions
Top badges earned
Boost 1
Validate 1
Ignite 1
Give Back
View profile

Avatar
Boost 1
Level 1
pharidos
Level 1

Likes

2 likes

Total Posts

11 posts

Correct reply

0 solutions
Top badges earned
Boost 1
Validate 1
Ignite 1
Give Back
View profile
pharidos
Level 1

07-05-2020

Hi,

We have a component that needs to be removed but there are almost 100+ pages referencing the component, what is the best way to remove the component references from all those pages?

 

AEM 6.4.6.0

 

Thanks,

Prabu

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 1
Level 1
gaurav3415
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Level 1
gaurav3415
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

1 solution
Top badges earned
Affirm 1
View profile
gaurav3415
Level 1

07-05-2020

From querydebug all the paths of pages containing component reference can be fetched, Below is the sample query-

path=/content
1_property=sling:resourceType
1_property.value=<path/of/the/component>
1_property.operation=like

 

Create a servlet/scheduler 

-hit the path

-get the resource

-iterate over its nodes

-delete the component node

-save the session.

 

 

 

Answers (2)

Answers (2)

Avatar

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

645 likes

Total Posts

607 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

645 likes

Total Posts

607 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
BrianKasingli
MVP

08-05-2020

By creating a servlet using JCR_SQL2. The servlet will query all the pages for any pages that have the existing component's "sling:resourceType", and delete the node using the session object. Please vigorously test this in Dev, QA, Staging, before calling from Prod. 

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

484 likes

Total Posts

1,048 posts

Correct reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

484 likes

Total Posts

1,048 posts

Correct reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

08-05-2020

I would write a servlet , query the pages with component reference and remove the component via servlet. The steps would be pretty much same as what @gaurav3415  mentioned above.