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.