refactor content loop splitting parseResults method
This commit is contained in:
@@ -205,7 +205,7 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
/** @var \Thelia\Model\Content $content */
|
||||
foreach ($loopResult->getResultDataCollection() as $content) {
|
||||
$loopResultRow = new LoopResultRow($content);
|
||||
|
||||
$defaultFolderId = $content->getDefaultFolderId();
|
||||
$loopResultRow->set("ID" , $content->getId())
|
||||
->set("IS_TRANSLATED" , $content->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $this->locale)
|
||||
@@ -218,44 +218,57 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
->set("META_DESCRIPTION" , $content->getVirtualColumn('i18n_META_DESCRIPTION'))
|
||||
->set("META_KEYWORDS" , $content->getVirtualColumn('i18n_META_KEYWORDS'))
|
||||
->set("POSITION" , $content->getPosition())
|
||||
->set("DEFAULT_FOLDER" , $content->getDefaultFolderId())
|
||||
->set("DEFAULT_FOLDER" , $defaultFolderId)
|
||||
|
||||
->set("VISIBLE" , $content->getVisible())
|
||||
;
|
||||
|
||||
|
||||
if ($this->getBackend_context() || $this->getWithPrevNextInfo()) {
|
||||
$defaultFolderId = $content->getDefaultFolderId();
|
||||
// Find previous and next category
|
||||
$previous = ContentQuery::create()
|
||||
->joinContentFolder()
|
||||
->where('ContentFolder.folder_id = ?', $defaultFolderId)
|
||||
->filterByPosition($content->getPosition(), Criteria::LESS_THAN)
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$next = ContentQuery::create()
|
||||
->joinContentFolder()
|
||||
->where('ContentFolder.folder_id = ?', $defaultFolderId)
|
||||
->filterByPosition($content->getPosition(), Criteria::GREATER_THAN)
|
||||
->orderByPosition(Criteria::ASC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$loopResultRow
|
||||
->set("HAS_PREVIOUS" , $previous != null ? 1 : 0)
|
||||
->set("HAS_NEXT" , $next != null ? 1 : 0)
|
||||
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
|
||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||
;
|
||||
}
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
$loopResult->addRow($this->findNextPrev($loopResultRow, $content, $defaultFolderId));
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResultRow $loopResultRow
|
||||
* @param \Thelia\Model\Content $content
|
||||
* @param $defaultFolderId
|
||||
* @return LoopResultRow
|
||||
*/
|
||||
private function findNextPrev(LoopResultRow $loopResultRow, \Thelia\Model\Content $content, $defaultFolderId)
|
||||
{
|
||||
if ($this->getBackend_context() || $this->getWithPrevNextInfo()) {
|
||||
|
||||
// Find previous and next category
|
||||
$previous = ContentQuery::create()
|
||||
->joinContentFolder()
|
||||
->where('ContentFolder.folder_id = ?', $defaultFolderId)
|
||||
->filterByPosition($content->getPosition(), Criteria::LESS_THAN)
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$next = ContentQuery::create()
|
||||
->joinContentFolder()
|
||||
->where('ContentFolder.folder_id = ?', $defaultFolderId)
|
||||
->filterByPosition($content->getPosition(), Criteria::GREATER_THAN)
|
||||
->orderByPosition(Criteria::ASC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$loopResultRow
|
||||
->set("HAS_PREVIOUS" , $previous != null ? 1 : 0)
|
||||
->set("HAS_NEXT" , $next != null ? 1 : 0)
|
||||
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
|
||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||
;
|
||||
}
|
||||
|
||||
return $loopResultRow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user