cancel
Showing results for 
Search instead for 
Did you mean: 

Catalog Price Rule throwing exception

Catalog Price Rule throwing exception

Hello,

the customer created a new rule (which has ID 36), duplicating an old one, and now in the product view I get an exception:

Item (Mage_SalesRule_Model_Rule) with the same id "36" already exist

. If I comment in lib/Varien/Data/Collection.php:

public function addItem(Varien_Object $item)
    {
        $itemId = $this->_getItemId($item);

        if (!is_null($itemId)) {
            if (isset($this->_items[$itemId])) {
                //throw new Exception('Item ('.get_class($item).') with the same id "'.$item->getId().'" already exist');
            }
            $this->_items[$itemId] = $item;
        } else {
            $this->_addItem($item);
        }
        return $this;
    }

the product view works correctly.

What is happening here and how to solve?

Many thanks

2 REPLIES 2

Re: Catalog Price Rule throwing exception

You have to remove old one entry from your table because issue related to duplicate entry.

 

In magento you cant keep two element with same id in table.

 

You cant comment out core file its not proper solutions. This will break other functionality of magento.

 

if issue solved, Click Kudos/Accept as solutions.

 

 

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Catalog Price Rule throwing exception

The customer duplicated a rule from magento admin, and as you can see in the screenshot there are no 2 rules with same ID.

Screen Shot 2017-07-14 at 15.40.02.png

any other hint?

thanks