/** * Find all products we need to list. * @param array|null * @return array */ protected function findProducts($arrCacheIds = null) { $arrIds = array(0); $objProduct = Product::findAvailableByIdOrAlias(Input::getAutoItem('product')); if (null === $objProduct) { return array(); } $objRelated = RelatedProduct::findByProductAndCategories($objProduct, $this->iso_related_categories); if (null !== $objRelated) { while ($objRelated->next()) { $ids = trimsplit(',', $objRelated->products); if (!empty($ids) && is_array($ids)) { $arrIds = array_unique(array_merge($arrIds, $ids)); } } } $objProducts = Product::findAvailableByIds($arrIds, array('order' => \Database::getInstance()->findInSet(Product::getTable() . '.id', $arrIds))); return null === $objProducts ? array() : $objProducts->getModels(); }
/** * Generate module * @return void */ protected function compile() { global $objPage; global $objIsotopeListPage; $objProduct = Product::findAvailableByIdOrAlias(\Haste\Input\Input::getAutoItem('product')); if (null === $objProduct) { $objHandler = new $GLOBALS['TL_PTY']['error_404'](); $objHandler->generate($objPage->id); exit; } $arrConfig = array('module' => $this, 'template' => $this->iso_reader_layout ?: $objProduct->getRelated('type')->reader_template, 'gallery' => $this->iso_gallery ?: $objProduct->getRelated('type')->reader_gallery, 'buttons' => deserialize($this->iso_buttons, true), 'useQuantity' => $this->iso_use_quantity, 'jumpTo' => $objIsotopeListPage ?: $objPage); if (\Environment::get('isAjaxRequest') && \Input::post('AJAX_MODULE') == $this->id && \Input::post('AJAX_PRODUCT') == $objProduct->getProductId()) { $objResponse = new HtmlResponse($objProduct->generate($arrConfig)); $objResponse->send(); } $arrCSS = deserialize($objProduct->cssID, true); $this->Template->product = $objProduct->generate($arrConfig); $this->Template->product_id = $arrCSS[0] != '' ? ' id="' . $arrCSS[0] . '"' : ''; $this->Template->product_class = trim('product ' . ($objProduct->isNew() ? 'new ' : '') . $arrCSS[1]); $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $this->addMetaTags($objProduct); $this->addCanonicalProductUrls($objProduct); }
/** * Show product name in breadcrumb * * @param array $arrItems * @param object $objModule * * @return array */ public function addProductToBreadcrumb($arrItems, $objModule) { if (\Haste\Input\Input::getAutoItem('product', false, true) != '') { $objProduct = Product::findAvailableByIdOrAlias(\Haste\Input\Input::getAutoItem('product', false, true)); if (null !== $objProduct) { global $objPage; global $objIsotopeListPage; $last = count($arrItems) - 1; // If we have a reader page, rename the last item (the reader) to the product title if (null !== $objIsotopeListPage) { $arrItems[$last]['title'] = $this->prepareMetaDescription($objProduct->meta_title ?: $objProduct->name); $arrItems[$last]['link'] = $objProduct->name; } else { $arrItems[$last]['href'] = \Controller::generateFrontendUrl($arrItems[$last]['data']); $arrItems[$last]['isActive'] = false; $arrItems[] = array('isRoot' => false, 'isActive' => true, 'href' => $objProduct->generateUrl($objPage), 'title' => $this->prepareMetaDescription($objProduct->meta_title ?: $objProduct->name), 'link' => $objProduct->name, 'data' => $objPage->row()); } } } return $arrItems; }
/** * Find product based on InsertTag parameter * * @param int $id * * @return IsotopeProduct|null */ private function findCurrentProduct($id = null) { if (null !== $id) { return Product::findAvailableByPk($id); } elseif (Product::getActive() !== null) { return Product::getActive(); } else { return Product::findAvailableByIdOrAlias(Input::getAutoItem('product', false, true)); } }
/** * The ids of all pages we take care of. This is what should later be used eg. for filter data. * * @return array */ protected function findCategories() { if (null === $this->arrCategories) { if ($this->defineRoot && $this->rootPage > 0) { $objPage = \PageModel::findWithDetails($this->rootPage); } else { global $objPage; } $t = \PageModel::getTable(); $arrCategories = null; $arrUnpublished = array(); $strWhere = "{$t}.type!='error_403' AND {$t}.type!='error_404'"; if (!BE_USER_LOGGED_IN) { $time = time(); $objUnpublished = \PageModel::findBy(array("({$t}.start!='' AND {$t}.start>{$time}) OR ({$t}.stop!='' AND {$t}.stop<{$time}) OR {$t}.published=?"), array('')); $arrUnpublished = $objUnpublished->fetchEach('id'); //$strWhere .= " AND ($t.start='' OR $t.start<$time) AND ($t.stop='' OR $t.stop>$time) AND $t.published='1'"; } switch ($this->iso_category_scope) { case 'global': $arrCategories = array($objPage->rootId); $arrCategories = \Database::getInstance()->getChildRecords($objPage->rootId, 'tl_page', false, $arrCategories, $strWhere); $arrCategories = array_diff($arrCategories, $arrUnpublished); break; case 'current_and_first_child': $arrCategories = \Database::getInstance()->execute("SELECT id FROM tl_page WHERE pid={$objPage->id} AND {$strWhere}")->fetchEach('id'); $arrCategories[] = $objPage->id; break; case 'current_and_all_children': $arrCategories = array($objPage->id); $arrCategories = \Database::getInstance()->getChildRecords($objPage->id, 'tl_page', false, $arrCategories, $strWhere); $arrCategories = array_diff($arrCategories, $arrUnpublished); break; case 'parent': $arrCategories = array($objPage->pid); break; case 'product': /** @var \Isotope\Model\Product\Standard $objProduct */ $objProduct = Product_Model::findAvailableByIdOrAlias(\Haste\Input\Input::getAutoItem('product')); if ($objProduct !== null) { $arrCategories = $objProduct->getCategories(true); } else { $arrCategories = array(0); } break; case 'article': $arrCategories = array($GLOBALS['ISO_CONFIG']['current_article']['pid'] ?: $objPage->id); break; case '': case 'current_category': $arrCategories = array($objPage->id); break; default: if (isset($GLOBALS['ISO_HOOKS']['findCategories']) && is_array($GLOBALS['ISO_HOOKS']['findCategories'])) { foreach ($GLOBALS['ISO_HOOKS']['findCategories'] as $callback) { $objCallback = \System::importStatic($callback[0]); $arrCategories = $objCallback->{$callback}[1]($this); if ($arrCategories !== false) { break; } } } break; } $this->arrCategories = empty($arrCategories) ? array(0) : $arrCategories; } return $this->arrCategories; }