Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ryansnowden/77bddb7ecfdc814d66c0988cf469e7f3 to your computer and use it in GitHub Desktop.
Save ryansnowden/77bddb7ecfdc814d66c0988cf469e7f3 to your computer and use it in GitHub Desktop.
_ProcessService.php
public function setupForProcess($feed, $feedData) ...
// If our duplication handling is to delete - we delete all elements
// If our duplication handling is to unpublish - we unpublish all elements
if (FeedMeDuplicate::isDelete($feed) || FeedMeDuplicate::isUnpublish($feed)) {
$criteria = $this->_service->setCriteria($feed);
$return['existingElements'] = $criteria->ids();
}
...
public function finalizeAfterProcess($settings, $feed) {
if (FeedMeDuplicate::isUnpublish($feed)) {
$UnpublishIds = array_diff($settings['existingElements'], $this->_processedElements);
$criteria = $this->_service->setCriteria($feed);
$criteria->id = $UnpublishIds;
$elementsToUnpublish = $criteria->find();
if ($elementsToUnpublish) {
foreach ($elementsToUnpublish as $entry) {
if (!$entry->enabled) {
// Skip already disabled entries
continue;
}
$entry->enabled = false;
if (!craft()->entries->saveEntry($entry)) {
FeedMePlugin::log($feed->name . ': The following element could not been unpublished: '. $entry->id, LogLevel::Info, true);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment