0

I have been receiving this error.

Error:

mysql4-install-1.0.php" - Wrong attribute set ID";i:1;s:1016:"#0 /Applications/MAMP/htdocs/flicdes/app/code/core/Mage/Core/Model/Resource/Setup.php(644): Mage::exception('Mage_Core', 'Error in file: ...')

Code:

<?php

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->load();
foreach ($attributeSetCollection as $id => $attributeSet) {
    $setup->addAttributeGroup('catalog_product', $attributeSet->getAttributeSetName(), 'Product Brand', 1000);
}
$setup->addAttribute('catalog_product', 'mgs_brand', array(
    'group' => 'Product Brand',
    'label' => 'MGS Brand',
    'type' => 'int',
    'input' => 'select',
    'frontend_class' => '',
    'source' => '',
    'backend' => '',
    'frontend' => '',
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible' => true,
    'required' => false,
    'user_defined' => true,
    'searchable' => false,
    'filterable' => false,
    'comparable' => false,
    'visible_on_front' => false,
    'visible_in_advanced_search' => false,
    'unique' => false
));
$setup->updateAttribute('catalog_product', 'mgs_brand', 'is_filterable', 0);
$setup->updateAttribute('catalog_product', 'mgs_brand', 'is_filterable_in_search', 0);
$setup->updateAttribute('catalog_product', 'mgs_brand', 'is_visible_on_front', 0);
$setup->updateAttribute('catalog_product', 'mgs_brand', 'used_in_product_listing', 0);
$installer->run("
DROP TABLE IF EXISTS {$this->getTable('mgs_brand')};
CREATE TABLE IF NOT EXISTS {$this->getTable('mgs_brand')} (
  `entity_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL DEFAULT '',
  `url_key` varchar(255) NOT NULL DEFAULT '',
  `icon` varchar(255) NOT NULL DEFAULT '',
  `image` varchar(255) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  `meta_keywords` text NOT NULL,
  `meta_description` text NOT NULL,
  `status` smallint(6) NOT NULL DEFAULT '1',
  `is_featured` smallint(6) NOT NULL DEFAULT '0',
  `priority` int(11) NOT NULL DEFAULT '0',
  `number_of_products` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`entity_id`),
  UNIQUE KEY (`url_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS {$this->getTable('mgs_brand_products')};
CREATE TABLE IF NOT EXISTS {$this->getTable('mgs_brand_products')} (
  `entity_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) unsigned NOT NULL,
  `product_id` int(11) unsigned NOT NULL,
  PRIMARY KEY (`entity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    ");
$installer->endSetup();
0

Try to replace entity_id with id So:

<?php

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->load();
foreach ($attributeSetCollection as $id => $attributeSet) {
    $setup->addAttributeGroup('catalog_product', $attributeSet->getAttributeSetName(), 'Product Brand', 1000);
}
$setup->addAttribute('catalog_product', 'mgs_brand', array(
    'group' => 'Product Brand',
    'label' => 'MGS Brand',
    'type' => 'int',
    'input' => 'select',
    'frontend_class' => '',
    'source' => '',
    'backend' => '',
    'frontend' => '',
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible' => true,
    'required' => false,
    'user_defined' => true,
    'searchable' => false,
    'filterable' => false,
    'comparable' => false,
    'visible_on_front' => false,
    'visible_in_advanced_search' => false,
    'unique' => false
));
$setup->updateAttribute('catalog_product', 'mgs_brand', 'is_filterable', 0);
$setup->updateAttribute('catalog_product', 'mgs_brand', 'is_filterable_in_search', 0);
$setup->updateAttribute('catalog_product', 'mgs_brand', 'is_visible_on_front', 0);
$setup->updateAttribute('catalog_product', 'mgs_brand', 'used_in_product_listing', 0);
$installer->run("
DROP TABLE IF EXISTS {$this->getTable('mgs_brand')};
CREATE TABLE IF NOT EXISTS {$this->getTable('mgs_brand')} (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL DEFAULT '',
  `url_key` varchar(255) NOT NULL DEFAULT '',
  `icon` varchar(255) NOT NULL DEFAULT '',
  `image` varchar(255) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  `meta_keywords` text NOT NULL,
  `meta_description` text NOT NULL,
  `status` smallint(6) NOT NULL DEFAULT '1',
  `is_featured` smallint(6) NOT NULL DEFAULT '0',
  `priority` int(11) NOT NULL DEFAULT '0',
  `number_of_products` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY (`url_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS {$this->getTable('mgs_brand_products')};
CREATE TABLE IF NOT EXISTS {$this->getTable('mgs_brand_products')} (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) unsigned NOT NULL,
  `product_id` int(11) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    ");
$installer->endSetup();
  • I have got the same error. – L.TurT Sep 10 '18 at 23:06
  • a:5:{i:0;s:139:"Error in file: "/Applications/MAMP/htdocs/flicdes/app/code/local/MGS/Brand/sql/brand_setup/mysql4-install-1.0.php" - Wrong attribute set ID";i:1;s:1016:"#0 /Applications/MAMP/htdocs/flicdes/app/code/core/Mage/Core/Model/Resource/Setup.php(644): Mage::exception('Mage_Core', 'Error in file: ...') #1 /Applications/MAMP/htdocs/flicdes/app/code/core/Mage/Core/Model/Resource/Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '1.1') – L.TurT Sep 10 '18 at 23:08
  • Did you changed your AttributeSet ? – PЯINCƏ Sep 11 '18 at 7:43
  • Hi, yes, I changed all words 'entity_id' for 'id', and got the same error. – L.TurT Sep 12 '18 at 16:16
  • Magento version: 1.9.3.8 – L.TurT Sep 12 '18 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.