<commit_before><?php

class Edge_AutoBuyPromotions_Model_Observer_Product
{
    public function autoBuyPromotions(Varien_Event_Observer $observer)
    {
        $rules = Mage::getModel('salesrule/rule')->getCollection()
            ->addFieldToFilter('auto_buy_promotions_product_ids', array('neq' => null));

        if (empty($rules)) {
            return;
        }

        $item = $observer->getEvent()->getQuoteItem();

        $quote = Mage::getModel('sales/quote');
        $validateItem = $quote->addProduct($item->getProduct());

        $cart = Mage::getSingleton('checkout/cart');
        foreach ($rules as $rule) {
            if ($rule->getConditions()->validate($validateItem)){
                foreach ($rule->getAutoBuyPromotionsProducts() as $product) {
                    $cartProduct = Mage::getModel('catalog/product')->load($product->getId());
                    $cart->addProduct($cartProduct);
                }<commit_msg>included buyRequest when adding product to quote - fixed error<commit_after><?php

class Edge_AutoBuyPromotions_Model_Observer_Product
{
    public function autoBuyPromotions(Varien_Event_Observer $observer)
    {
        $rules = Mage::getModel('salesrule/rule')->getCollection()
            ->addFieldToFilter('auto_buy_promotions_product_ids', array('neq' => null));

        if (empty($rules)) {
            return;
        }

        $item = $observer->getEvent()->getQuoteItem();

        $quote = Mage::getModel('sales/quote');
        $validateItem = $quote->addProduct($item->getProduct(), $item->getBuyRequest());

        $cart = Mage::getSingleton('checkout/cart');
        foreach ($rules as $rule) {
            if ($rule->getConditions()->validate($validateItem)){
                foreach ($rule->getAutoBuyPromotionsProducts() as $product) {
                    $cartProduct = Mage::getModel('catalog/product')->load($product->getId());
                    $cart->addProduct($cartProduct);
                }
{'fraction_non_alphanumeric': 0.14951849974657883, 'fraction_numerical': 0.0, 'mean_word_length': 2.847953216374269, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '5628289', 'n_tokens_mistral': 566, 'n_tokens_neox': 514, 'n_words': 81}