/** * Add product items to the indexer * @param array * @param integer * @param boolean * @return array */ public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false) { $arrRoot = array(); if ($intRoot > 0) { $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page'); } $time = time(); $arrProcessed = array(); // Get all catalog categories $objCatalog = \ProductCatalogModel::findByProtected(''); // Walk through each archive if ($objCatalog !== null) { while ($objCatalog->next()) { // Skip catalog categories without target page if (!$objCatalog->jumpTo) { continue; } // Skip catalog categories outside the root nodes if (!empty($arrRoot) && !in_array($objCatalog->jumpTo, $arrRoot)) { continue; } // Get the URL of the jumpTo page if (!isset($arrProcessed[$objCatalog->jumpTo])) { $objParent = \PageModel::findWithDetails($objCatalog->jumpTo); // The target page does not exist if ($objParent === null) { continue; } // The target page has not been published (see #5520) if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop < $time) { continue; } // The target page is exempt from the sitemap (see #6418) if ($blnIsSitemap && $objParent->sitemap == 'map_never') { continue; } // Set the domain (see #6421) $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/'; // Generate the URL $arrProcessed[$objCatalog->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language); } $strUrl = $arrProcessed[$objCatalog->jumpTo]; // Get the items $objProduct = \ProductModel::findPublishedByPid($objCatalog->id); if ($objProduct !== null) { while ($objProduct->next()) { $objElement = \ContentModel::findPublishedByPidAndTable($objProduct->id, 'tl_product'); if ($objElement !== null) { $arrPages[] = $this->getLink($objProduct, $strUrl); } } } } } return $arrPages; }
/** * Sort out protected archives * @param array * @return array */ protected function sortOutProtected($arrCatalogs) { if (BE_USER_LOGGED_IN || !is_array($arrCatalogs) || empty($arrCatalogs)) { return $arrCatalogs; } $this->import('FrontendUser', 'User'); $objCatalog = \ProductCatalogModel::findMultipleByIds($arrCatalogs); $arrCatalogs = array(); if ($objCatalog !== null) { while ($objCatalog->next()) { if ($objCatalog->protected) { if (!FE_USER_LOGGED_IN) { continue; } $groups = deserialize($objCatalog->groups); if (!is_array($groups) || empty($groups) || !count(array_intersect($groups, $this->User->groups))) { continue; } } $arrCatalogs[] = $objCatalog->id; } } return $arrCatalogs; }