Issues with Special Price and SQL error on product save (+ editing in cart?) #52

Selfish-zz opened this Issue Sep 2, 2011 · 27 comments


None yet


When using any version with Magento CE 1.6 I noticed at least 2 issues:

  1. When creating a configurable product and trying to save the associated products I get an error: ""SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2944-0-1' for key 1""
  2. When a product has a special price, the shopping cart shows it's 'price' field, not 'special price'.
  3. Not sure if this a bug, however, when a configurable product is in the cart, it cannot be edited = no link 'edit' there.

Please!!!!! Help us out!!!!
We are creating our first store and are really stuck on the stage of filling a catalog with products =(

Thank you!

1pxrgba commented Sep 6, 2011

I am also running Magento CE 1.6 and can confirm the above issues also exist on my installation.

We are running Magento Pro and have a related issue (just posted). I have found it is creating duplicate (or near duplicate) simple products and this is causing the logic to fail when adding to the cart.

Any news here? For now I have disabled this extension, but I would like to re-enable my configurable products as soon as possible.


Alas =( I had to disable the extension as well...

Same issue. Magento v1.6.

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '172-0-1' for key 'PRIMARY'

I had the same problem with 1.6 on our first magento store that's not yet live. This extension is essential for us to run the store so I digged into the issue and came up with the following solution:

Copy app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price/Default.php to app/code/local/Mage/Catalog/Model/Resource/Product/Indexer/Price/Default.php

Change line 533 from

$query = $select->insertFromSelect($this->getIdxTable(), array(), false);


$query = $select->insertIgnoreFromSelect($this->getIdxTable(), array(), false);

Copy app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php to app/code/local/Mage/Catalog/Model/Resource/Product/Indexer/Price.php

Change lini 464 from

$query  = $select->insertFromSelect($this->getIdxTable(), array(), false);


$query  = $select->insertIgnoreFromSelect($this->getIdxTable(), array(), false);

I'm new to Magento, there might be a better way to solve this instead of copying core files to local.

Thanks for the solution msslovi0. How does the code work? Does this still require that simple configurable products is still installed or is this an alternative way of getting the same sort of functionality without SCP.

Ok I went ahead and made the changes msslovi0 suggested although I did not have a 'local' folder, so I made the changes direct to the core files. It seems to have fixed the sql integrity problem. I didn't need to uninstall SCP.

Everything works so far, so thanks again msslovi0! Would be nice to get some feedback from the developers on this.

That's right, no need to uninstall SCP.
What the fix does is instead of sending an INSERT command to the database (which will fail if the primary key already exists) sending an INSERT IGNORE (which will just be dropped if the primary key exists). As this only affects temporary tables it is IMHO save to do so.

cschuler commented Oct 5, 2011

Thanks msslovi0!

I tried your fix, and it appears to stop the errors (but does it fix the actual problem?) I agree with sloth456... It would be nice to get some feedback from the developers on this.

For those who like to cun-n-paste (you'll need to change the path, probably)...

mkdir -p /var/www/html/magento/app/code/local/Mage/Catalog/Model/Resource/Product/Indexer/Price
cd /var/www/html/magento/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price/
cp Default.php /var/www/html/magento/app/code/local/Mage/Catalog/Model/Resource/Product/Indexer/Price/Default.php
cd /var/www/html/magento/app/code/local/Mage/Catalog/Model/Resource/Product/Indexer/Price/
gedit Default.php

(edit line 534, change to "insertIgnoreFromSelect")

cd /var/www/html/magento/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/
cp Price.php /var/www/html/magento/app/code/local/Mage/Catalog/Model/Resource/Product/Indexer/Price.php
cd /var/www/html/magento/app/code/local/Mage/Catalog/Model/Resource/Product/Indexer/
gedit Price.php

(edit line 464, change to "insertIgnoreFromSelect")


Just did the fix to both files and it works perfect on - Thanks!

@msslovi0 :: are you on the Magento forums? I posted your solution there. Thanks again

msslovi0 commented Oct 7, 2011

Yes I am. There's another thread I already postet this:

leiweke commented Oct 8, 2011

I tried this fix but after checking my system.log i got each time i load the article list and after saving a product the following entry at least 19 times : 2011-10-08T19:07:42+00:00 DEBUG (7): cpid:
but nothing behind.
it comes up after the modification of Default.php
if i have the original Magento core files and this module disabled, i got no entry in the system.log

PauGNU commented Oct 27, 2011

Hi all,

In Magento and this problem persists even after performing those changes. Any idea on how to solve it? Thanks!

@PauGNU:: Have you opened a support ticket with Magento?

PauGNU commented Oct 28, 2011

Not yet ;) I wanted to ask before opening it ;). But maybe is the best solution if I can't solve the problem.

PauGNU commented Oct 28, 2011

OK, the solution above actually does work in Magento and (something related to caches or other things were the problem).

Ahhh yes, many caching issues on first release of 1.11 especially in the cart

amadex commented Nov 8, 2011

Is there any feedback from the developers on the "The SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry..." issue?

PauGNU commented Nov 9, 2011

Sure. It's not that difficult to solve it. Read the previous message:
#52 (comment)

amadex commented Nov 9, 2011

But there is no colateral issues raised by those changes on core files?!... What is originating this issue in the module?

cschuler commented Nov 9, 2011

I think the concern here about this fix is with the "insert__Ignore__FromSelect".

"ignoring" your problems does not make them go away.

amadex commented Nov 9, 2011

Yes. That's the problem! Why this problem is being raised and how can be solved at origin and not masking the results...
Never saw a comment from the developers on this. Did they still are active on this project?...

amadex commented Nov 11, 2011

Any news on this?...

Samborg commented Dec 26, 2011

As also suggested by JoshM ( ) the best solution seems to be to replace the function call at line 58 in






Becuase in 1.6 cloneIndexTable does nothing but in previous versions when called with true as param it drops and re-creates the table, essentially the same as truncating it.

Does the above solutions work for the 'edit' function in the cart? Because I can't seem to get this working!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment