Best way to remove component references in pages

pharidos

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

AEM 6.4 component

Accepted Solutions (1)

Accepted Solutions (1)

gaurav3415

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)

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. 

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.