<commit_before><?php

class Liip_Shared_Helper_Bundle extends Mage_Core_Helper_Abstract
{
    /**
     * Calculates the price of a bundle with the given selection.
     *
     * @param   object|int      The product
     * @param   array           Bundle item selection
     * @return  double|false    The price otherwise FALSE if a selection couldn't be found
     */
    public function getPrice($product, $bundleOptions, $extra = array())
    {
        if (!$product instanceof Mage_Catalog_Model_Product_Type_Price) {
            $product = Mage::getModel('catalog/product')->load($product);
        }
        $options = Mage::helper('daytrips/cart')->getOptions($product);


        // if user passed all params
        if (isset($bundleOptions['bundle_option'])) {
            $bundleOptions = $bundleOptions['bundle_option'];
        }

        $total = 0;

        $priceModel = $product->getPriceModel();
        foreach ($bundleOptions as $optionId => $selectionIds) {
            $selectionIds = (array)$selectionIds;

            foreach ($selectionIds as $selectionId) {
                $selection = $options[$optionId]->getSelectionById($selectionId);
                if ($selection) {
                    // calculate special cases
                    $price = $this->calculateProductPrice($selection, $extra);

                    if ($price === false) {
                        // default
                        $price = $priceModel->getSelectionPreFinalPrice($product, $selection, $selection->getSelectionQty());
                    }
                    $total += $price;
                } else {
                    return false;
                }
            }
        }
        return $total;
    }

    protected function calculateProductPrice($selection, $extra = array())
    {
        $price = false;

        if (Mage::helper('bergbahn')->isBergbahnTicket($selection) && $selection->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL) {
            $price = Mage::helper('jungfrau')->getPrice($selection->getPricematrix(), $extra['date']);
        }

        return $price;
    }
}
<commit_msg>re-add bundle#getOptions method that got lost on bad merge<commit_after><?php

class Liip_Shared_Helper_Bundle extends Mage_Core_Helper_Abstract
{
    /**
     * Calculates the price of a bundle with the given selection.
     *
     * @param   object|int      The product
     * @param   array           Bundle item selection
     * @return  double|false    The price otherwise FALSE if a selection couldn't be found
     */
    public function getPrice($product, $bundleOptions, $extra = array())
    {
        if (!$product instanceof Mage_Catalog_Model_Product_Type_Price) {
            $product = Mage::getModel('catalog/product')->load($product);
        }
        $options = Mage::helper('daytrips/cart')->getOptions($product);


        // if user passed all params
        if (isset($bundleOptions['bundle_option'])) {
            $bundleOptions = $bundleOptions['bundle_option'];
        }

        $total = 0;

        $priceModel = $product->getPriceModel();
        foreach ($bundleOptions as $optionId => $selectionIds) {
            $selectionIds = (array)$selectionIds;

            foreach ($selectionIds as $selectionId) {
                $selection = $options[$optionId]->getSelectionById($selectionId);
                if ($selection) {
                    // calculate special cases
                    $price = $this->calculateProductPrice($selection, $extra);

                    if ($price === false) {
                        // default
                        $price = $priceModel->getSelectionPreFinalPrice($product, $selection, $selection->getSelectionQty());
                    }
                    $total += $price;
                } else {
                    return false;
                }
            }
        }
        return $total;
    }

    protected function calculateProductPrice($selection, $extra = array())
    {
        $price = false;

        if (Mage::helper('bergbahn')->isBergbahnTicket($selection) && $selection->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL) {
            $price = Mage::helper('jungfrau')->getPrice($selection->getPricematrix(), $extra['date']);
        }

        return $price;
    }


    /**
     * Retrieves the option collection of a bundle including their respective selections.
     *
     * @param   Mage_Catalog_Model_Product      $product          The product
     * @param   bool                            $appendAll        Whether to get all selections or just those saleable
     * @return  array
     */
    public function getOptions(Mage_Catalog_Model_Product $product, $appendAll = true)
    {
        $typeInstance = $product->getTypeInstance(true);
        $typeInstance->setStoreFilter($product->getStoreId(), $product);

        $optionCollection = $typeInstance->getOptionsCollection($product);

        $optionIds = $typeInstance->getOptionsIds($product);
        $selectionIds = array();

        $selectionCollection = $typeInstance->getSelectionsCollection($optionIds, $product);

        $options = $optionCollection->appendSelections($selectionCollection, false, $appendAll);

        return $options;
    }
}

{'fraction_non_alphanumeric': 0.11558170430821788, 'fraction_numerical': 0.0003795786676788764, 'mean_word_length': 2.165165165165165, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7579274', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1306, 'n_words': 293}