コード例 #1
0
    /**
     * Renders the product list for the basket
     *
     * @return string HTML Content
     */
    protected function makeProductList()
    {
        $content = '';
        $hookObjectsArr = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['makeProductList'])) {
            GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/pi2/class.tx_commerce_pi2.php\'][\'makeProductList\']
				is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Controller/BasketController.php\'][\'makeProductList\']
			');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['makeProductList'] as $classRef) {
                $hookObjectsArr[] =& GeneralUtility::getUserObj($classRef);
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['makeProductList'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['makeProductList'] as $classRef) {
                $hookObjectsArr[] =& GeneralUtility::getUserObj($classRef);
            }
        }
        $hookObject = NULL;
        if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['alternativePrefixId']) {
            GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/pi2/class.tx_commerce_pi2.php\'][\'alternativePrefixId\']
				is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Controller/BasketController.php\'][\'alternativePrefixId\']
			');
            $hookObject = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['alternativePrefixId']);
        }
        if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['alternativePrefixId']) {
            $hookObject = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['alternativePrefixId']);
        }
        if (method_exists($hookObject, 'SingeDisplayPrefixId')) {
            $altPrefixSingle = $hookObject->SingeDisplayPrefixId();
        } 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 $basketItem Tx_Commerce_Domain_Model_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 ($hookObjectsArr 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 ($hookObjectsArr 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;
    }