Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mage_Core_Exception #35

Open
JanWGK opened this issue Jul 3, 2018 · 3 comments
Open

Mage_Core_Exception #35

JanWGK opened this issue Jul 3, 2018 · 3 comments

Comments

@JanWGK
Copy link

JanWGK commented Jul 3, 2018

Hi Simon,

the module installs without any errors and seems to work, but if I run the setup script manually via n98-magerun I am getting the following error:

Error in file: "/htdocs/app/code/community/CustomGento/ConfigurableTierPrices/sql/customgento_configurabletierprices_setup/upgrade-2.0.0-2.1.0.php" - SQLSTATE[2300
0]: Integrity constraint violation: 1062 Duplicate entry '9-General' for key 'UNQ_EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_NAME', query was: INSERT INTO eav_attribute_group (a ttribute_set_id, attribute_group_name, default_id, sort_order) VALUES (?, ?, ?, ?)

The same error appears, if I try to clear the cache via Magento admin.

Any ideas?

@sprankhub
Copy link
Member

Weird! It seems that

is an issue for you. Never heard of that before. Usually, this should work. Did you rename / delete / re-create the General attribute group?

As a quick fix, remove the line and run the setup scripts. Afterwards, add the attribute to each attribute set manually.

@JanWGK
Copy link
Author

JanWGK commented Jul 4, 2018

Thanks for the fix, that worked. I do not know of somebody changing the general attribute group, but the database has a long history and I noticed that there are several duplicates of system attribute groups in the table...

For your info, I just installed another module which is adding an attribute to all attribute sets without any issues like this:

<?php

$installer = new Mage_Eav_Model_Entity_Setup($this->_resourceName);
$installer->startSetup();

$installer->addAttribute('catalog_product', 'simple_price', array(
    'type'              => 'int',
    'backend'           => '',
    'frontend'          => '',
    'label'             => 'Use price of simple products',
    'note'              => 'If set to "Yes", full price of associated products of configurables is used for calculations and front end display instead of price difference.',
    'input'             => 'select',
    'class'             => '',
    'source'            => 'eav/entity_attribute_source_boolean',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible'           => true,
    'required'          => false,
    'user_defined'      => false,
    'default'           => '',
    'searchable'        => false,
    'filterable'        => false,
    'comparable'        => false,
    'visible_on_front'  => false,
    'unique'            => false,
    'apply_to'          => 'configurable',
    'is_configurable'   => false,
//    'group'             => 'General',
));
$attributeId = $installer->getAttributeId('catalog_product', 'simple_price');

foreach ($installer->getAllAttributeSetIds('catalog_product') as $attributeSetId) 
{
    try {
        $attributeGroupId = $installer->getAttributeGroupId('catalog_product', $attributeSetId, 'General');
    } catch (Exception $e) {
        $attributeGroupId = $installer->getDefaultAttributeGroupId('catalog_product', $attributeSetId);
    }
    $installer->addAttributeToSet('catalog_product', $attributeSetId, $attributeGroupId, $attributeId);
}

$installer->endSetup();

@JanWGK JanWGK closed this as completed Jul 4, 2018
@sprankhub
Copy link
Member

It may be a good idea to add the attribute like this. I will reopen this, so that I can check this in more detail at some time. Thanks for the report!

@sprankhub sprankhub reopened this Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants