마스터 및 웹에서 항목을 삭제하고 solr 인덱스에서 각 항목을 삭제하려는 비즈니스 요구 사항을 발견했습니다. 비즈니스는 형제 또는 부모가 변경 될 수 있으므로 부모 항목을 게시하고 싶지 않아 onPublishEndAsync , onPublishEndAsyncSingleInstance onPublishEndAsyncPreview 와 같은 전략을 트리거 할 수 없습니다. 아래와 같은 것을 시도하고 있지만 작동하지 않습니다.
var ParentItem = item.Parent;
using (new EditContext(item))
{
if (Sitecore.Configuration.Settings.RecycleBinActive)
item.Recycle();
else
item.Delete();
}
if (item == null)
return;
ISearchIndex index = ContentSearchManager.GetIndex((SitecoreIndexableItem)ParentItem );
if (index == null)
return;
index.Refresh(new SitecoreIndexableItem(ParentItem )); or
index.RefreshAsync(new SitecoreIndexableItem(item), IndexingOptions.ForcedIndexing, new System.Threading.CancellationToken());
사이트 코어 로그 또는 solr 로그 파일에서 오류가 발생하지 않지만 색인이 항목을 삭제하지 않습니다.
항목을 게시 할 수 없음으로 표시하고 게시 한 다음 ( web
데이터베이스와 web
인덱스 에서 항목 이 제거됨) 삭제할 수 있습니다.
다음은 모든 게시 대상 데이터베이스에서 항목을 게시 취소 한 샘플 코드입니다.
using (new SecurityDisabler())
{
var targets = PublishManager.GetPublishingTargets(item.Database)
.Select(i => Database.GetDatabase(i[FieldIDs.PublishingTargetDatabase]))
.ToArray();
var languages = LanguageManager.GetLanguages(item.Database).ToArray();
item.Editing.BeginEdit();
item.Publishing.NeverPublish = true;
item.Editing.EndEdit();
var handle = PublishManager.PublishItem(item, targets, languages, false, false);
PublishManager.WaitFor(handle);
}
그냥 실행 item.Recycle
하거나 Delete
후에.
얼마 전에 저는 한 번의 클릭으로 항목을 "삭제 및 게시 취소"하는 리본 버튼을 추가하는 방법을 설명하는 블로그 게시물을 작성했습니다. 여기에서 찾을 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다