/** * Renders the product list for the basket. * * @return string HTML Content */ protected function makeProductList() { $content = ''; $hooks = HookFactory::getHooks('Controller/BasketController', 'makeProductList'); $hookObject = HookFactory::getHook('Controller/BasketController', 'alternativePrefixId'); if (is_object($hookObject) && method_exists($hookObject, 'singleDisplayPrefixId')) { $altPrefixSingle = $hookObject->singleDisplayPrefixId(); } else { $altPrefixSingle = $this->prefixId; } $list = array(); $articleTypes = GeneralUtility::trimExplode(',', $this->conf['regularArticleTypes'], true); foreach ($articleTypes as $articleType) { $list = array_merge($list, $this->basket->getArticlesByArticleTypeUidAsUidlist($articleType)); } // ########### product list ###################### $templateMarker[] = '###' . strtoupper($this->conf['templateMarker.']['items_listview']) . '###'; $templateMarker[] = '###' . strtoupper($this->conf['templateMarker.']['items_listview2']) . '###'; $changerowcount = 0; foreach ($list as $basketItemId) { // Fill marker arrays with product/article values /** * Basket item. * * @var \CommerceTeam\Commerce\Domain\Model\BasketItem $basketItem */ $basketItem = $this->basket->getBasketItem($basketItemId); // Check stock $stockOk = true; if ($this->conf['checkStock'] == 1) { if (!$basketItem->getArticle()->hasStock($basketItem->getQuantity())) { $stockOk = false; } } // Check accessible $access = $basketItem->getProduct()->isAccessible() && $basketItem->getArticle()->isAccessible(); // Only if Stock is ok and Access is ok (could have been changed since // the article was put into the basket if ($stockOk && $access) { $safePrefix = $this->prefixId; $typoLinkConf = array(); $typoLinkConf['parameter'] = $this->conf['listPid']; $typoLinkConf['useCacheHash'] = 1; $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[catUid]=' . $basketItem->getProduct()->getMasterparentCategory(); $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[showUid]=' . $basketItem->getProduct()->getUid(); if ($this->basketHashValue) { $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[basketHashValue]=' . $this->basketHashValue; } // @todo change link building to pure TypoScript, cObj->data usage required $lokalTsProduct = $this->addTypoLinkToTypoScript($this->conf['fields.']['products.'], $typoLinkConf); $lokalTsArticle = $this->addTypoLinkToTypoScript($this->conf['fields.']['articles.'], $typoLinkConf); $this->prefixId = $altPrefixSingle; $wrapMarkerArray['###PRODUCT_LINK_DETAIL###'] = explode('|', $this->pi_list_linkSingle('|', $basketItem->getProduct()->getUid(), 1, array('catUid' => (int) $basketItem->getProduct()->getMasterparentCategory()), false, $this->conf['listPid'])); $this->prefixId = $safePrefix; $productMarkerArray = $this->generateMarkerArray($basketItem->getProductAssocArray(''), $lokalTsProduct, 'product_', 'tx_commerce_products'); $articleMarkerArray = $this->generateMarkerArray($basketItem->getArticleAssocArray(''), $lokalTsArticle, 'article_', 'tx_commerce_articles'); $this->selectAttributes = $basketItem->getProduct()->getAttributes(array(ATTRIB_SELECTOR)); $productMarkerArray['PRODUCT_BASKET_FOR_LISTVIEW'] = $this->makeArticleView($basketItem->getArticle(), $basketItem->getProduct()); $templateSelector = $changerowcount % 2; foreach ($hooks as $hookObj) { if (method_exists($hookObj, 'changeProductTemplate')) { $templateMarker = $hookObj->changeProductTemplate($templateMarker, $basketItem, $this); } } $template = $this->cObj->getSubpart($this->getTemplateCode(), $templateMarker[$templateSelector]); ++$changerowcount; $template = $this->cObj->substituteSubpart($template, '###PRODUCT_BASKET_FORM_SMALL###', ''); $markerArray = array_merge($productMarkerArray, $articleMarkerArray); foreach ($hooks as $hookObj) { if (method_exists($hookObj, 'additionalMarkerProductList')) { $markerArray = $hookObj->additionalMarkerProductList($markerArray, $basketItem, $this); } } $tempContent = $this->cObj->substituteMarkerArray($template, $markerArray, '###|###', 1); $content .= $this->substituteMarkerArrayNoCached($tempContent, $this->languageMarker, array(), $wrapMarkerArray); } else { // Remove article from basket $this->basket->deleteArticle($basketItem->getArticle()->getUid()); $this->basket->storeData(); } } return $content; }