Created
April 6, 2017 07:11
-
-
Save ryansnowden/77bddb7ecfdc814d66c0988cf469e7f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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