Hinzufügen von (bundle) Artikeln

Hallo,
ich bin gerade dabei ein Modul für Artikel-Bundles zu schreiben, welches es ermöglicht mehrere Artikel an ein Produkt anzuhängen.

Dafür habe ich “oxbasket” extended.

Folgende schreibweise funktioniert (es werden artikel zum Warenkorb hinzugefügt)


public function addToBasket( $sProductID, $dAmount, $aSel = null, $aPersParam = null, $blOverride = false, $blBundle = false, $sOldBasketItemId = null ){
   [...]
   parent::addToBasket($articleID,  $amount);
   [...]
}

Sobald ich aber versuche die Artikel als Bundeled-Artikel einzufügen funktioniert es nicht mehr:


public function addToBasket( $sProductID, $dAmount, $aSel = null, $aPersParam = null, $blOverride = false, $blBundle = false, $sOldBasketItemId = null ){
   [...]
   parent::addToBasket($articleID,  $amount, null, null, false, true);
   [...]
}

Was mache ich da blos falsch?
Diese Infohilft mir leider auch nicht weiter

Danke für eure Hilfe

Habe inzwischen eine Lösung gefunden. Anstatt addToBasket zu überschreiben ist es besser die Methode _addBundles zu überschreiben.

Das ganze sieht dann so aus:


protected function _addBundles()
	{
		// iterating through articles and binding bundles
		foreach ( $this->_aBasketContents as $key => $oBasketItem ) {
			try {
				// adding discount type bundles
				if ( !$oBasketItem->isDiscountArticle() && !$oBasketItem->isBundle() ) {
					$aBundles = $this->_getItemBundles( $oBasketItem );
				} else {
					continue;
				}
	
				$this->_addBundlesToBasket( $aBundles );
	
				// adding item type bundles
				$aBundles = $this->_getArticleBundles( $oBasketItem );

				// adding bundles to basket
				$this->_addBundlesToBasket( $aBundles );
				
				
				//my changes :)
				$db = oxDB::getDb();
				$db_res = $db->getAll("SELECT article, SUM(amount) FROM my_article_in_bundle WHERE bundle IN (SELECT bundle FROM my_bundle2article WHERE article = ".$db->quote($oBasketItem->getProductId()).") GROUP BY article" );
				
				
				//$aBundles = array();
				foreach($db_res as $row){
					//echo $row[0]." - ".$row[1]."<br>";
					$bi = parent::addToBasket($row[0],  $row[1]*$oBasketItem->getAmount(), null, null, false, true);
					$bi->setAsDiscountArticle( true );
				}
				// end of my changes :)
				
			} catch ( oxNoArticleException $oEx ) {
				$this->removeItem( $key );
				oxUtilsView::getInstance()->addErrorToDisplay( $oEx );
			} catch( oxArticleInputException $oEx ) {
				$this->removeItem( $key );
				oxUtilsView::getInstance()->addErrorToDisplay( $oEx );
			}
		}
	
		// adding global basket bundles
		if ( $aBundles = $this->_getBasketBundles() ) {
			$this->_addBundlesToBasket( $aBundles );
		}
	
	}

Ist diese Lösung eurer Meinung so schön?

Hätte eventuell jemand Interesse an dem Modul? (Es ermöglicht mehrere Produkte als Bundle an einen Artikel zu hängen.) Würde mich sehr über euer Feedback freuen.