Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83716

Remove item from reference_catalog if it's UID is gone or purge broken reference_catalog in Plone

I have the following situation with LinguaPlone

Now, I need to fix this situation somehow to make a1-en believe that it is canonical page again. I need to remove this one corrupted reference from the reference_catalog from "sourceUID" index which is being checked.

Questions

Upvotes: 1

Views: 197

Answers (1)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83716

Like this:

badCanonical = app.Plone.en.offering.restaurants
badCanonical.isCanonical()  # False - contains a corrupted translationOf link
badCanonical.getTranslations()   # Get list of what translations should exist
cat = app.Plone.reference_catalog
cat.getReferences(badCanonical, relationship="translationOf")  # Displays UID referring object not existing
# Delete forward relationships
for b in cat.getReferences(badCanonical, "translationOf"): cat._deleteReference(b)  
badCanonical.isCanonical()  # True - fixed
badCanonical.getTranslations() 

# Check that one of the translated versions still work
translated = app.Plone.sv["kalajoki-erbjuder"].restauranger
translated.isCanonical()
translated.getTranslations()

Upvotes: 2

Related Questions